On 2015-10-04 05.37, Jeff King wrote: > On Sat, Oct 03, 2015 at 11:12:13PM +0200, Torsten Bögershausen wrote: > >>> Hmph, Peff's quick-fix passed the original "CoNfIg" in &buf directly >>> to probe_utf8_pathname_composition() without changing its signature. >> True, ( I was thinking that the test did only work on case insensitive FS). >> We can skip that change. >> >> Beside that, I later realized, that a better signature could be: >> +void probe_utf8_pathname_composition(const char *path, size_t len) >> >> I can send a proper patch the next days. > That is the original signature, before my sprintf series. I do not mind > leaving that as-is, and simply cleaning up probe_utf8_pathname_composition > by using a strbuf internally there. Though I have to wonder if it even > needs us to pass _anything_ at that point. It could just call > git_path_buf("config%s", auml_nfd) itself. The whole reason to pass > anything was to let it reuse the buffer the caller had. > > -Peff Makes sense, here is V2: git diff 07690109b6a252ac7cbede diff --git a/builtin/init-db.c b/builtin/init-db.c index 89f2c05..4892579 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -276,7 +276,7 @@ static int create_default_files(const char *template_path) path = git_path_buf(&buf, "CoNfIg"); if (!access(path, F_OK)) git_config_set("core.ignorecase", "true"); - probe_utf8_pathname_composition(path); + probe_utf8_pathname_composition(); } strbuf_release(&buf); diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c index b4dd3c7..64b85f2 100644 --- a/compat/precompose_utf8.c +++ b/compat/precompose_utf8.c @@ -8,6 +8,7 @@ #include "cache.h" #include "utf8.h" #include "precompose_utf8.h" +#include "strbuf.h" typedef char *iconv_ibp; static const char *repo_encoding = "UTF-8"; @@ -36,28 +37,27 @@ static size_t has_non_ascii(const char *s, size_t maxlen, size_t *strlen_c) } -void probe_utf8_pathname_composition(struct strbuf *path) +void probe_utf8_pathname_composition(void) { + struct strbuf sbuf = STRBUF_INIT; static const char *auml_nfc = "\xc3\xa4"; static const char *auml_nfd = "\x61\xcc\x88"; - size_t baselen = path->len; + const char *path; int output_fd; if (precomposed_unicode != -1) return; /* We found it defined in the global config, respect it */ - strbuf_addstr(path, auml_nfc); + path = git_path_buf(&sbuf, "%s", auml_nfc); output_fd = open(path, O_CREAT|O_EXCL|O_RDWR, 0600); if (output_fd >= 0) { close(output_fd); - strbuf_setlen(path, baselen); - strbuf_addstr(path, auml_nfd); + path = git_path_buf(&sbuf, "%s", auml_nfd); precomposed_unicode = access(path, R_OK) ? 0 : 1; git_config_set("core.precomposeunicode", precomposed_unicode ? "true" : "false"); - strbuf_setlen(path, baselen); - strbuf_addstr(path, auml_nfc); + path = git_path_buf(&sbuf, "%s", auml_nfc); if (unlink(path)) die_errno(_("failed to unlink '%s'"), path); } - strbuf_setlen(path, baselen); + strbuf_release(&sbuf); } diff --git a/compat/precompose_utf8.h b/compat/precompose_utf8.h index 7fc7be5..a94e7c4 100644 --- a/compat/precompose_utf8.h +++ b/compat/precompose_utf8.h @@ -27,7 +27,7 @@ typedef struct { } PREC_DIR; void precompose_argv(int argc, const char **argv); -void probe_utf8_pathname_composition(struct strbuf *path); +void probe_utf8_pathname_composition(void); PREC_DIR *precompose_utf8_opendir(const char *dirname); struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *dirp); ============================ And this is fix for David: diff --git a/refs.h b/refs.h index f499093..7dee497 100644 --- a/refs.h +++ b/refs.h @@ -670,7 +670,6 @@ typedef int (*ref_transaction_verify_fn)(struct ref_transaction *transaction, unsigned int flags, struct strbuf *err); typedef int (*ref_transaction_commit_fn)(struct ref_transaction *transaction, struct strbuf *err); -typedef void (*ref_transaction_free_fn)(struct ref_transaction *transaction); /* reflog functions */ typedef int (*for_each_reflog_ent_fn)(const char *refname, -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html