{"thread":{"id":"41423","subject":"[PATCH v5 01/15] config: introduce set_or_die wrappers","startedAt":"2016-02-16T12:56:27Z","lastAt":"2016-02-17T21:09:25Z","messageCount":25,"participants":["Patrick Steinhardt","Eric Sunshine","Junio C Hamano","Lars Schneider","Michael Blume"],"isPatch":true,"patchVersion":5,"patchTotal":15},"messages":[{"id":"278311","messageId":"1455627402-752-1-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":null,"subject":"[PATCH v5 00/15] config: make git_config_set die on failure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:27Z","receivedAt":"2016-02-16T12:56:27Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Fifth version of the config refactorings, version 4 can be found\nat [1]. Besides fixing up the Signed-off's and a typo in a commit\nmessage pointed out by Eric Sunshine the biggest changes relate\nto install_branch_config.\n\nJunio pointed out that it might not always be the most sensible\nthing to die when install_branch_config fails. After thinking\nabout it I changed the behavior of the function to print an error\nand advise message and return an error code. The error code is\nthen only used by the `git branch --set-upstream-to=` command to\nabort early, as its main intent will usually be to set the\ntracking information. The other callers (related to git-clone and\ngit-push) simply ignore the returned value while the messages are\nstill printed.\n\nI think it does make sense to not abort clones and pushes when\nthe function fails. Setting the upstream information is only a\nsmall part of these commands and especially when cloning a large\nrepository it is harmful to die as this would delete everything\nthat has just been cloned. The user can still fix up the remote\ntracking branch afterwards.\n\n[1]: http://article.gmane.org/gmane.comp.version-control.git/285250\n\nInterdiff between v4 and v5:\n\ndiff --git a/branch.c b/branch.c\nindex 0c11023..06942ef 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -49,7 +49,13 @@ static int should_setup_rebase(const char *origin)\n \treturn 0;\n }\n \n-void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n+static const char tracking_advice[] =\n+N_(\"\\n\"\n+\"After fixing the error cause you may try to fix up\\n\"\n+\"the remote tracking information by invoking\\n\"\n+\"\\\"git branch --set-upstream-to=\\\".\");\n+\n+int install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n {\n \tconst char *shortname = NULL;\n \tstruct strbuf key = STRBUF_INIT;\n@@ -60,20 +66,23 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t    && !origin) {\n \t\twarning(_(\"Not setting branch %s as its own upstream.\"),\n \t\t\tlocal);\n-\t\treturn;\n+\t\treturn 0;\n \t}\n \n \tstrbuf_addf(&key, \"branch.%s.remote\", local);\n-\tgit_config_set(key.buf, origin ? origin : \".\");\n+\tif (git_config_set_gently(key.buf, origin ? origin : \".\") < 0)\n+\t\tgoto out_err;\n \n \tstrbuf_reset(&key);\n \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n-\tgit_config_set(key.buf, remote);\n+\tif (git_config_set_gently(key.buf, remote) < 0)\n+\t\tgoto out_err;\n \n \tif (rebasing) {\n \t\tstrbuf_reset(&key);\n \t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n-\t\tgit_config_set(key.buf, \"true\");\n+\t\tif (git_config_set_gently(key.buf, \"true\") < 0)\n+\t\t    goto out_err;\n \t}\n \tstrbuf_release(&key);\n \n@@ -102,6 +111,14 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t\t\t\t\t  local, remote);\n \t\t}\n \t}\n+\n+\treturn 0;\n+\n+out_err:\n+\tstrbuf_release(&key);\n+\terror(_(\"Unable to write upstream branch configuration\"));\n+\tadvise(_(tracking_advice));\n+\treturn -1;\n }\n \n /*\n@@ -134,8 +151,9 @@ static void setup_tracking(const char *new_ref, const char *orig_ref,\n \t\tdie(_(\"Not tracking: ambiguous information for ref %s\"),\n \t\t    orig_ref);\n \n-\tinstall_branch_config(config_flags, new_ref, tracking.remote,\n-\t\t\t      tracking.src ? tracking.src : orig_ref);\n+\tif (install_branch_config(config_flags, new_ref, tracking.remote,\n+\t\t\t      tracking.src ? tracking.src : orig_ref) < 0)\n+\t\texit(-1);\n \n \tfree(tracking.src);\n }\ndiff --git a/branch.h b/branch.h\nindex 8ce22f8..78ad438 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -43,10 +43,10 @@ void remove_branch_state(void);\n /*\n  * Configure local branch \"local\" as downstream to branch \"remote\"\n  * from remote \"origin\".  Used by git branch --set-upstream.\n- * Dies if unable to install branch config.\n+ * Returns 0 on success.\n  */\n #define BRANCH_CONFIG_VERBOSE 01\n-extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n+extern int install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n \n /*\n  * Read branch description\n\n\nPatrick Steinhardt (15):\n  config: introduce set_or_die wrappers\n  branch: report errors in tracking branch setup\n  branch: die on config error when unsetting upstream\n  branch: die on config error when editing branch description\n  submodule: die on config error when linking modules\n  submodule--helper: die on config error when cloning module\n  remote: die on config error when setting URL\n  remote: die on config error when setting/adding branches\n  remote: die on config error when manipulating remotes\n  clone: die on config error in cmd_clone\n  init-db: die on config errors when initializing empty repo\n  sequencer: die on config error when saving replay opts\n  compat: die when unable to set core.precomposeunicode\n  config: rename git_config_set to git_config_set_gently\n  config: rename git_config_set_or_die to git_config_set\n\n branch.c                 | 45 +++++++++++++++++++++----------\n branch.h                 |  3 ++-\n builtin/branch.c         |  5 ++--\n builtin/clone.c          |  2 +-\n builtin/config.c         | 28 +++++++++----------\n builtin/init-db.c        |  2 +-\n builtin/remote.c         | 70 +++++++++++++++++-------------------------------\n cache.h                  | 14 ++++++----\n compat/precompose_utf8.c |  3 ++-\n config.c                 | 52 ++++++++++++++++++++++++++---------\n submodule.c              | 10 +++----\n t/t3200-branch.sh        | 16 ++++++++++-\n t/t5505-remote.sh        |  9 +++++++\n 13 files changed, 154 insertions(+), 105 deletions(-)\n\n-- \n2.7.1\n"},{"id":"278297","messageId":"1455627402-752-2-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 01/15] config: introduce set_or_die wrappers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:28Z","receivedAt":"2016-02-16T12:56:28Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"A lot of call-sites for the existing family of `git_config_set`\nfunctions do not check for errors that may occur, e.g. when the\nconfiguration file is locked. In many cases we simply want to die\nwhen such a situation arises.\n\nIntroduce wrappers that will cause the program to die in those\ncases. These wrappers are temporary only to ease the transition\nto let `git_config_set` die by default. They will be removed\nlater on when `git_config_set` itself has been replaced by\n`git_config_set_gently`.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n cache.h  |  4 ++++\n config.c | 27 +++++++++++++++++++++++++++\n 2 files changed, 31 insertions(+)\n\ndiff --git a/cache.h b/cache.h\nindex 553b04b..6870a25 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1526,11 +1526,15 @@ extern int git_config_maybe_bool(const char *, const char *);\n extern int git_config_string(const char **, const char *, const char *);\n extern int git_config_pathname(const char **, const char *, const char *);\n extern int git_config_set_in_file(const char *, const char *, const char *);\n+extern void git_config_set_in_file_or_die(const char *, const char *, const char *);\n extern int git_config_set(const char *, const char *);\n+extern void git_config_set_or_die(const char *, const char *);\n extern int git_config_parse_key(const char *, char **, int *);\n extern int git_config_key_is_valid(const char *key);\n extern int git_config_set_multivar(const char *, const char *, const char *, int);\n+extern void git_config_set_multivar_or_die(const char *, const char *, const char *, int);\n extern int git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);\n+extern void git_config_set_multivar_in_file_or_die(const char *, const char *, const char *, const char *, int);\n extern int git_config_rename_section(const char *, const char *);\n extern int git_config_rename_section_in_file(const char *, const char *, const char *);\n extern const char *git_etc_gitconfig(void);\ndiff --git a/config.c b/config.c\nindex 86a5eb2..856f7d34 100644\n--- a/config.c\n+++ b/config.c\n@@ -1831,11 +1831,22 @@ int git_config_set_in_file(const char *config_filename,\n \treturn git_config_set_multivar_in_file(config_filename, key, value, NULL, 0);\n }\n \n+void git_config_set_in_file_or_die(const char *config_filename,\n+\t\t\tconst char *key, const char *value)\n+{\n+\tgit_config_set_multivar_in_file_or_die(config_filename, key, value, NULL, 0);\n+}\n+\n int git_config_set(const char *key, const char *value)\n {\n \treturn git_config_set_multivar(key, value, NULL, 0);\n }\n \n+void git_config_set_or_die(const char *key, const char *value)\n+{\n+\tgit_config_set_multivar_or_die(key, value, NULL, 0);\n+}\n+\n /*\n  * Auxiliary function to sanity-check and split the key into the section\n  * identifier and variable name.\n@@ -2179,6 +2190,15 @@ write_err_out:\n \n }\n \n+void git_config_set_multivar_in_file_or_die(const char *config_filename,\n+\t\t\t\tconst char *key, const char *value,\n+\t\t\t\tconst char *value_regex, int multi_replace)\n+{\n+\tif (git_config_set_multivar_in_file(config_filename, key, value,\n+\t\t\t\t\t    value_regex, multi_replace) < 0)\n+\t\tdie(_(\"Could not set '%s' to '%s'\"), key, value);\n+}\n+\n int git_config_set_multivar(const char *key, const char *value,\n \t\t\tconst char *value_regex, int multi_replace)\n {\n@@ -2186,6 +2206,13 @@ int git_config_set_multivar(const char *key, const char *value,\n \t\t\t\t\t       multi_replace);\n }\n \n+void git_config_set_multivar_or_die(const char *key, const char *value,\n+\t\t\tconst char *value_regex, int multi_replace)\n+{\n+\tgit_config_set_multivar_in_file_or_die(NULL, key, value, value_regex,\n+\t\t\t\t\t       multi_replace);\n+}\n+\n static int section_name_match (const char *buf, const char *name)\n {\n \tint i = 0, j = 0, dot = 0;\n-- \n2.7.1\n"},{"id":"278309","messageId":"1455627402-752-3-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 02/15] branch: report errors in tracking branch setup","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:29Z","receivedAt":"2016-02-16T12:56:29Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When setting up a new tracking branch fails due to issues with\nthe configuration file we do not report any errors to the user\nand pretend setting the tracking branch succeeded.\n\nSetting up the tracking branch is handled by the\n`install_branch_config` function. We do not want to simply die\nthere as the function is not only invoked when explicitly setting\nupstream information with `git branch --set-upstream-to=`, but\nalso by `git push --set-upstream` and `git clone`. While it is\nreasonable to die in the explict first case, we would lose\ninformation in the latter two cases, so we only print the error\nmessage but continue the program as usual.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n branch.c          | 45 +++++++++++++++++++++++++++++++--------------\n branch.h          |  3 ++-\n t/t3200-branch.sh |  9 ++++++++-\n 3 files changed, 41 insertions(+), 16 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 7ff3f20..3b9ccea 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -49,7 +49,13 @@ static int should_setup_rebase(const char *origin)\n \treturn 0;\n }\n \n-void install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n+static const char tracking_advice[] =\n+N_(\"\\n\"\n+\"After fixing the error cause you may try to fix up\\n\"\n+\"the remote tracking information by invoking\\n\"\n+\"\\\"git branch --set-upstream-to=\\\".\");\n+\n+int install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n {\n \tconst char *shortname = NULL;\n \tstruct strbuf key = STRBUF_INIT;\n@@ -60,20 +66,23 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t    && !origin) {\n \t\twarning(_(\"Not setting branch %s as its own upstream.\"),\n \t\t\tlocal);\n-\t\treturn;\n+\t\treturn 0;\n \t}\n \n \tstrbuf_addf(&key, \"branch.%s.remote\", local);\n-\tgit_config_set(key.buf, origin ? origin : \".\");\n+\tif (git_config_set(key.buf, origin ? origin : \".\") < 0)\n+\t\tgoto out_err;\n \n \tstrbuf_reset(&key);\n \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n-\tgit_config_set(key.buf, remote);\n+\tif (git_config_set(key.buf, remote) < 0)\n+\t\tgoto out_err;\n \n \tif (rebasing) {\n \t\tstrbuf_reset(&key);\n \t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n-\t\tgit_config_set(key.buf, \"true\");\n+\t\tif (git_config_set(key.buf, \"true\") < 0)\n+\t\t    goto out_err;\n \t}\n \tstrbuf_release(&key);\n \n@@ -102,6 +111,14 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t\t\t\t\t  local, remote);\n \t\t}\n \t}\n+\n+\treturn 0;\n+\n+out_err:\n+\tstrbuf_release(&key);\n+\terror(_(\"Unable to write upstream branch configuration\"));\n+\tadvise(_(tracking_advice));\n+\treturn -1;\n }\n \n /*\n@@ -109,8 +126,8 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n  * to infer the settings for branch.<new_ref>.{remote,merge} from the\n  * config.\n  */\n-static int setup_tracking(const char *new_ref, const char *orig_ref,\n-\t\t\t  enum branch_track track, int quiet)\n+static void setup_tracking(const char *new_ref, const char *orig_ref,\n+\t\t\t   enum branch_track track, int quiet)\n {\n \tstruct tracking tracking;\n \tint config_flags = quiet ? 0 : BRANCH_CONFIG_VERBOSE;\n@@ -118,7 +135,7 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,\n \tmemset(&tracking, 0, sizeof(tracking));\n \ttracking.spec.dst = (char *)orig_ref;\n \tif (for_each_remote(find_tracked_branch, &tracking))\n-\t\treturn 1;\n+\t\treturn;\n \n \tif (!tracking.matches)\n \t\tswitch (track) {\n@@ -127,18 +144,18 @@ static int setup_tracking(const char *new_ref, const char *orig_ref,\n \t\tcase BRANCH_TRACK_OVERRIDE:\n \t\t\tbreak;\n \t\tdefault:\n-\t\t\treturn 1;\n+\t\t\treturn;\n \t\t}\n \n \tif (tracking.matches > 1)\n-\t\treturn error(_(\"Not tracking: ambiguous information for ref %s\"),\n-\t\t\t\torig_ref);\n+\t\tdie(_(\"Not tracking: ambiguous information for ref %s\"),\n+\t\t    orig_ref);\n \n-\tinstall_branch_config(config_flags, new_ref, tracking.remote,\n-\t\t\t      tracking.src ? tracking.src : orig_ref);\n+\tif (install_branch_config(config_flags, new_ref, tracking.remote,\n+\t\t\t      tracking.src ? tracking.src : orig_ref) < 0)\n+\t\texit(-1);\n \n \tfree(tracking.src);\n-\treturn 0;\n }\n \n int read_branch_desc(struct strbuf *buf, const char *branch_name)\ndiff --git a/branch.h b/branch.h\nindex 58aa45f..78ad438 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -43,9 +43,10 @@ void remove_branch_state(void);\n /*\n  * Configure local branch \"local\" as downstream to branch \"remote\"\n  * from remote \"origin\".  Used by git branch --set-upstream.\n+ * Returns 0 on success.\n  */\n #define BRANCH_CONFIG_VERBOSE 01\n-extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n+extern int install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n \n /*\n  * Read branch description\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex cdaf6f6..dd776b3 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -446,6 +446,13 @@ test_expect_success '--set-upstream-to fails on a non-ref' '\n \ttest_must_fail git branch --set-upstream-to HEAD^{}\n '\n \n+test_expect_success '--set-upstream-to fails on locked config' '\n+\ttest_when_finished \"rm -f .git/config.lock\" &&\n+\t>.git/config.lock &&\n+\tgit branch locked &&\n+\ttest_must_fail git branch --set-upstream-to locked\n+'\n+\n test_expect_success 'use --set-upstream-to modify HEAD' '\n \ttest_config branch.master.remote foo &&\n \ttest_config branch.master.merge foo &&\n@@ -579,7 +586,7 @@ test_expect_success 'avoid ambiguous track' '\n \tgit config remote.ambi1.fetch refs/heads/lalala:refs/heads/master &&\n \tgit config remote.ambi2.url lilili &&\n \tgit config remote.ambi2.fetch refs/heads/lilili:refs/heads/master &&\n-\tgit branch all1 master &&\n+\ttest_must_fail git branch all1 master &&\n \ttest -z \"$(git config branch.all1.merge)\"\n '\n \n-- \n2.7.1\n"},{"id":"278298","messageId":"1455627402-752-4-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 03/15] branch: die on config error when unsetting upstream","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:30Z","receivedAt":"2016-02-16T12:56:30Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When we try to unset upstream configurations we do not check\nreturn codes for the `git_config_set` functions. As those may\nindicate that we were unable to unset the respective\nconfiguration we may exit successfully without any error message\nwhile in fact the upstream configuration was not unset.\n\nFix this by dying with an error message when we cannot unset the\nconfiguration.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/branch.c  | 4 ++--\n t/t3200-branch.sh | 7 +++++++\n 2 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 3f6c825..0978287 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -791,10 +791,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"Branch '%s' has no upstream information\"), branch->name);\n \n \t\tstrbuf_addf(&buf, \"branch.%s.remote\", branch->name);\n-\t\tgit_config_set_multivar(buf.buf, NULL, NULL, 1);\n+\t\tgit_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n \t\tstrbuf_reset(&buf);\n \t\tstrbuf_addf(&buf, \"branch.%s.merge\", branch->name);\n-\t\tgit_config_set_multivar(buf.buf, NULL, NULL, 1);\n+\t\tgit_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n \t\tstrbuf_release(&buf);\n \t} else if (argc > 0 && argc <= 2) {\n \t\tstruct branch *branch = branch_get(argv[0]);\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex dd776b3..a897248 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -473,6 +473,13 @@ test_expect_success '--unset-upstream should fail if given a non-existent branch\n \ttest_must_fail git branch --unset-upstream i-dont-exist\n '\n \n+test_expect_success '--unset-upstream should fail if config is locked' '\n+\ttest_when_finished \"rm -f .git/config.lock\" &&\n+\tgit branch --set-upstream-to locked &&\n+\t>.git/config.lock &&\n+\ttest_must_fail git branch --unset-upstream\n+'\n+\n test_expect_success 'test --unset-upstream on HEAD' '\n \tgit branch my14 &&\n \ttest_config branch.master.remote foo &&\n-- \n2.7.1\n"},{"id":"278312","messageId":"1455627402-752-5-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 04/15] branch: die on config error when editing branch description","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:31Z","receivedAt":"2016-02-16T12:56:31Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Signed-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/branch.c | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 0978287..c043cfc 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -570,7 +570,6 @@ static const char edit_description[] = \"BRANCH_DESCRIPTION\";\n \n static int edit_branch_description(const char *branch_name)\n {\n-\tint status;\n \tstruct strbuf buf = STRBUF_INIT;\n \tstruct strbuf name = STRBUF_INIT;\n \n@@ -595,11 +594,11 @@ static int edit_branch_description(const char *branch_name)\n \tstrbuf_stripspace(&buf, 1);\n \n \tstrbuf_addf(&name, \"branch.%s.description\", branch_name);\n-\tstatus = git_config_set(name.buf, buf.len ? buf.buf : NULL);\n+\tgit_config_set_or_die(name.buf, buf.len ? buf.buf : NULL);\n \tstrbuf_release(&name);\n \tstrbuf_release(&buf);\n \n-\treturn status;\n+\treturn 0;\n }\n \n int cmd_branch(int argc, const char **argv, const char *prefix)\n-- \n2.7.1\n"},{"id":"278310","messageId":"1455627402-752-6-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 05/15] submodule: die on config error when linking modules","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:32Z","receivedAt":"2016-02-16T12:56:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When trying to connect a submodule with its corresponding\nrepository in '.git/modules' we try to set the core.worktree\nsetting in the submodule, which may fail due to an error\nencountered in `git_config_set_in_file`.\n\nThe function is used in the git-mv command when trying to move a\nsubmodule to another location. We already die when renaming a\nfile fails but do not pay attention to the case where updating\nthe connection between submodule and its repository fails. As\nthis leaves the repository in an inconsistent state, as well,\nabort the program by dying early and presenting the failure to\nthe user.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n submodule.c | 8 +++-----\n 1 file changed, 3 insertions(+), 5 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex b83939c..589a82c 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -1087,11 +1087,9 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)\n \t/* Update core.worktree setting */\n \tstrbuf_reset(&file_name);\n \tstrbuf_addf(&file_name, \"%s/config\", git_dir);\n-\tif (git_config_set_in_file(file_name.buf, \"core.worktree\",\n-\t\t\t\t   relative_path(real_work_tree, git_dir,\n-\t\t\t\t\t\t &rel_path)))\n-\t\tdie(_(\"Could not set core.worktree in %s\"),\n-\t\t    file_name.buf);\n+\tgit_config_set_in_file_or_die(file_name.buf, \"core.worktree\",\n+\t\t\t\t      relative_path(real_work_tree, git_dir,\n+\t\t\t\t\t\t    &rel_path));\n \n \tstrbuf_release(&file_name);\n \tstrbuf_release(&rel_path);\n-- \n2.7.1\n"},{"id":"278299","messageId":"1455627402-752-7-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 06/15] submodule--helper: die on config error when cloning module","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:33Z","receivedAt":"2016-02-16T12:56:33Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When setting the 'core.worktree' option for a newly cloned\nsubmodule we ignore the return value of `git_config_set_in_file`.\nAs this leaves the submodule in an inconsistent state, we instead\nwant to inform the user that something has gone wrong by printing\nan error and aborting the program.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/submodule--helper.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex f4c3eff..c7e1ea2 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -245,8 +245,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \tp = git_pathdup_submodule(path, \"config\");\n \tif (!p)\n \t\tdie(_(\"could not get submodule directory for '%s'\"), path);\n-\tgit_config_set_in_file(p, \"core.worktree\",\n-\t\t\t       relative_path(sb.buf, sm_gitdir, &rel_path));\n+\tgit_config_set_in_file_or_die(p, \"core.worktree\",\n+\t\t\t\t      relative_path(sb.buf, sm_gitdir, &rel_path));\n \tstrbuf_release(&sb);\n \tstrbuf_release(&rel_path);\n \tfree(sm_gitdir);\n-- \n2.7.1\n"},{"id":"278306","messageId":"1455627402-752-8-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 07/15] remote: die on config error when setting URL","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:34Z","receivedAt":"2016-02-16T12:56:34Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When invoking `git-remote --set-url` we do not check the return\nvalue when writing the actual new URL to the configuration file,\npretending to the user that the configuration has been set while\nit was in fact not persisted.\n\nFix this problem by dying early when setting the config fails.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/remote.c  | 11 ++++++-----\n t/t5505-remote.sh |  9 +++++++++\n 2 files changed, 15 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 2b2ff9b..8b78c3d 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -1583,11 +1583,12 @@ static int set_url(int argc, const char **argv)\n \t/* Special cases that add new entry. */\n \tif ((!oldurl && !delete_mode) || add_mode) {\n \t\tif (add_mode)\n-\t\t\tgit_config_set_multivar(name_buf.buf, newurl,\n-\t\t\t\t\"^$\", 0);\n+\t\t\tgit_config_set_multivar_or_die(name_buf.buf, newurl,\n+\t\t\t\t\t\t       \"^$\", 0);\n \t\telse\n-\t\t\tgit_config_set(name_buf.buf, newurl);\n+\t\t\tgit_config_set_or_die(name_buf.buf, newurl);\n \t\tstrbuf_release(&name_buf);\n+\n \t\treturn 0;\n \t}\n \n@@ -1608,9 +1609,9 @@ static int set_url(int argc, const char **argv)\n \tregfree(&old_regex);\n \n \tif (!delete_mode)\n-\t\tgit_config_set_multivar(name_buf.buf, newurl, oldurl, 0);\n+\t\tgit_config_set_multivar_or_die(name_buf.buf, newurl, oldurl, 0);\n \telse\n-\t\tgit_config_set_multivar(name_buf.buf, NULL, oldurl, 1);\n+\t\tgit_config_set_multivar_or_die(name_buf.buf, NULL, oldurl, 1);\n \treturn 0;\n }\n \ndiff --git a/t/t5505-remote.sh b/t/t5505-remote.sh\nindex 1a8e3b8..e019f27 100755\n--- a/t/t5505-remote.sh\n+++ b/t/t5505-remote.sh\n@@ -932,6 +932,15 @@ test_expect_success 'get-url on new remote' '\n \techo foo | get_url_test --push --all someremote\n '\n \n+test_expect_success 'remote set-url with locked config' '\n+\ttest_when_finished \"rm -f .git/config.lock\" &&\n+\tgit config --get-all remote.someremote.url >expect &&\n+\t>.git/config.lock &&\n+\ttest_must_fail git remote set-url someremote baz &&\n+\tgit config --get-all remote.someremote.url >actual &&\n+\tcmp expect actual\n+'\n+\n test_expect_success 'remote set-url bar' '\n \tgit remote set-url someremote bar &&\n \techo bar >expect &&\n-- \n2.7.1\n"},{"id":"278300","messageId":"1455627402-752-9-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 08/15] remote: die on config error when setting/adding branches","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:35Z","receivedAt":"2016-02-16T12:56:35Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When we add or set new branches (e.g. by `git remote add -f` or\n`git remote set-branches`) we do not check for error codes when\nwriting the branches to the configuration file. When persisting\nthe configuration failed we are left with a remote that has none\nor not all of the branches that should have been set without\nnotifying the user.\n\nFix this issue by dying early on configuration error.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/remote.c | 26 +++++++++-----------------\n 1 file changed, 9 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex 8b78c3d..eeb6d2e 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -108,8 +108,8 @@ enum {\n #define MIRROR_PUSH 2\n #define MIRROR_BOTH (MIRROR_FETCH|MIRROR_PUSH)\n \n-static int add_branch(const char *key, const char *branchname,\n-\t\tconst char *remotename, int mirror, struct strbuf *tmp)\n+static void add_branch(const char *key, const char *branchname,\n+\t\t       const char *remotename, int mirror, struct strbuf *tmp)\n {\n \tstrbuf_reset(tmp);\n \tstrbuf_addch(tmp, '+');\n@@ -119,7 +119,7 @@ static int add_branch(const char *key, const char *branchname,\n \telse\n \t\tstrbuf_addf(tmp, \"refs/heads/%s:refs/remotes/%s/%s\",\n \t\t\t\tbranchname, remotename, branchname);\n-\treturn git_config_set_multivar(key, tmp->buf, \"^$\", 0);\n+\tgit_config_set_multivar_or_die(key, tmp->buf, \"^$\", 0);\n }\n \n static const char mirror_advice[] =\n@@ -206,9 +206,8 @@ static int add(int argc, const char **argv)\n \t\tif (track.nr == 0)\n \t\t\tstring_list_append(&track, \"*\");\n \t\tfor (i = 0; i < track.nr; i++) {\n-\t\t\tif (add_branch(buf.buf, track.items[i].string,\n-\t\t\t\t       name, mirror, &buf2))\n-\t\t\t\treturn 1;\n+\t\t\tadd_branch(buf.buf, track.items[i].string,\n+\t\t\t\t   name, mirror, &buf2);\n \t\t}\n \t}\n \n@@ -1416,21 +1415,17 @@ static int remove_all_fetch_refspecs(const char *remote, const char *key)\n \treturn git_config_set_multivar(key, NULL, NULL, 1);\n }\n \n-static int add_branches(struct remote *remote, const char **branches,\n-\t\t\tconst char *key)\n+static void add_branches(struct remote *remote, const char **branches,\n+\t\t\t const char *key)\n {\n \tconst char *remotename = remote->name;\n \tint mirror = remote->mirror;\n \tstruct strbuf refspec = STRBUF_INIT;\n \n \tfor (; *branches; branches++)\n-\t\tif (add_branch(key, *branches, remotename, mirror, &refspec)) {\n-\t\t\tstrbuf_release(&refspec);\n-\t\t\treturn 1;\n-\t\t}\n+\t\tadd_branch(key, *branches, remotename, mirror, &refspec);\n \n \tstrbuf_release(&refspec);\n-\treturn 0;\n }\n \n static int set_remote_branches(const char *remotename, const char **branches,\n@@ -1449,10 +1444,7 @@ static int set_remote_branches(const char *remotename, const char **branches,\n \t\tstrbuf_release(&key);\n \t\treturn 1;\n \t}\n-\tif (add_branches(remote, branches, key.buf)) {\n-\t\tstrbuf_release(&key);\n-\t\treturn 1;\n-\t}\n+\tadd_branches(remote, branches, key.buf);\n \n \tstrbuf_release(&key);\n \treturn 0;\n-- \n2.7.1\n"},{"id":"278301","messageId":"1455627402-752-10-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 09/15] remote: die on config error when manipulating remotes","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:36Z","receivedAt":"2016-02-16T12:56:36Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When manipulating remotes we try to set various configuration\nvalues without checking if the values were persisted correctly,\npossibly leaving the remote in an inconsistent state.\n\nFix this issue by dying early and notifying the user about the\nerror.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/remote.c | 39 ++++++++++++---------------------------\n 1 file changed, 12 insertions(+), 27 deletions(-)\n\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex eeb6d2e..fe57f77 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -197,8 +197,7 @@ static int add(int argc, const char **argv)\n \t\tdie(_(\"'%s' is not a valid remote name\"), name);\n \n \tstrbuf_addf(&buf, \"remote.%s.url\", name);\n-\tif (git_config_set(buf.buf, url))\n-\t\treturn 1;\n+\tgit_config_set_or_die(buf.buf, url);\n \n \tif (!mirror || mirror & MIRROR_FETCH) {\n \t\tstrbuf_reset(&buf);\n@@ -214,16 +213,14 @@ static int add(int argc, const char **argv)\n \tif (mirror & MIRROR_PUSH) {\n \t\tstrbuf_reset(&buf);\n \t\tstrbuf_addf(&buf, \"remote.%s.mirror\", name);\n-\t\tif (git_config_set(buf.buf, \"true\"))\n-\t\t\treturn 1;\n+\t\tgit_config_set_or_die(buf.buf, \"true\");\n \t}\n \n \tif (fetch_tags != TAGS_DEFAULT) {\n \t\tstrbuf_reset(&buf);\n \t\tstrbuf_addf(&buf, \"remote.%s.tagopt\", name);\n-\t\tif (git_config_set(buf.buf,\n-\t\t\tfetch_tags == TAGS_SET ? \"--tags\" : \"--no-tags\"))\n-\t\t\treturn 1;\n+\t\tgit_config_set_or_die(buf.buf,\n+\t\t\t\t      fetch_tags == TAGS_SET ? \"--tags\" : \"--no-tags\");\n \t}\n \n \tif (fetch && fetch_remote(name))\n@@ -591,25 +588,20 @@ static int migrate_file(struct remote *remote)\n \n \tstrbuf_addf(&buf, \"remote.%s.url\", remote->name);\n \tfor (i = 0; i < remote->url_nr; i++)\n-\t\tif (git_config_set_multivar(buf.buf, remote->url[i], \"^$\", 0))\n-\t\t\treturn error(_(\"Could not append '%s' to '%s'\"),\n-\t\t\t\t\tremote->url[i], buf.buf);\n+\t\tgit_config_set_multivar_or_die(buf.buf, remote->url[i], \"^$\", 0);\n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.push\", remote->name);\n \tfor (i = 0; i < remote->push_refspec_nr; i++)\n-\t\tif (git_config_set_multivar(buf.buf, remote->push_refspec[i], \"^$\", 0))\n-\t\t\treturn error(_(\"Could not append '%s' to '%s'\"),\n-\t\t\t\t\tremote->push_refspec[i], buf.buf);\n+\t\tgit_config_set_multivar_or_die(buf.buf, remote->push_refspec[i], \"^$\", 0);\n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.fetch\", remote->name);\n \tfor (i = 0; i < remote->fetch_refspec_nr; i++)\n-\t\tif (git_config_set_multivar(buf.buf, remote->fetch_refspec[i], \"^$\", 0))\n-\t\t\treturn error(_(\"Could not append '%s' to '%s'\"),\n-\t\t\t\t\tremote->fetch_refspec[i], buf.buf);\n+\t\tgit_config_set_multivar_or_die(buf.buf, remote->fetch_refspec[i], \"^$\", 0);\n \tif (remote->origin == REMOTE_REMOTES)\n \t\tunlink_or_warn(git_path(\"remotes/%s\", remote->name));\n \telse if (remote->origin == REMOTE_BRANCHES)\n \t\tunlink_or_warn(git_path(\"branches/%s\", remote->name));\n+\n \treturn 0;\n }\n \n@@ -656,8 +648,7 @@ static int mv(int argc, const char **argv)\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.fetch\", rename.new);\n-\tif (git_config_set_multivar(buf.buf, NULL, NULL, 1))\n-\t\treturn error(_(\"Could not remove config section '%s'\"), buf.buf);\n+\tgit_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n \tstrbuf_addf(&old_remote_context, \":refs/remotes/%s/\", rename.old);\n \tfor (i = 0; i < oldremote->fetch_refspec_nr; i++) {\n \t\tchar *ptr;\n@@ -677,8 +668,7 @@ static int mv(int argc, const char **argv)\n \t\t\t\t  \"\\tPlease update the configuration manually if necessary.\"),\n \t\t\t\tbuf2.buf);\n \n-\t\tif (git_config_set_multivar(buf.buf, buf2.buf, \"^$\", 0))\n-\t\t\treturn error(_(\"Could not append '%s'\"), buf.buf);\n+\t\tgit_config_set_multivar_or_die(buf.buf, buf2.buf, \"^$\", 0);\n \t}\n \n \tread_branches();\n@@ -688,9 +678,7 @@ static int mv(int argc, const char **argv)\n \t\tif (info->remote_name && !strcmp(info->remote_name, rename.old)) {\n \t\t\tstrbuf_reset(&buf);\n \t\t\tstrbuf_addf(&buf, \"branch.%s.remote\", item->string);\n-\t\t\tif (git_config_set(buf.buf, rename.new)) {\n-\t\t\t\treturn error(_(\"Could not set '%s'\"), buf.buf);\n-\t\t\t}\n+\t\t\tgit_config_set_or_die(buf.buf, rename.new);\n \t\t}\n \t}\n \n@@ -788,10 +776,7 @@ static int rm(int argc, const char **argv)\n \t\t\t\tstrbuf_reset(&buf);\n \t\t\t\tstrbuf_addf(&buf, \"branch.%s.%s\",\n \t\t\t\t\t\titem->string, *k);\n-\t\t\t\tif (git_config_set(buf.buf, NULL)) {\n-\t\t\t\t\tstrbuf_release(&buf);\n-\t\t\t\t\treturn -1;\n-\t\t\t\t}\n+\t\t\t\tgit_config_set_or_die(buf.buf, NULL);\n \t\t\t}\n \t\t}\n \t}\n-- \n2.7.1\n"},{"id":"278304","messageId":"1455627402-752-11-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 10/15] clone: die on config error in cmd_clone","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:37Z","receivedAt":"2016-02-16T12:56:37Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The clone command does not check for error codes returned by\n`git_config_set` functions. This may cause the user to end up\nwith an inconsistent repository without any indication with what\nwent wrong.\n\nFix this problem by dying with an error message when we are\nunable to write the configuration files to disk.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/clone.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex bcba080..164038a 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -786,12 +786,12 @@ static void write_refspec_config(const char *src_ref_prefix,\n \t\t/* Configure the remote */\n \t\tif (value.len) {\n \t\t\tstrbuf_addf(&key, \"remote.%s.fetch\", option_origin);\n-\t\t\tgit_config_set_multivar(key.buf, value.buf, \"^$\", 0);\n+\t\t\tgit_config_set_multivar_or_die(key.buf, value.buf, \"^$\", 0);\n \t\t\tstrbuf_reset(&key);\n \n \t\t\tif (option_mirror) {\n \t\t\t\tstrbuf_addf(&key, \"remote.%s.mirror\", option_origin);\n-\t\t\t\tgit_config_set(key.buf, \"true\");\n+\t\t\t\tgit_config_set_or_die(key.buf, \"true\");\n \t\t\t\tstrbuf_reset(&key);\n \t\t\t}\n \t\t}\n@@ -949,14 +949,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\t\tsrc_ref_prefix = \"refs/\";\n \t\tstrbuf_addstr(&branch_top, src_ref_prefix);\n \n-\t\tgit_config_set(\"core.bare\", \"true\");\n+\t\tgit_config_set_or_die(\"core.bare\", \"true\");\n \t} else {\n \t\tstrbuf_addf(&branch_top, \"refs/remotes/%s/\", option_origin);\n \t}\n \n \tstrbuf_addf(&value, \"+%s*:%s*\", src_ref_prefix, branch_top.buf);\n \tstrbuf_addf(&key, \"remote.%s.url\", option_origin);\n-\tgit_config_set(key.buf, repo);\n+\tgit_config_set_or_die(key.buf, repo);\n \tstrbuf_reset(&key);\n \n \tif (option_reference.nr)\n-- \n2.7.1\n"},{"id":"278308","messageId":"1455627402-752-12-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 11/15] init-db: die on config errors when initializing empty repo","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:38Z","receivedAt":"2016-02-16T12:56:38Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When creating an empty repository with `git init-db` we do not\ncheck for error codes returned by `git_config_set` functions.\nThis may cause the user to end up with an inconsistent repository\nwithout any indication for the user.\n\nFix this problem by dying early with an error message when we are\nunable to write the configuration files to disk.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/init-db.c | 20 ++++++++++----------\n 1 file changed, 10 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex 07229d6..ef19048 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -227,7 +227,7 @@ static int create_default_files(const char *template_path)\n \t/* This forces creation of new config file */\n \txsnprintf(repo_version_string, sizeof(repo_version_string),\n \t\t  \"%d\", GIT_REPO_VERSION);\n-\tgit_config_set(\"core.repositoryformatversion\", repo_version_string);\n+\tgit_config_set_or_die(\"core.repositoryformatversion\", repo_version_string);\n \n \t/* Check filemode trustability */\n \tpath = git_path_buf(&buf, \"config\");\n@@ -241,18 +241,18 @@ static int create_default_files(const char *template_path)\n \t\tif (filemode && !reinit && (st1.st_mode & S_IXUSR))\n \t\t\tfilemode = 0;\n \t}\n-\tgit_config_set(\"core.filemode\", filemode ? \"true\" : \"false\");\n+\tgit_config_set_or_die(\"core.filemode\", filemode ? \"true\" : \"false\");\n \n \tif (is_bare_repository())\n-\t\tgit_config_set(\"core.bare\", \"true\");\n+\t\tgit_config_set_or_die(\"core.bare\", \"true\");\n \telse {\n \t\tconst char *work_tree = get_git_work_tree();\n-\t\tgit_config_set(\"core.bare\", \"false\");\n+\t\tgit_config_set_or_die(\"core.bare\", \"false\");\n \t\t/* allow template config file to override the default */\n \t\tif (log_all_ref_updates == -1)\n-\t\t    git_config_set(\"core.logallrefupdates\", \"true\");\n+\t\t\tgit_config_set_or_die(\"core.logallrefupdates\", \"true\");\n \t\tif (needs_work_tree_config(get_git_dir(), work_tree))\n-\t\t\tgit_config_set(\"core.worktree\", work_tree);\n+\t\t\tgit_config_set_or_die(\"core.worktree\", work_tree);\n \t}\n \n \tif (!reinit) {\n@@ -265,12 +265,12 @@ static int create_default_files(const char *template_path)\n \t\t    S_ISLNK(st1.st_mode))\n \t\t\tunlink(path); /* good */\n \t\telse\n-\t\t\tgit_config_set(\"core.symlinks\", \"false\");\n+\t\t\tgit_config_set_or_die(\"core.symlinks\", \"false\");\n \n \t\t/* Check if the filesystem is case-insensitive */\n \t\tpath = git_path_buf(&buf, \"CoNfIg\");\n \t\tif (!access(path, F_OK))\n-\t\t\tgit_config_set(\"core.ignorecase\", \"true\");\n+\t\t\tgit_config_set_or_die(\"core.ignorecase\", \"true\");\n \t\tprobe_utf8_pathname_composition();\n \t}\n \n@@ -386,8 +386,8 @@ int init_db(const char *template_dir, unsigned int flags)\n \t\t\txsnprintf(buf, sizeof(buf), \"%d\", OLD_PERM_EVERYBODY);\n \t\telse\n \t\t\tdie(\"BUG: invalid value for shared_repository\");\n-\t\tgit_config_set(\"core.sharedrepository\", buf);\n-\t\tgit_config_set(\"receive.denyNonFastforwards\", \"true\");\n+\t\tgit_config_set_or_die(\"core.sharedrepository\", buf);\n+\t\tgit_config_set_or_die(\"receive.denyNonFastforwards\", \"true\");\n \t}\n \n \tif (!(flags & INIT_DB_QUIET)) {\n-- \n2.7.1\n"},{"id":"278307","messageId":"1455627402-752-13-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 12/15] sequencer: die on config error when saving replay opts","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:39Z","receivedAt":"2016-02-16T12:56:39Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When we start picking a range of revisions we save the replay\noptions that are required to restore state when interrupting and\nlater continuing picking the revisions. However, we do not check\nthe return values of the `git_config_set` functions, which may\nlead us to store incomplete information. As this may lead us to\nfail when trying to continue the sequence the error can be fatal.\n\nFix this by dying immediately when we are unable to write back\nany replay option.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n sequencer.c | 22 +++++++++++-----------\n 1 file changed, 11 insertions(+), 11 deletions(-)\n\ndiff --git a/sequencer.c b/sequencer.c\nindex 8048786..3590248 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -933,31 +933,31 @@ static void save_opts(struct replay_opts *opts)\n \tconst char *opts_file = git_path_opts_file();\n \n \tif (opts->no_commit)\n-\t\tgit_config_set_in_file(opts_file, \"options.no-commit\", \"true\");\n+\t\tgit_config_set_in_file_or_die(opts_file, \"options.no-commit\", \"true\");\n \tif (opts->edit)\n-\t\tgit_config_set_in_file(opts_file, \"options.edit\", \"true\");\n+\t\tgit_config_set_in_file_or_die(opts_file, \"options.edit\", \"true\");\n \tif (opts->signoff)\n-\t\tgit_config_set_in_file(opts_file, \"options.signoff\", \"true\");\n+\t\tgit_config_set_in_file_or_die(opts_file, \"options.signoff\", \"true\");\n \tif (opts->record_origin)\n-\t\tgit_config_set_in_file(opts_file, \"options.record-origin\", \"true\");\n+\t\tgit_config_set_in_file_or_die(opts_file, \"options.record-origin\", \"true\");\n \tif (opts->allow_ff)\n-\t\tgit_config_set_in_file(opts_file, \"options.allow-ff\", \"true\");\n+\t\tgit_config_set_in_file_or_die(opts_file, \"options.allow-ff\", \"true\");\n \tif (opts->mainline) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tstrbuf_addf(&buf, \"%d\", opts->mainline);\n-\t\tgit_config_set_in_file(opts_file, \"options.mainline\", buf.buf);\n+\t\tgit_config_set_in_file_or_die(opts_file, \"options.mainline\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\n \tif (opts->strategy)\n-\t\tgit_config_set_in_file(opts_file, \"options.strategy\", opts->strategy);\n+\t\tgit_config_set_in_file_or_die(opts_file, \"options.strategy\", opts->strategy);\n \tif (opts->gpg_sign)\n-\t\tgit_config_set_in_file(opts_file, \"options.gpg-sign\", opts->gpg_sign);\n+\t\tgit_config_set_in_file_or_die(opts_file, \"options.gpg-sign\", opts->gpg_sign);\n \tif (opts->xopts) {\n \t\tint i;\n \t\tfor (i = 0; i < opts->xopts_nr; i++)\n-\t\t\tgit_config_set_multivar_in_file(opts_file,\n-\t\t\t\t\t\t\t\"options.strategy-option\",\n-\t\t\t\t\t\t\topts->xopts[i], \"^$\", 0);\n+\t\t\tgit_config_set_multivar_in_file_or_die(opts_file,\n+\t\t\t\t\t\t\t       \"options.strategy-option\",\n+\t\t\t\t\t\t\t       opts->xopts[i], \"^$\", 0);\n \t}\n }\n \n-- \n2.7.1\n"},{"id":"278305","messageId":"1455627402-752-14-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 13/15] compat: die when unable to set core.precomposeunicode","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:40Z","receivedAt":"2016-02-16T12:56:40Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"When calling `git_config_set` to set 'core.precomposeunicode' we\nignore the return value of the function, which may indicate that\nwe were unable to write the value back to disk. As the function\nis only called by init-db we can and should die when an error\noccurs.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n compat/precompose_utf8.c | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c\nindex 079070f..9ff1ebe 100644\n--- a/compat/precompose_utf8.c\n+++ b/compat/precompose_utf8.c\n@@ -50,7 +50,8 @@ void probe_utf8_pathname_composition(void)\n \t\tclose(output_fd);\n \t\tgit_path_buf(&path, \"%s\", auml_nfd);\n \t\tprecomposed_unicode = access(path.buf, R_OK) ? 0 : 1;\n-\t\tgit_config_set(\"core.precomposeunicode\", precomposed_unicode ? \"true\" : \"false\");\n+\t\tgit_config_set_or_die(\"core.precomposeunicode\",\n+\t\t\t\t      precomposed_unicode ? \"true\" : \"false\");\n \t\tgit_path_buf(&path, \"%s\", auml_nfc);\n \t\tif (unlink(path.buf))\n \t\t\tdie_errno(_(\"failed to unlink '%s'\"), path.buf);\n-- \n2.7.1\n"},{"id":"278303","messageId":"1455627402-752-15-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 14/15] config: rename git_config_set to git_config_set_gently","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:41Z","receivedAt":"2016-02-16T12:56:41Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The desired default behavior for `git_config_set` is to die\nwhenever an error occurs. Dying is the default for a lot of\ninternal functions when failures occur and is in this case the\nright thing to do for most callers as otherwise we might run into\ninconsistent repositories without noticing.\n\nAs some code may rely on the actual return values for\n`git_config_set` we still require the ability to invoke these\nfunctions without aborting. Rename the existing `git_config_set`\nfunctions to `git_config_set_gently` to keep them available for\nthose callers.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n branch.c         |  6 +++---\n builtin/clone.c  |  2 +-\n builtin/config.c | 28 ++++++++++++++--------------\n builtin/remote.c |  2 +-\n cache.h          | 10 +++++-----\n config.c         | 29 +++++++++++++++--------------\n submodule.c      |  2 +-\n 7 files changed, 40 insertions(+), 39 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 3b9ccea..06942ef 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -70,18 +70,18 @@ int install_branch_config(int flag, const char *local, const char *origin, const\n \t}\n \n \tstrbuf_addf(&key, \"branch.%s.remote\", local);\n-\tif (git_config_set(key.buf, origin ? origin : \".\") < 0)\n+\tif (git_config_set_gently(key.buf, origin ? origin : \".\") < 0)\n \t\tgoto out_err;\n \n \tstrbuf_reset(&key);\n \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n-\tif (git_config_set(key.buf, remote) < 0)\n+\tif (git_config_set_gently(key.buf, remote) < 0)\n \t\tgoto out_err;\n \n \tif (rebasing) {\n \t\tstrbuf_reset(&key);\n \t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n-\t\tif (git_config_set(key.buf, \"true\") < 0)\n+\t\tif (git_config_set_gently(key.buf, \"true\") < 0)\n \t\t    goto out_err;\n \t}\n \tstrbuf_release(&key);\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 164038a..38094d4 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -735,7 +735,7 @@ static int checkout(void)\n \n static int write_one_config(const char *key, const char *value, void *data)\n {\n-\treturn git_config_set_multivar(key, value ? value : \"true\", \"^$\", 0);\n+\treturn git_config_set_multivar_gently(key, value ? value : \"true\", \"^$\", 0);\n }\n \n static void write_config(struct string_list *config)\ndiff --git a/builtin/config.c b/builtin/config.c\nindex adc7727..c26d6e7 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -582,7 +582,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\tcheck_write();\n \t\tcheck_argc(argc, 2, 2);\n \t\tvalue = normalize_value(argv[0], argv[1]);\n-\t\tret = git_config_set_in_file(given_config_source.file, argv[0], value);\n+\t\tret = git_config_set_in_file_gently(given_config_source.file, argv[0], value);\n \t\tif (ret == CONFIG_NOTHING_SET)\n \t\t\terror(\"cannot overwrite multiple values with a single value\\n\"\n \t\t\t\"       Use a regexp, --add or --replace-all to change %s.\", argv[0]);\n@@ -592,23 +592,23 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\tcheck_write();\n \t\tcheck_argc(argc, 2, 3);\n \t\tvalue = normalize_value(argv[0], argv[1]);\n-\t\treturn git_config_set_multivar_in_file(given_config_source.file,\n-\t\t\t\t\t\t       argv[0], value, argv[2], 0);\n+\t\treturn git_config_set_multivar_in_file_gently(given_config_source.file,\n+\t\t\t\t\t\t\t      argv[0], value, argv[2], 0);\n \t}\n \telse if (actions == ACTION_ADD) {\n \t\tcheck_write();\n \t\tcheck_argc(argc, 2, 2);\n \t\tvalue = normalize_value(argv[0], argv[1]);\n-\t\treturn git_config_set_multivar_in_file(given_config_source.file,\n-\t\t\t\t\t\t       argv[0], value,\n-\t\t\t\t\t\t       CONFIG_REGEX_NONE, 0);\n+\t\treturn git_config_set_multivar_in_file_gently(given_config_source.file,\n+\t\t\t\t\t\t\t      argv[0], value,\n+\t\t\t\t\t\t\t      CONFIG_REGEX_NONE, 0);\n \t}\n \telse if (actions == ACTION_REPLACE_ALL) {\n \t\tcheck_write();\n \t\tcheck_argc(argc, 2, 3);\n \t\tvalue = normalize_value(argv[0], argv[1]);\n-\t\treturn git_config_set_multivar_in_file(given_config_source.file,\n-\t\t\t\t\t\t       argv[0], value, argv[2], 1);\n+\t\treturn git_config_set_multivar_in_file_gently(given_config_source.file,\n+\t\t\t\t\t\t\t      argv[0], value, argv[2], 1);\n \t}\n \telse if (actions == ACTION_GET) {\n \t\tcheck_argc(argc, 1, 2);\n@@ -634,17 +634,17 @@ int cmd_config(int argc, const char **argv, const char *prefix)\n \t\tcheck_write();\n \t\tcheck_argc(argc, 1, 2);\n \t\tif (argc == 2)\n-\t\t\treturn git_config_set_multivar_in_file(given_config_source.file,\n-\t\t\t\t\t\t\t       argv[0], NULL, argv[1], 0);\n+\t\t\treturn git_config_set_multivar_in_file_gently(given_config_source.file,\n+\t\t\t\t\t\t\t\t      argv[0], NULL, argv[1], 0);\n \t\telse\n-\t\t\treturn git_config_set_in_file(given_config_source.file,\n-\t\t\t\t\t\t      argv[0], NULL);\n+\t\t\treturn git_config_set_in_file_gently(given_config_source.file,\n+\t\t\t\t\t\t\t     argv[0], NULL);\n \t}\n \telse if (actions == ACTION_UNSET_ALL) {\n \t\tcheck_write();\n \t\tcheck_argc(argc, 1, 2);\n-\t\treturn git_config_set_multivar_in_file(given_config_source.file,\n-\t\t\t\t\t\t       argv[0], NULL, argv[1], 1);\n+\t\treturn git_config_set_multivar_in_file_gently(given_config_source.file,\n+\t\t\t\t\t\t\t      argv[0], NULL, argv[1], 1);\n \t}\n \telse if (actions == ACTION_RENAME_SECTION) {\n \t\tint ret;\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex fe57f77..abd5f67 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -1397,7 +1397,7 @@ static int update(int argc, const char **argv)\n \n static int remove_all_fetch_refspecs(const char *remote, const char *key)\n {\n-\treturn git_config_set_multivar(key, NULL, NULL, 1);\n+\treturn git_config_set_multivar_gently(key, NULL, NULL, 1);\n }\n \n static void add_branches(struct remote *remote, const char **branches,\ndiff --git a/cache.h b/cache.h\nindex 6870a25..2d48aef 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1487,7 +1487,7 @@ extern int update_server_info(int);\n /* git_config_parse_key() returns these negated: */\n #define CONFIG_INVALID_KEY 1\n #define CONFIG_NO_SECTION_OR_NAME 2\n-/* git_config_set(), git_config_set_multivar() return the above or these: */\n+/* git_config_set_gently(), git_config_set_multivar_gently() return the above or these: */\n #define CONFIG_NO_LOCK -1\n #define CONFIG_INVALID_FILE 3\n #define CONFIG_NO_WRITE 4\n@@ -1525,15 +1525,15 @@ extern int git_config_bool(const char *, const char *);\n extern int git_config_maybe_bool(const char *, const char *);\n extern int git_config_string(const char **, const char *, const char *);\n extern int git_config_pathname(const char **, const char *, const char *);\n-extern int git_config_set_in_file(const char *, const char *, const char *);\n+extern int git_config_set_in_file_gently(const char *, const char *, const char *);\n extern void git_config_set_in_file_or_die(const char *, const char *, const char *);\n-extern int git_config_set(const char *, const char *);\n+extern int git_config_set_gently(const char *, const char *);\n extern void git_config_set_or_die(const char *, const char *);\n extern int git_config_parse_key(const char *, char **, int *);\n extern int git_config_key_is_valid(const char *key);\n-extern int git_config_set_multivar(const char *, const char *, const char *, int);\n+extern int git_config_set_multivar_gently(const char *, const char *, const char *, int);\n extern void git_config_set_multivar_or_die(const char *, const char *, const char *, int);\n-extern int git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);\n+extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int);\n extern void git_config_set_multivar_in_file_or_die(const char *, const char *, const char *, const char *, int);\n extern int git_config_rename_section(const char *, const char *);\n extern int git_config_rename_section_in_file(const char *, const char *, const char *);\ndiff --git a/config.c b/config.c\nindex 856f7d34..e7f42da 100644\n--- a/config.c\n+++ b/config.c\n@@ -1825,10 +1825,10 @@ contline:\n \treturn offset;\n }\n \n-int git_config_set_in_file(const char *config_filename,\n-\t\t\tconst char *key, const char *value)\n+int git_config_set_in_file_gently(const char *config_filename,\n+\t\t\t\t  const char *key, const char *value)\n {\n-\treturn git_config_set_multivar_in_file(config_filename, key, value, NULL, 0);\n+\treturn git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0);\n }\n \n void git_config_set_in_file_or_die(const char *config_filename,\n@@ -1837,9 +1837,9 @@ void git_config_set_in_file_or_die(const char *config_filename,\n \tgit_config_set_multivar_in_file_or_die(config_filename, key, value, NULL, 0);\n }\n \n-int git_config_set(const char *key, const char *value)\n+int git_config_set_gently(const char *key, const char *value)\n {\n-\treturn git_config_set_multivar(key, value, NULL, 0);\n+\treturn git_config_set_multivar_gently(key, value, NULL, 0);\n }\n \n void git_config_set_or_die(const char *key, const char *value)\n@@ -1961,9 +1961,10 @@ int git_config_key_is_valid(const char *key)\n  * - the config file is removed and the lock file rename()d to it.\n  *\n  */\n-int git_config_set_multivar_in_file(const char *config_filename,\n-\t\t\t\tconst char *key, const char *value,\n-\t\t\t\tconst char *value_regex, int multi_replace)\n+int git_config_set_multivar_in_file_gently(const char *config_filename,\n+\t\t\t\t\t   const char *key, const char *value,\n+\t\t\t\t\t   const char *value_regex,\n+\t\t\t\t\t   int multi_replace)\n {\n \tint fd = -1, in_fd = -1;\n \tint ret;\n@@ -2194,16 +2195,16 @@ void git_config_set_multivar_in_file_or_die(const char *config_filename,\n \t\t\t\tconst char *key, const char *value,\n \t\t\t\tconst char *value_regex, int multi_replace)\n {\n-\tif (git_config_set_multivar_in_file(config_filename, key, value,\n-\t\t\t\t\t    value_regex, multi_replace) < 0)\n+\tif (git_config_set_multivar_in_file_gently(config_filename, key, value,\n+\t\t\t\t\t\t   value_regex, multi_replace) < 0)\n \t\tdie(_(\"Could not set '%s' to '%s'\"), key, value);\n }\n \n-int git_config_set_multivar(const char *key, const char *value,\n-\t\t\tconst char *value_regex, int multi_replace)\n+int git_config_set_multivar_gently(const char *key, const char *value,\n+\t\t\t\t   const char *value_regex, int multi_replace)\n {\n-\treturn git_config_set_multivar_in_file(NULL, key, value, value_regex,\n-\t\t\t\t\t       multi_replace);\n+\treturn git_config_set_multivar_in_file_gently(NULL, key, value, value_regex,\n+\t\t\t\t\t\t      multi_replace);\n }\n \n void git_config_set_multivar_or_die(const char *key, const char *value,\ndiff --git a/submodule.c b/submodule.c\nindex 589a82c..be8b5cc 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -69,7 +69,7 @@ int update_path_in_gitmodules(const char *oldpath, const char *newpath)\n \tstrbuf_addstr(&entry, \"submodule.\");\n \tstrbuf_addstr(&entry, submodule->name);\n \tstrbuf_addstr(&entry, \".path\");\n-\tif (git_config_set_in_file(\".gitmodules\", entry.buf, newpath) < 0) {\n+\tif (git_config_set_in_file_gently(\".gitmodules\", entry.buf, newpath) < 0) {\n \t\t/* Maybe the user already did that, don't error out here */\n \t\twarning(_(\"Could not update .gitmodules entry %s\"), entry.buf);\n \t\tstrbuf_release(&entry);\n-- \n2.7.1\n"},{"id":"278302","messageId":"1455627402-752-16-git-send-email-ps@pks.im","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"[PATCH v5 15/15] config: rename git_config_set_or_die to git_config_set","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-16T12:56:42Z","receivedAt":"2016-02-16T12:56:42Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Rename git_config_set_or_die functions to git_config_set, leading\nto the new default behavior of dying whenever a configuration\nerror occurs.\n\nBy now all callers that shall die on error have been transitioned\nto the _or_die variants, thus making this patch a simple rename\nof the functions.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n builtin/branch.c            |  6 +++---\n builtin/clone.c             |  8 ++++----\n builtin/init-db.c           | 20 ++++++++++----------\n builtin/remote.c            | 32 ++++++++++++++++----------------\n builtin/submodule--helper.c |  4 ++--\n cache.h                     |  8 ++++----\n config.c                    | 24 ++++++++++++------------\n sequencer.c                 | 22 +++++++++++-----------\n submodule.c                 |  6 +++---\n 9 files changed, 65 insertions(+), 65 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex c043cfc..7b45b6b 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -594,7 +594,7 @@ static int edit_branch_description(const char *branch_name)\n \tstrbuf_stripspace(&buf, 1);\n \n \tstrbuf_addf(&name, \"branch.%s.description\", branch_name);\n-\tgit_config_set_or_die(name.buf, buf.len ? buf.buf : NULL);\n+\tgit_config_set(name.buf, buf.len ? buf.buf : NULL);\n \tstrbuf_release(&name);\n \tstrbuf_release(&buf);\n \n@@ -790,10 +790,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\t\tdie(_(\"Branch '%s' has no upstream information\"), branch->name);\n \n \t\tstrbuf_addf(&buf, \"branch.%s.remote\", branch->name);\n-\t\tgit_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n+\t\tgit_config_set_multivar(buf.buf, NULL, NULL, 1);\n \t\tstrbuf_reset(&buf);\n \t\tstrbuf_addf(&buf, \"branch.%s.merge\", branch->name);\n-\t\tgit_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n+\t\tgit_config_set_multivar(buf.buf, NULL, NULL, 1);\n \t\tstrbuf_release(&buf);\n \t} else if (argc > 0 && argc <= 2) {\n \t\tstruct branch *branch = branch_get(argv[0]);\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex 38094d4..b47c73f 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -786,12 +786,12 @@ static void write_refspec_config(const char *src_ref_prefix,\n \t\t/* Configure the remote */\n \t\tif (value.len) {\n \t\t\tstrbuf_addf(&key, \"remote.%s.fetch\", option_origin);\n-\t\t\tgit_config_set_multivar_or_die(key.buf, value.buf, \"^$\", 0);\n+\t\t\tgit_config_set_multivar(key.buf, value.buf, \"^$\", 0);\n \t\t\tstrbuf_reset(&key);\n \n \t\t\tif (option_mirror) {\n \t\t\t\tstrbuf_addf(&key, \"remote.%s.mirror\", option_origin);\n-\t\t\t\tgit_config_set_or_die(key.buf, \"true\");\n+\t\t\t\tgit_config_set(key.buf, \"true\");\n \t\t\t\tstrbuf_reset(&key);\n \t\t\t}\n \t\t}\n@@ -949,14 +949,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\t\tsrc_ref_prefix = \"refs/\";\n \t\tstrbuf_addstr(&branch_top, src_ref_prefix);\n \n-\t\tgit_config_set_or_die(\"core.bare\", \"true\");\n+\t\tgit_config_set(\"core.bare\", \"true\");\n \t} else {\n \t\tstrbuf_addf(&branch_top, \"refs/remotes/%s/\", option_origin);\n \t}\n \n \tstrbuf_addf(&value, \"+%s*:%s*\", src_ref_prefix, branch_top.buf);\n \tstrbuf_addf(&key, \"remote.%s.url\", option_origin);\n-\tgit_config_set_or_die(key.buf, repo);\n+\tgit_config_set(key.buf, repo);\n \tstrbuf_reset(&key);\n \n \tif (option_reference.nr)\ndiff --git a/builtin/init-db.c b/builtin/init-db.c\nindex ef19048..6223b7d 100644\n--- a/builtin/init-db.c\n+++ b/builtin/init-db.c\n@@ -227,7 +227,7 @@ static int create_default_files(const char *template_path)\n \t/* This forces creation of new config file */\n \txsnprintf(repo_version_string, sizeof(repo_version_string),\n \t\t  \"%d\", GIT_REPO_VERSION);\n-\tgit_config_set_or_die(\"core.repositoryformatversion\", repo_version_string);\n+\tgit_config_set(\"core.repositoryformatversion\", repo_version_string);\n \n \t/* Check filemode trustability */\n \tpath = git_path_buf(&buf, \"config\");\n@@ -241,18 +241,18 @@ static int create_default_files(const char *template_path)\n \t\tif (filemode && !reinit && (st1.st_mode & S_IXUSR))\n \t\t\tfilemode = 0;\n \t}\n-\tgit_config_set_or_die(\"core.filemode\", filemode ? \"true\" : \"false\");\n+\tgit_config_set(\"core.filemode\", filemode ? \"true\" : \"false\");\n \n \tif (is_bare_repository())\n-\t\tgit_config_set_or_die(\"core.bare\", \"true\");\n+\t\tgit_config_set(\"core.bare\", \"true\");\n \telse {\n \t\tconst char *work_tree = get_git_work_tree();\n-\t\tgit_config_set_or_die(\"core.bare\", \"false\");\n+\t\tgit_config_set(\"core.bare\", \"false\");\n \t\t/* allow template config file to override the default */\n \t\tif (log_all_ref_updates == -1)\n-\t\t\tgit_config_set_or_die(\"core.logallrefupdates\", \"true\");\n+\t\t\tgit_config_set(\"core.logallrefupdates\", \"true\");\n \t\tif (needs_work_tree_config(get_git_dir(), work_tree))\n-\t\t\tgit_config_set_or_die(\"core.worktree\", work_tree);\n+\t\t\tgit_config_set(\"core.worktree\", work_tree);\n \t}\n \n \tif (!reinit) {\n@@ -265,12 +265,12 @@ static int create_default_files(const char *template_path)\n \t\t    S_ISLNK(st1.st_mode))\n \t\t\tunlink(path); /* good */\n \t\telse\n-\t\t\tgit_config_set_or_die(\"core.symlinks\", \"false\");\n+\t\t\tgit_config_set(\"core.symlinks\", \"false\");\n \n \t\t/* Check if the filesystem is case-insensitive */\n \t\tpath = git_path_buf(&buf, \"CoNfIg\");\n \t\tif (!access(path, F_OK))\n-\t\t\tgit_config_set_or_die(\"core.ignorecase\", \"true\");\n+\t\t\tgit_config_set(\"core.ignorecase\", \"true\");\n \t\tprobe_utf8_pathname_composition();\n \t}\n \n@@ -386,8 +386,8 @@ int init_db(const char *template_dir, unsigned int flags)\n \t\t\txsnprintf(buf, sizeof(buf), \"%d\", OLD_PERM_EVERYBODY);\n \t\telse\n \t\t\tdie(\"BUG: invalid value for shared_repository\");\n-\t\tgit_config_set_or_die(\"core.sharedrepository\", buf);\n-\t\tgit_config_set_or_die(\"receive.denyNonFastforwards\", \"true\");\n+\t\tgit_config_set(\"core.sharedrepository\", buf);\n+\t\tgit_config_set(\"receive.denyNonFastforwards\", \"true\");\n \t}\n \n \tif (!(flags & INIT_DB_QUIET)) {\ndiff --git a/builtin/remote.c b/builtin/remote.c\nindex abd5f67..ecb9b26 100644\n--- a/builtin/remote.c\n+++ b/builtin/remote.c\n@@ -119,7 +119,7 @@ static void add_branch(const char *key, const char *branchname,\n \telse\n \t\tstrbuf_addf(tmp, \"refs/heads/%s:refs/remotes/%s/%s\",\n \t\t\t\tbranchname, remotename, branchname);\n-\tgit_config_set_multivar_or_die(key, tmp->buf, \"^$\", 0);\n+\tgit_config_set_multivar(key, tmp->buf, \"^$\", 0);\n }\n \n static const char mirror_advice[] =\n@@ -197,7 +197,7 @@ static int add(int argc, const char **argv)\n \t\tdie(_(\"'%s' is not a valid remote name\"), name);\n \n \tstrbuf_addf(&buf, \"remote.%s.url\", name);\n-\tgit_config_set_or_die(buf.buf, url);\n+\tgit_config_set(buf.buf, url);\n \n \tif (!mirror || mirror & MIRROR_FETCH) {\n \t\tstrbuf_reset(&buf);\n@@ -213,14 +213,14 @@ static int add(int argc, const char **argv)\n \tif (mirror & MIRROR_PUSH) {\n \t\tstrbuf_reset(&buf);\n \t\tstrbuf_addf(&buf, \"remote.%s.mirror\", name);\n-\t\tgit_config_set_or_die(buf.buf, \"true\");\n+\t\tgit_config_set(buf.buf, \"true\");\n \t}\n \n \tif (fetch_tags != TAGS_DEFAULT) {\n \t\tstrbuf_reset(&buf);\n \t\tstrbuf_addf(&buf, \"remote.%s.tagopt\", name);\n-\t\tgit_config_set_or_die(buf.buf,\n-\t\t\t\t      fetch_tags == TAGS_SET ? \"--tags\" : \"--no-tags\");\n+\t\tgit_config_set(buf.buf,\n+\t\t\t       fetch_tags == TAGS_SET ? \"--tags\" : \"--no-tags\");\n \t}\n \n \tif (fetch && fetch_remote(name))\n@@ -588,15 +588,15 @@ static int migrate_file(struct remote *remote)\n \n \tstrbuf_addf(&buf, \"remote.%s.url\", remote->name);\n \tfor (i = 0; i < remote->url_nr; i++)\n-\t\tgit_config_set_multivar_or_die(buf.buf, remote->url[i], \"^$\", 0);\n+\t\tgit_config_set_multivar(buf.buf, remote->url[i], \"^$\", 0);\n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.push\", remote->name);\n \tfor (i = 0; i < remote->push_refspec_nr; i++)\n-\t\tgit_config_set_multivar_or_die(buf.buf, remote->push_refspec[i], \"^$\", 0);\n+\t\tgit_config_set_multivar(buf.buf, remote->push_refspec[i], \"^$\", 0);\n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.fetch\", remote->name);\n \tfor (i = 0; i < remote->fetch_refspec_nr; i++)\n-\t\tgit_config_set_multivar_or_die(buf.buf, remote->fetch_refspec[i], \"^$\", 0);\n+\t\tgit_config_set_multivar(buf.buf, remote->fetch_refspec[i], \"^$\", 0);\n \tif (remote->origin == REMOTE_REMOTES)\n \t\tunlink_or_warn(git_path(\"remotes/%s\", remote->name));\n \telse if (remote->origin == REMOTE_BRANCHES)\n@@ -648,7 +648,7 @@ static int mv(int argc, const char **argv)\n \n \tstrbuf_reset(&buf);\n \tstrbuf_addf(&buf, \"remote.%s.fetch\", rename.new);\n-\tgit_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n+\tgit_config_set_multivar(buf.buf, NULL, NULL, 1);\n \tstrbuf_addf(&old_remote_context, \":refs/remotes/%s/\", rename.old);\n \tfor (i = 0; i < oldremote->fetch_refspec_nr; i++) {\n \t\tchar *ptr;\n@@ -668,7 +668,7 @@ static int mv(int argc, const char **argv)\n \t\t\t\t  \"\\tPlease update the configuration manually if necessary.\"),\n \t\t\t\tbuf2.buf);\n \n-\t\tgit_config_set_multivar_or_die(buf.buf, buf2.buf, \"^$\", 0);\n+\t\tgit_config_set_multivar(buf.buf, buf2.buf, \"^$\", 0);\n \t}\n \n \tread_branches();\n@@ -678,7 +678,7 @@ static int mv(int argc, const char **argv)\n \t\tif (info->remote_name && !strcmp(info->remote_name, rename.old)) {\n \t\t\tstrbuf_reset(&buf);\n \t\t\tstrbuf_addf(&buf, \"branch.%s.remote\", item->string);\n-\t\t\tgit_config_set_or_die(buf.buf, rename.new);\n+\t\t\tgit_config_set(buf.buf, rename.new);\n \t\t}\n \t}\n \n@@ -776,7 +776,7 @@ static int rm(int argc, const char **argv)\n \t\t\t\tstrbuf_reset(&buf);\n \t\t\t\tstrbuf_addf(&buf, \"branch.%s.%s\",\n \t\t\t\t\t\titem->string, *k);\n-\t\t\t\tgit_config_set_or_die(buf.buf, NULL);\n+\t\t\t\tgit_config_set(buf.buf, NULL);\n \t\t\t}\n \t\t}\n \t}\n@@ -1560,10 +1560,10 @@ static int set_url(int argc, const char **argv)\n \t/* Special cases that add new entry. */\n \tif ((!oldurl && !delete_mode) || add_mode) {\n \t\tif (add_mode)\n-\t\t\tgit_config_set_multivar_or_die(name_buf.buf, newurl,\n+\t\t\tgit_config_set_multivar(name_buf.buf, newurl,\n \t\t\t\t\t\t       \"^$\", 0);\n \t\telse\n-\t\t\tgit_config_set_or_die(name_buf.buf, newurl);\n+\t\t\tgit_config_set(name_buf.buf, newurl);\n \t\tstrbuf_release(&name_buf);\n \n \t\treturn 0;\n@@ -1586,9 +1586,9 @@ static int set_url(int argc, const char **argv)\n \tregfree(&old_regex);\n \n \tif (!delete_mode)\n-\t\tgit_config_set_multivar_or_die(name_buf.buf, newurl, oldurl, 0);\n+\t\tgit_config_set_multivar(name_buf.buf, newurl, oldurl, 0);\n \telse\n-\t\tgit_config_set_multivar_or_die(name_buf.buf, NULL, oldurl, 1);\n+\t\tgit_config_set_multivar(name_buf.buf, NULL, oldurl, 1);\n \treturn 0;\n }\n \ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex c7e1ea2..f4c3eff 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -245,8 +245,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n \tp = git_pathdup_submodule(path, \"config\");\n \tif (!p)\n \t\tdie(_(\"could not get submodule directory for '%s'\"), path);\n-\tgit_config_set_in_file_or_die(p, \"core.worktree\",\n-\t\t\t\t      relative_path(sb.buf, sm_gitdir, &rel_path));\n+\tgit_config_set_in_file(p, \"core.worktree\",\n+\t\t\t       relative_path(sb.buf, sm_gitdir, &rel_path));\n \tstrbuf_release(&sb);\n \tstrbuf_release(&rel_path);\n \tfree(sm_gitdir);\ndiff --git a/cache.h b/cache.h\nindex 2d48aef..63fb85e 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1526,15 +1526,15 @@ extern int git_config_maybe_bool(const char *, const char *);\n extern int git_config_string(const char **, const char *, const char *);\n extern int git_config_pathname(const char **, const char *, const char *);\n extern int git_config_set_in_file_gently(const char *, const char *, const char *);\n-extern void git_config_set_in_file_or_die(const char *, const char *, const char *);\n+extern void git_config_set_in_file(const char *, const char *, const char *);\n extern int git_config_set_gently(const char *, const char *);\n-extern void git_config_set_or_die(const char *, const char *);\n+extern void git_config_set(const char *, const char *);\n extern int git_config_parse_key(const char *, char **, int *);\n extern int git_config_key_is_valid(const char *key);\n extern int git_config_set_multivar_gently(const char *, const char *, const char *, int);\n-extern void git_config_set_multivar_or_die(const char *, const char *, const char *, int);\n+extern void git_config_set_multivar(const char *, const char *, const char *, int);\n extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int);\n-extern void git_config_set_multivar_in_file_or_die(const char *, const char *, const char *, const char *, int);\n+extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);\n extern int git_config_rename_section(const char *, const char *);\n extern int git_config_rename_section_in_file(const char *, const char *, const char *);\n extern const char *git_etc_gitconfig(void);\ndiff --git a/config.c b/config.c\nindex e7f42da..325c3ea 100644\n--- a/config.c\n+++ b/config.c\n@@ -1831,10 +1831,10 @@ int git_config_set_in_file_gently(const char *config_filename,\n \treturn git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0);\n }\n \n-void git_config_set_in_file_or_die(const char *config_filename,\n-\t\t\tconst char *key, const char *value)\n+void git_config_set_in_file(const char *config_filename,\n+\t\t\t    const char *key, const char *value)\n {\n-\tgit_config_set_multivar_in_file_or_die(config_filename, key, value, NULL, 0);\n+\tgit_config_set_multivar_in_file(config_filename, key, value, NULL, 0);\n }\n \n int git_config_set_gently(const char *key, const char *value)\n@@ -1842,9 +1842,9 @@ int git_config_set_gently(const char *key, const char *value)\n \treturn git_config_set_multivar_gently(key, value, NULL, 0);\n }\n \n-void git_config_set_or_die(const char *key, const char *value)\n+void git_config_set(const char *key, const char *value)\n {\n-\tgit_config_set_multivar_or_die(key, value, NULL, 0);\n+\tgit_config_set_multivar(key, value, NULL, 0);\n }\n \n /*\n@@ -2191,9 +2191,9 @@ write_err_out:\n \n }\n \n-void git_config_set_multivar_in_file_or_die(const char *config_filename,\n-\t\t\t\tconst char *key, const char *value,\n-\t\t\t\tconst char *value_regex, int multi_replace)\n+void git_config_set_multivar_in_file(const char *config_filename,\n+\t\t\t\t     const char *key, const char *value,\n+\t\t\t\t     const char *value_regex, int multi_replace)\n {\n \tif (git_config_set_multivar_in_file_gently(config_filename, key, value,\n \t\t\t\t\t\t   value_regex, multi_replace) < 0)\n@@ -2207,11 +2207,11 @@ int git_config_set_multivar_gently(const char *key, const char *value,\n \t\t\t\t\t\t      multi_replace);\n }\n \n-void git_config_set_multivar_or_die(const char *key, const char *value,\n-\t\t\tconst char *value_regex, int multi_replace)\n+void git_config_set_multivar(const char *key, const char *value,\n+\t\t\t     const char *value_regex, int multi_replace)\n {\n-\tgit_config_set_multivar_in_file_or_die(NULL, key, value, value_regex,\n-\t\t\t\t\t       multi_replace);\n+\tgit_config_set_multivar_in_file(NULL, key, value, value_regex,\n+\t\t\t\t\tmulti_replace);\n }\n \n static int section_name_match (const char *buf, const char *name)\ndiff --git a/sequencer.c b/sequencer.c\nindex 3590248..8048786 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -933,31 +933,31 @@ static void save_opts(struct replay_opts *opts)\n \tconst char *opts_file = git_path_opts_file();\n \n \tif (opts->no_commit)\n-\t\tgit_config_set_in_file_or_die(opts_file, \"options.no-commit\", \"true\");\n+\t\tgit_config_set_in_file(opts_file, \"options.no-commit\", \"true\");\n \tif (opts->edit)\n-\t\tgit_config_set_in_file_or_die(opts_file, \"options.edit\", \"true\");\n+\t\tgit_config_set_in_file(opts_file, \"options.edit\", \"true\");\n \tif (opts->signoff)\n-\t\tgit_config_set_in_file_or_die(opts_file, \"options.signoff\", \"true\");\n+\t\tgit_config_set_in_file(opts_file, \"options.signoff\", \"true\");\n \tif (opts->record_origin)\n-\t\tgit_config_set_in_file_or_die(opts_file, \"options.record-origin\", \"true\");\n+\t\tgit_config_set_in_file(opts_file, \"options.record-origin\", \"true\");\n \tif (opts->allow_ff)\n-\t\tgit_config_set_in_file_or_die(opts_file, \"options.allow-ff\", \"true\");\n+\t\tgit_config_set_in_file(opts_file, \"options.allow-ff\", \"true\");\n \tif (opts->mainline) {\n \t\tstruct strbuf buf = STRBUF_INIT;\n \t\tstrbuf_addf(&buf, \"%d\", opts->mainline);\n-\t\tgit_config_set_in_file_or_die(opts_file, \"options.mainline\", buf.buf);\n+\t\tgit_config_set_in_file(opts_file, \"options.mainline\", buf.buf);\n \t\tstrbuf_release(&buf);\n \t}\n \tif (opts->strategy)\n-\t\tgit_config_set_in_file_or_die(opts_file, \"options.strategy\", opts->strategy);\n+\t\tgit_config_set_in_file(opts_file, \"options.strategy\", opts->strategy);\n \tif (opts->gpg_sign)\n-\t\tgit_config_set_in_file_or_die(opts_file, \"options.gpg-sign\", opts->gpg_sign);\n+\t\tgit_config_set_in_file(opts_file, \"options.gpg-sign\", opts->gpg_sign);\n \tif (opts->xopts) {\n \t\tint i;\n \t\tfor (i = 0; i < opts->xopts_nr; i++)\n-\t\t\tgit_config_set_multivar_in_file_or_die(opts_file,\n-\t\t\t\t\t\t\t       \"options.strategy-option\",\n-\t\t\t\t\t\t\t       opts->xopts[i], \"^$\", 0);\n+\t\t\tgit_config_set_multivar_in_file(opts_file,\n+\t\t\t\t\t\t\t\"options.strategy-option\",\n+\t\t\t\t\t\t\topts->xopts[i], \"^$\", 0);\n \t}\n }\n \ndiff --git a/submodule.c b/submodule.c\nindex be8b5cc..b3fc6ac 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -1087,9 +1087,9 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)\n \t/* Update core.worktree setting */\n \tstrbuf_reset(&file_name);\n \tstrbuf_addf(&file_name, \"%s/config\", git_dir);\n-\tgit_config_set_in_file_or_die(file_name.buf, \"core.worktree\",\n-\t\t\t\t      relative_path(real_work_tree, git_dir,\n-\t\t\t\t\t\t    &rel_path));\n+\tgit_config_set_in_file(file_name.buf, \"core.worktree\",\n+\t\t\t       relative_path(real_work_tree, git_dir,\n+\t\t\t\t\t     &rel_path));\n \n \tstrbuf_release(&file_name);\n \tstrbuf_release(&rel_path);\n-- \n2.7.1\n"},{"id":"278364","messageId":"CAPig+cQav4AS6-RwUKGA2fmWxRL-2e2o72oYkk83emqz3z6q3w@mail.gmail.com","threadId":"41423","inReplyTo":"1455627402-752-1-git-send-email-ps@pks.im","subject":"Re: [PATCH v5 00/15] config: make git_config_set die on failure","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-02-16T17:15:35Z","receivedAt":"2016-02-16T17:15:35Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Feb 16, 2016 at 7:56 AM, Patrick Steinhardt <ps@pks.im> wrote:\n> [...]\n> Junio pointed out that it might not always be the most sensible\n> thing to die when install_branch_config fails. After thinking\n> about it I changed the behavior of the function to print an error\n> and advise message and return an error code. The error code is\n> then only used by the `git branch --set-upstream-to=` command to\n> abort early, as its main intent will usually be to set the\n> tracking information. The other callers (related to git-clone and\n> git-push) simply ignore the returned value while the messages are\n> still printed.\n>\n> I think it does make sense to not abort clones and pushes when\n> the function fails. Setting the upstream information is only a\n> small part of these commands and especially when cloning a large\n> repository it is harmful to die as this would delete everything\n> that has just been cloned. The user can still fix up the remote\n> tracking branch afterwards.\n>\n> Interdiff between v4 and v5:\n>\n> diff --git a/branch.c b/branch.c\n> @@ -49,7 +49,13 @@ static int should_setup_rebase(const char *origin)\n> +static const char tracking_advice[] =\n> +N_(\"\\n\"\n> +\"After fixing the error cause you may try to fix up\\n\"\n> +\"the remote tracking information by invoking\\n\"\n> +\"\\\"git branch --set-upstream-to=\\\".\");\n\nDo you have enough information at the point this message is emitted to\nmake it even more useful for the user by showing the actual argument\nto --set-upstream-to= that the user would need to invoke once the\nissue is resolved?\n"},{"id":"278408","messageId":"xmqq1t8cmeyc.fsf@gitster.mtv.corp.google.com","threadId":"41423","inReplyTo":"1455627402-752-3-git-send-email-ps@pks.im","subject":"Re: [PATCH v5 02/15] branch: report errors in tracking branch setup","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-16T23:07:55Z","receivedAt":"2016-02-16T23:07:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n>  \tif (rebasing) {\n>  \t\tstrbuf_reset(&key);\n>  \t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n> -\t\tgit_config_set(key.buf, \"true\");\n> +\t\tif (git_config_set(key.buf, \"true\") < 0)\n> +\t\t    goto out_err;\n\nThe indentation here is suspect.\n"},{"id":"278445","messageId":"435511DD-0B0F-437F-974C-65C7265188A8@gmail.com","threadId":"41423","inReplyTo":"1455627402-752-14-git-send-email-ps@pks.im","subject":"Re: [PATCH v5 13/15] compat: die when unable to set core.precomposeunicode","fromName":"Lars Schneider","fromEmail":"larsxschneider@gmail.com","sentAt":"2016-02-17T09:14:57Z","receivedAt":"2016-02-17T09:14:57Z","isPatch":true,"sender":{"key":"larsxschneider@gmail.com","avatar":"https://avatars.githubusercontent.com/u/477434?v=4"},"body":"\nOn 16 Feb 2016, at 13:56, Patrick Steinhardt <ps@pks.im> wrote:\n\n> When calling `git_config_set` to set 'core.precomposeunicode' we\n> ignore the return value of the function, which may indicate that\n> we were unable to write the value back to disk. As the function\n> is only called by init-db we can and should die when an error\n> occurs.\n> \n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n> compat/precompose_utf8.c | 3 ++-\n> 1 file changed, 2 insertions(+), 1 deletion(-)\n> \n> diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c\n> index 079070f..9ff1ebe 100644\n> --- a/compat/precompose_utf8.c\n> +++ b/compat/precompose_utf8.c\n> @@ -50,7 +50,8 @@ void probe_utf8_pathname_composition(void)\n> \t\tclose(output_fd);\n> \t\tgit_path_buf(&path, \"%s\", auml_nfd);\n> \t\tprecomposed_unicode = access(path.buf, R_OK) ? 0 : 1;\n> -\t\tgit_config_set(\"core.precomposeunicode\", precomposed_unicode ? \"true\" : \"false\");\n> +\t\tgit_config_set_or_die(\"core.precomposeunicode\",\n> +\t\t\t\t      precomposed_unicode ? \"true\" : \"false\");\n\nI haven't been actively following this topic, so I don't know much about\nit. However, I just noticed that the topic might brake the OS X build?\n\nhttps://travis-ci.org/git/git/jobs/109752716 \n\nCheers,\nLars\n\n> \t\tgit_path_buf(&path, \"%s\", auml_nfc);\n> \t\tif (unlink(path.buf))\n> \t\t\tdie_errno(_(\"failed to unlink '%s'\"), path.buf);\n> -- \n> 2.7.1\n> \n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n"},{"id":"278446","messageId":"20160217103419.GA743@pks-xps.fritz.box","threadId":"41423","inReplyTo":"435511DD-0B0F-437F-974C-65C7265188A8@gmail.com","subject":"Re: [PATCH v5 13/15] compat: die when unable to set core.precomposeunicode","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-17T10:34:19Z","receivedAt":"2016-02-17T10:34:19Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Feb 17, 2016 at 10:14:57AM +0100, Lars Schneider wrote:\n> \n> On 16 Feb 2016, at 13:56, Patrick Steinhardt <ps@pks.im> wrote:\n> \n> > When calling `git_config_set` to set 'core.precomposeunicode' we\n> > ignore the return value of the function, which may indicate that\n> > we were unable to write the value back to disk. As the function\n> > is only called by init-db we can and should die when an error\n> > occurs.\n> > \n> > Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> > ---\n> > compat/precompose_utf8.c | 3 ++-\n> > 1 file changed, 2 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c\n> > index 079070f..9ff1ebe 100644\n> > --- a/compat/precompose_utf8.c\n> > +++ b/compat/precompose_utf8.c\n> > @@ -50,7 +50,8 @@ void probe_utf8_pathname_composition(void)\n> > \t\tclose(output_fd);\n> > \t\tgit_path_buf(&path, \"%s\", auml_nfd);\n> > \t\tprecomposed_unicode = access(path.buf, R_OK) ? 0 : 1;\n> > -\t\tgit_config_set(\"core.precomposeunicode\", precomposed_unicode ? \"true\" : \"false\");\n> > +\t\tgit_config_set_or_die(\"core.precomposeunicode\",\n> > +\t\t\t\t      precomposed_unicode ? \"true\" : \"false\");\n> \n> I haven't been actively following this topic, so I don't know much about\n> it. However, I just noticed that the topic might brake the OS X build?\n> \n> https://travis-ci.org/git/git/jobs/109752716 \n\nThanks for the notice. Seems I've forgotten to switch that back\nto `git_config_set`. Didn't notice the breakage as the file\nis not required on my system.\n\nPatrick\n"},{"id":"278448","messageId":"20160217103435.GB743@pks-xps.fritz.box","threadId":"41423","inReplyTo":"xmqq1t8cmeyc.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v5 02/15] branch: report errors in tracking branch setup","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-17T10:34:35Z","receivedAt":"2016-02-17T10:34:35Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Feb 16, 2016 at 03:07:55PM -0800, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> >  \tif (rebasing) {\n> >  \t\tstrbuf_reset(&key);\n> >  \t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n> > -\t\tgit_config_set(key.buf, \"true\");\n> > +\t\tif (git_config_set(key.buf, \"true\") < 0)\n> > +\t\t    goto out_err;\n> \n> The indentation here is suspect.\n\nThanks, will fix.\n"},{"id":"278449","messageId":"20160217103548.GC743@pks-xps.fritz.box","threadId":"41423","inReplyTo":"CAPig+cQav4AS6-RwUKGA2fmWxRL-2e2o72oYkk83emqz3z6q3w@mail.gmail.com","subject":"Re: [PATCH v5 00/15] config: make git_config_set die on failure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-17T10:35:48Z","receivedAt":"2016-02-17T10:35:48Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Feb 16, 2016 at 12:15:35PM -0500, Eric Sunshine wrote:\n> On Tue, Feb 16, 2016 at 7:56 AM, Patrick Steinhardt <ps@pks.im> wrote:\n> > [...]\n> > Junio pointed out that it might not always be the most sensible\n> > thing to die when install_branch_config fails. After thinking\n> > about it I changed the behavior of the function to print an error\n> > and advise message and return an error code. The error code is\n> > then only used by the `git branch --set-upstream-to=` command to\n> > abort early, as its main intent will usually be to set the\n> > tracking information. The other callers (related to git-clone and\n> > git-push) simply ignore the returned value while the messages are\n> > still printed.\n> >\n> > I think it does make sense to not abort clones and pushes when\n> > the function fails. Setting the upstream information is only a\n> > small part of these commands and especially when cloning a large\n> > repository it is harmful to die as this would delete everything\n> > that has just been cloned. The user can still fix up the remote\n> > tracking branch afterwards.\n> >\n> > Interdiff between v4 and v5:\n> >\n> > diff --git a/branch.c b/branch.c\n> > @@ -49,7 +49,13 @@ static int should_setup_rebase(const char *origin)\n> > +static const char tracking_advice[] =\n> > +N_(\"\\n\"\n> > +\"After fixing the error cause you may try to fix up\\n\"\n> > +\"the remote tracking information by invoking\\n\"\n> > +\"\\\"git branch --set-upstream-to=\\\".\");\n> \n> Do you have enough information at the point this message is emitted to\n> make it even more useful for the user by showing the actual argument\n> to --set-upstream-to= that the user would need to invoke once the\n> issue is resolved?\n\nActually, yes. The message is invoked by `install_branch_config`\nwhich naturally has to know what upstream we want to set to. Will\nimprove the message in the next revision, thanks.\n\nPatrick\n"},{"id":"278505","messageId":"CAO2U3Qia8r=jp9CmF0rN3ZxeJk+811q5VZ65pygr9aqrgLUn3A@mail.gmail.com","threadId":"41423","inReplyTo":"1455627402-752-16-git-send-email-ps@pks.im","subject":"Re: [PATCH v5 15/15] config: rename git_config_set_or_die to git_config_set","fromName":"Michael Blume","fromEmail":"blume.mike@gmail.com","sentAt":"2016-02-17T20:57:17Z","receivedAt":"2016-02-17T20:57:17Z","isPatch":true,"sender":{"key":"blume.mike@gmail.com","avatar":"https://gravatar.com/avatar/1a7b440e1d942425ff4098ac7fc15b86b30cecaa56e1692a7ef8b5939ba25ea7?d=mp&s=160"},"body":"On Tue, Feb 16, 2016 at 4:56 AM, Patrick Steinhardt <ps@pks.im> wrote:\n> Rename git_config_set_or_die functions to git_config_set, leading\n> to the new default behavior of dying whenever a configuration\n> error occurs.\n>\n> By now all callers that shall die on error have been transitioned\n> to the _or_die variants, thus making this patch a simple rename\n> of the functions.\n>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  builtin/branch.c            |  6 +++---\n>  builtin/clone.c             |  8 ++++----\n>  builtin/init-db.c           | 20 ++++++++++----------\n>  builtin/remote.c            | 32 ++++++++++++++++----------------\n>  builtin/submodule--helper.c |  4 ++--\n>  cache.h                     |  8 ++++----\n>  config.c                    | 24 ++++++++++++------------\n>  sequencer.c                 | 22 +++++++++++-----------\n>  submodule.c                 |  6 +++---\n>  9 files changed, 65 insertions(+), 65 deletions(-)\n>\n> diff --git a/builtin/branch.c b/builtin/branch.c\n> index c043cfc..7b45b6b 100644\n> --- a/builtin/branch.c\n> +++ b/builtin/branch.c\n> @@ -594,7 +594,7 @@ static int edit_branch_description(const char *branch_name)\n>         strbuf_stripspace(&buf, 1);\n>\n>         strbuf_addf(&name, \"branch.%s.description\", branch_name);\n> -       git_config_set_or_die(name.buf, buf.len ? buf.buf : NULL);\n> +       git_config_set(name.buf, buf.len ? buf.buf : NULL);\n>         strbuf_release(&name);\n>         strbuf_release(&buf);\n>\n> @@ -790,10 +790,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n>                         die(_(\"Branch '%s' has no upstream information\"), branch->name);\n>\n>                 strbuf_addf(&buf, \"branch.%s.remote\", branch->name);\n> -               git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n> +               git_config_set_multivar(buf.buf, NULL, NULL, 1);\n>                 strbuf_reset(&buf);\n>                 strbuf_addf(&buf, \"branch.%s.merge\", branch->name);\n> -               git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n> +               git_config_set_multivar(buf.buf, NULL, NULL, 1);\n>                 strbuf_release(&buf);\n>         } else if (argc > 0 && argc <= 2) {\n>                 struct branch *branch = branch_get(argv[0]);\n> diff --git a/builtin/clone.c b/builtin/clone.c\n> index 38094d4..b47c73f 100644\n> --- a/builtin/clone.c\n> +++ b/builtin/clone.c\n> @@ -786,12 +786,12 @@ static void write_refspec_config(const char *src_ref_prefix,\n>                 /* Configure the remote */\n>                 if (value.len) {\n>                         strbuf_addf(&key, \"remote.%s.fetch\", option_origin);\n> -                       git_config_set_multivar_or_die(key.buf, value.buf, \"^$\", 0);\n> +                       git_config_set_multivar(key.buf, value.buf, \"^$\", 0);\n>                         strbuf_reset(&key);\n>\n>                         if (option_mirror) {\n>                                 strbuf_addf(&key, \"remote.%s.mirror\", option_origin);\n> -                               git_config_set_or_die(key.buf, \"true\");\n> +                               git_config_set(key.buf, \"true\");\n>                                 strbuf_reset(&key);\n>                         }\n>                 }\n> @@ -949,14 +949,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n>                         src_ref_prefix = \"refs/\";\n>                 strbuf_addstr(&branch_top, src_ref_prefix);\n>\n> -               git_config_set_or_die(\"core.bare\", \"true\");\n> +               git_config_set(\"core.bare\", \"true\");\n>         } else {\n>                 strbuf_addf(&branch_top, \"refs/remotes/%s/\", option_origin);\n>         }\n>\n>         strbuf_addf(&value, \"+%s*:%s*\", src_ref_prefix, branch_top.buf);\n>         strbuf_addf(&key, \"remote.%s.url\", option_origin);\n> -       git_config_set_or_die(key.buf, repo);\n> +       git_config_set(key.buf, repo);\n>         strbuf_reset(&key);\n>\n>         if (option_reference.nr)\n> diff --git a/builtin/init-db.c b/builtin/init-db.c\n> index ef19048..6223b7d 100644\n> --- a/builtin/init-db.c\n> +++ b/builtin/init-db.c\n> @@ -227,7 +227,7 @@ static int create_default_files(const char *template_path)\n>         /* This forces creation of new config file */\n>         xsnprintf(repo_version_string, sizeof(repo_version_string),\n>                   \"%d\", GIT_REPO_VERSION);\n> -       git_config_set_or_die(\"core.repositoryformatversion\", repo_version_string);\n> +       git_config_set(\"core.repositoryformatversion\", repo_version_string);\n>\n>         /* Check filemode trustability */\n>         path = git_path_buf(&buf, \"config\");\n> @@ -241,18 +241,18 @@ static int create_default_files(const char *template_path)\n>                 if (filemode && !reinit && (st1.st_mode & S_IXUSR))\n>                         filemode = 0;\n>         }\n> -       git_config_set_or_die(\"core.filemode\", filemode ? \"true\" : \"false\");\n> +       git_config_set(\"core.filemode\", filemode ? \"true\" : \"false\");\n>\n>         if (is_bare_repository())\n> -               git_config_set_or_die(\"core.bare\", \"true\");\n> +               git_config_set(\"core.bare\", \"true\");\n>         else {\n>                 const char *work_tree = get_git_work_tree();\n> -               git_config_set_or_die(\"core.bare\", \"false\");\n> +               git_config_set(\"core.bare\", \"false\");\n>                 /* allow template config file to override the default */\n>                 if (log_all_ref_updates == -1)\n> -                       git_config_set_or_die(\"core.logallrefupdates\", \"true\");\n> +                       git_config_set(\"core.logallrefupdates\", \"true\");\n>                 if (needs_work_tree_config(get_git_dir(), work_tree))\n> -                       git_config_set_or_die(\"core.worktree\", work_tree);\n> +                       git_config_set(\"core.worktree\", work_tree);\n>         }\n>\n>         if (!reinit) {\n> @@ -265,12 +265,12 @@ static int create_default_files(const char *template_path)\n>                     S_ISLNK(st1.st_mode))\n>                         unlink(path); /* good */\n>                 else\n> -                       git_config_set_or_die(\"core.symlinks\", \"false\");\n> +                       git_config_set(\"core.symlinks\", \"false\");\n>\n>                 /* Check if the filesystem is case-insensitive */\n>                 path = git_path_buf(&buf, \"CoNfIg\");\n>                 if (!access(path, F_OK))\n> -                       git_config_set_or_die(\"core.ignorecase\", \"true\");\n> +                       git_config_set(\"core.ignorecase\", \"true\");\n>                 probe_utf8_pathname_composition();\n>         }\n>\n> @@ -386,8 +386,8 @@ int init_db(const char *template_dir, unsigned int flags)\n>                         xsnprintf(buf, sizeof(buf), \"%d\", OLD_PERM_EVERYBODY);\n>                 else\n>                         die(\"BUG: invalid value for shared_repository\");\n> -               git_config_set_or_die(\"core.sharedrepository\", buf);\n> -               git_config_set_or_die(\"receive.denyNonFastforwards\", \"true\");\n> +               git_config_set(\"core.sharedrepository\", buf);\n> +               git_config_set(\"receive.denyNonFastforwards\", \"true\");\n>         }\n>\n>         if (!(flags & INIT_DB_QUIET)) {\n> diff --git a/builtin/remote.c b/builtin/remote.c\n> index abd5f67..ecb9b26 100644\n> --- a/builtin/remote.c\n> +++ b/builtin/remote.c\n> @@ -119,7 +119,7 @@ static void add_branch(const char *key, const char *branchname,\n>         else\n>                 strbuf_addf(tmp, \"refs/heads/%s:refs/remotes/%s/%s\",\n>                                 branchname, remotename, branchname);\n> -       git_config_set_multivar_or_die(key, tmp->buf, \"^$\", 0);\n> +       git_config_set_multivar(key, tmp->buf, \"^$\", 0);\n>  }\n>\n>  static const char mirror_advice[] =\n> @@ -197,7 +197,7 @@ static int add(int argc, const char **argv)\n>                 die(_(\"'%s' is not a valid remote name\"), name);\n>\n>         strbuf_addf(&buf, \"remote.%s.url\", name);\n> -       git_config_set_or_die(buf.buf, url);\n> +       git_config_set(buf.buf, url);\n>\n>         if (!mirror || mirror & MIRROR_FETCH) {\n>                 strbuf_reset(&buf);\n> @@ -213,14 +213,14 @@ static int add(int argc, const char **argv)\n>         if (mirror & MIRROR_PUSH) {\n>                 strbuf_reset(&buf);\n>                 strbuf_addf(&buf, \"remote.%s.mirror\", name);\n> -               git_config_set_or_die(buf.buf, \"true\");\n> +               git_config_set(buf.buf, \"true\");\n>         }\n>\n>         if (fetch_tags != TAGS_DEFAULT) {\n>                 strbuf_reset(&buf);\n>                 strbuf_addf(&buf, \"remote.%s.tagopt\", name);\n> -               git_config_set_or_die(buf.buf,\n> -                                     fetch_tags == TAGS_SET ? \"--tags\" : \"--no-tags\");\n> +               git_config_set(buf.buf,\n> +                              fetch_tags == TAGS_SET ? \"--tags\" : \"--no-tags\");\n>         }\n>\n>         if (fetch && fetch_remote(name))\n> @@ -588,15 +588,15 @@ static int migrate_file(struct remote *remote)\n>\n>         strbuf_addf(&buf, \"remote.%s.url\", remote->name);\n>         for (i = 0; i < remote->url_nr; i++)\n> -               git_config_set_multivar_or_die(buf.buf, remote->url[i], \"^$\", 0);\n> +               git_config_set_multivar(buf.buf, remote->url[i], \"^$\", 0);\n>         strbuf_reset(&buf);\n>         strbuf_addf(&buf, \"remote.%s.push\", remote->name);\n>         for (i = 0; i < remote->push_refspec_nr; i++)\n> -               git_config_set_multivar_or_die(buf.buf, remote->push_refspec[i], \"^$\", 0);\n> +               git_config_set_multivar(buf.buf, remote->push_refspec[i], \"^$\", 0);\n>         strbuf_reset(&buf);\n>         strbuf_addf(&buf, \"remote.%s.fetch\", remote->name);\n>         for (i = 0; i < remote->fetch_refspec_nr; i++)\n> -               git_config_set_multivar_or_die(buf.buf, remote->fetch_refspec[i], \"^$\", 0);\n> +               git_config_set_multivar(buf.buf, remote->fetch_refspec[i], \"^$\", 0);\n>         if (remote->origin == REMOTE_REMOTES)\n>                 unlink_or_warn(git_path(\"remotes/%s\", remote->name));\n>         else if (remote->origin == REMOTE_BRANCHES)\n> @@ -648,7 +648,7 @@ static int mv(int argc, const char **argv)\n>\n>         strbuf_reset(&buf);\n>         strbuf_addf(&buf, \"remote.%s.fetch\", rename.new);\n> -       git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n> +       git_config_set_multivar(buf.buf, NULL, NULL, 1);\n>         strbuf_addf(&old_remote_context, \":refs/remotes/%s/\", rename.old);\n>         for (i = 0; i < oldremote->fetch_refspec_nr; i++) {\n>                 char *ptr;\n> @@ -668,7 +668,7 @@ static int mv(int argc, const char **argv)\n>                                   \"\\tPlease update the configuration manually if necessary.\"),\n>                                 buf2.buf);\n>\n> -               git_config_set_multivar_or_die(buf.buf, buf2.buf, \"^$\", 0);\n> +               git_config_set_multivar(buf.buf, buf2.buf, \"^$\", 0);\n>         }\n>\n>         read_branches();\n> @@ -678,7 +678,7 @@ static int mv(int argc, const char **argv)\n>                 if (info->remote_name && !strcmp(info->remote_name, rename.old)) {\n>                         strbuf_reset(&buf);\n>                         strbuf_addf(&buf, \"branch.%s.remote\", item->string);\n> -                       git_config_set_or_die(buf.buf, rename.new);\n> +                       git_config_set(buf.buf, rename.new);\n>                 }\n>         }\n>\n> @@ -776,7 +776,7 @@ static int rm(int argc, const char **argv)\n>                                 strbuf_reset(&buf);\n>                                 strbuf_addf(&buf, \"branch.%s.%s\",\n>                                                 item->string, *k);\n> -                               git_config_set_or_die(buf.buf, NULL);\n> +                               git_config_set(buf.buf, NULL);\n>                         }\n>                 }\n>         }\n> @@ -1560,10 +1560,10 @@ static int set_url(int argc, const char **argv)\n>         /* Special cases that add new entry. */\n>         if ((!oldurl && !delete_mode) || add_mode) {\n>                 if (add_mode)\n> -                       git_config_set_multivar_or_die(name_buf.buf, newurl,\n> +                       git_config_set_multivar(name_buf.buf, newurl,\n>                                                        \"^$\", 0);\n>                 else\n> -                       git_config_set_or_die(name_buf.buf, newurl);\n> +                       git_config_set(name_buf.buf, newurl);\n>                 strbuf_release(&name_buf);\n>\n>                 return 0;\n> @@ -1586,9 +1586,9 @@ static int set_url(int argc, const char **argv)\n>         regfree(&old_regex);\n>\n>         if (!delete_mode)\n> -               git_config_set_multivar_or_die(name_buf.buf, newurl, oldurl, 0);\n> +               git_config_set_multivar(name_buf.buf, newurl, oldurl, 0);\n>         else\n> -               git_config_set_multivar_or_die(name_buf.buf, NULL, oldurl, 1);\n> +               git_config_set_multivar(name_buf.buf, NULL, oldurl, 1);\n>         return 0;\n>  }\n>\n> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n> index c7e1ea2..f4c3eff 100644\n> --- a/builtin/submodule--helper.c\n> +++ b/builtin/submodule--helper.c\n> @@ -245,8 +245,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>         p = git_pathdup_submodule(path, \"config\");\n>         if (!p)\n>                 die(_(\"could not get submodule directory for '%s'\"), path);\n> -       git_config_set_in_file_or_die(p, \"core.worktree\",\n> -                                     relative_path(sb.buf, sm_gitdir, &rel_path));\n> +       git_config_set_in_file(p, \"core.worktree\",\n> +                              relative_path(sb.buf, sm_gitdir, &rel_path));\n>         strbuf_release(&sb);\n>         strbuf_release(&rel_path);\n>         free(sm_gitdir);\n> diff --git a/cache.h b/cache.h\n> index 2d48aef..63fb85e 100644\n> --- a/cache.h\n> +++ b/cache.h\n> @@ -1526,15 +1526,15 @@ extern int git_config_maybe_bool(const char *, const char *);\n>  extern int git_config_string(const char **, const char *, const char *);\n>  extern int git_config_pathname(const char **, const char *, const char *);\n>  extern int git_config_set_in_file_gently(const char *, const char *, const char *);\n> -extern void git_config_set_in_file_or_die(const char *, const char *, const char *);\n> +extern void git_config_set_in_file(const char *, const char *, const char *);\n>  extern int git_config_set_gently(const char *, const char *);\n> -extern void git_config_set_or_die(const char *, const char *);\n> +extern void git_config_set(const char *, const char *);\n>  extern int git_config_parse_key(const char *, char **, int *);\n>  extern int git_config_key_is_valid(const char *key);\n>  extern int git_config_set_multivar_gently(const char *, const char *, const char *, int);\n> -extern void git_config_set_multivar_or_die(const char *, const char *, const char *, int);\n> +extern void git_config_set_multivar(const char *, const char *, const char *, int);\n>  extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int);\n> -extern void git_config_set_multivar_in_file_or_die(const char *, const char *, const char *, const char *, int);\n> +extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);\n>  extern int git_config_rename_section(const char *, const char *);\n>  extern int git_config_rename_section_in_file(const char *, const char *, const char *);\n>  extern const char *git_etc_gitconfig(void);\n> diff --git a/config.c b/config.c\n> index e7f42da..325c3ea 100644\n> --- a/config.c\n> +++ b/config.c\n> @@ -1831,10 +1831,10 @@ int git_config_set_in_file_gently(const char *config_filename,\n>         return git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0);\n>  }\n>\n> -void git_config_set_in_file_or_die(const char *config_filename,\n> -                       const char *key, const char *value)\n> +void git_config_set_in_file(const char *config_filename,\n> +                           const char *key, const char *value)\n>  {\n> -       git_config_set_multivar_in_file_or_die(config_filename, key, value, NULL, 0);\n> +       git_config_set_multivar_in_file(config_filename, key, value, NULL, 0);\n>  }\n>\n>  int git_config_set_gently(const char *key, const char *value)\n> @@ -1842,9 +1842,9 @@ int git_config_set_gently(const char *key, const char *value)\n>         return git_config_set_multivar_gently(key, value, NULL, 0);\n>  }\n>\n> -void git_config_set_or_die(const char *key, const char *value)\n> +void git_config_set(const char *key, const char *value)\n>  {\n> -       git_config_set_multivar_or_die(key, value, NULL, 0);\n> +       git_config_set_multivar(key, value, NULL, 0);\n>  }\n>\n>  /*\n> @@ -2191,9 +2191,9 @@ write_err_out:\n>\n>  }\n>\n> -void git_config_set_multivar_in_file_or_die(const char *config_filename,\n> -                               const char *key, const char *value,\n> -                               const char *value_regex, int multi_replace)\n> +void git_config_set_multivar_in_file(const char *config_filename,\n> +                                    const char *key, const char *value,\n> +                                    const char *value_regex, int multi_replace)\n>  {\n>         if (git_config_set_multivar_in_file_gently(config_filename, key, value,\n>                                                    value_regex, multi_replace) < 0)\n> @@ -2207,11 +2207,11 @@ int git_config_set_multivar_gently(const char *key, const char *value,\n>                                                       multi_replace);\n>  }\n>\n> -void git_config_set_multivar_or_die(const char *key, const char *value,\n> -                       const char *value_regex, int multi_replace)\n> +void git_config_set_multivar(const char *key, const char *value,\n> +                            const char *value_regex, int multi_replace)\n>  {\n> -       git_config_set_multivar_in_file_or_die(NULL, key, value, value_regex,\n> -                                              multi_replace);\n> +       git_config_set_multivar_in_file(NULL, key, value, value_regex,\n> +                                       multi_replace);\n>  }\n>\n>  static int section_name_match (const char *buf, const char *name)\n> diff --git a/sequencer.c b/sequencer.c\n> index 3590248..8048786 100644\n> --- a/sequencer.c\n> +++ b/sequencer.c\n> @@ -933,31 +933,31 @@ static void save_opts(struct replay_opts *opts)\n>         const char *opts_file = git_path_opts_file();\n>\n>         if (opts->no_commit)\n> -               git_config_set_in_file_or_die(opts_file, \"options.no-commit\", \"true\");\n> +               git_config_set_in_file(opts_file, \"options.no-commit\", \"true\");\n>         if (opts->edit)\n> -               git_config_set_in_file_or_die(opts_file, \"options.edit\", \"true\");\n> +               git_config_set_in_file(opts_file, \"options.edit\", \"true\");\n>         if (opts->signoff)\n> -               git_config_set_in_file_or_die(opts_file, \"options.signoff\", \"true\");\n> +               git_config_set_in_file(opts_file, \"options.signoff\", \"true\");\n>         if (opts->record_origin)\n> -               git_config_set_in_file_or_die(opts_file, \"options.record-origin\", \"true\");\n> +               git_config_set_in_file(opts_file, \"options.record-origin\", \"true\");\n>         if (opts->allow_ff)\n> -               git_config_set_in_file_or_die(opts_file, \"options.allow-ff\", \"true\");\n> +               git_config_set_in_file(opts_file, \"options.allow-ff\", \"true\");\n>         if (opts->mainline) {\n>                 struct strbuf buf = STRBUF_INIT;\n>                 strbuf_addf(&buf, \"%d\", opts->mainline);\n> -               git_config_set_in_file_or_die(opts_file, \"options.mainline\", buf.buf);\n> +               git_config_set_in_file(opts_file, \"options.mainline\", buf.buf);\n>                 strbuf_release(&buf);\n>         }\n>         if (opts->strategy)\n> -               git_config_set_in_file_or_die(opts_file, \"options.strategy\", opts->strategy);\n> +               git_config_set_in_file(opts_file, \"options.strategy\", opts->strategy);\n>         if (opts->gpg_sign)\n> -               git_config_set_in_file_or_die(opts_file, \"options.gpg-sign\", opts->gpg_sign);\n> +               git_config_set_in_file(opts_file, \"options.gpg-sign\", opts->gpg_sign);\n>         if (opts->xopts) {\n>                 int i;\n>                 for (i = 0; i < opts->xopts_nr; i++)\n> -                       git_config_set_multivar_in_file_or_die(opts_file,\n> -                                                              \"options.strategy-option\",\n> -                                                              opts->xopts[i], \"^$\", 0);\n> +                       git_config_set_multivar_in_file(opts_file,\n> +                                                       \"options.strategy-option\",\n> +                                                       opts->xopts[i], \"^$\", 0);\n>         }\n>  }\n>\n> diff --git a/submodule.c b/submodule.c\n> index be8b5cc..b3fc6ac 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -1087,9 +1087,9 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)\n>         /* Update core.worktree setting */\n>         strbuf_reset(&file_name);\n>         strbuf_addf(&file_name, \"%s/config\", git_dir);\n> -       git_config_set_in_file_or_die(file_name.buf, \"core.worktree\",\n> -                                     relative_path(real_work_tree, git_dir,\n> -                                                   &rel_path));\n> +       git_config_set_in_file(file_name.buf, \"core.worktree\",\n> +                              relative_path(real_work_tree, git_dir,\n> +                                            &rel_path));\n>\n>         strbuf_release(&file_name);\n>         strbuf_release(&rel_path);\n> --\n> 2.7.1\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n\nThis fails to compile on my mac:\n\n    CC unix-socket.o\n    CC compat/sha1-chunked.o\n    CC thread-utils.o\n    CC compat/precompose_utf8.o\ncompat/precompose_utf8.c:53:3: warning: implicit declaration of\nfunction 'git_config_set_or_die' is invalid in C99\n[-Wimplicit-function-declaration]\n                git_config_set_or_die(\"core.precomposeunicode\",\n                ^\n1 warning generated.\n    AR libgit.a\n    LINK git-credential-store\nUndefined symbols for architecture x86_64:\n  \"_git_config_set_or_die\", referenced from:\n      _probe_utf8_pathname_composition in libgit.a(precompose_utf8.o)\nld: symbol(s) not found for architecture x86_64\nclang: error: linker command failed with exit code 1 (use -v to see invocation)\nmake: *** [git-credential-store] Error 1\n"},{"id":"278506","messageId":"CAO2U3QjYKV_fPWb7CBYqvHXhQjcgZC+ht6VMQso4PBaHXas99Q@mail.gmail.com","threadId":"41423","inReplyTo":"CAO2U3Qia8r=jp9CmF0rN3ZxeJk+811q5VZ65pygr9aqrgLUn3A@mail.gmail.com","subject":"Re: [PATCH v5 15/15] config: rename git_config_set_or_die to git_config_set","fromName":"Michael Blume","fromEmail":"blume.mike@gmail.com","sentAt":"2016-02-17T21:02:45Z","receivedAt":"2016-02-17T21:02:45Z","isPatch":true,"sender":{"key":"blume.mike@gmail.com","avatar":"https://gravatar.com/avatar/1a7b440e1d942425ff4098ac7fc15b86b30cecaa56e1692a7ef8b5939ba25ea7?d=mp&s=160"},"body":"On Wed, Feb 17, 2016 at 12:57 PM, Michael Blume <blume.mike@gmail.com> wrote:\n> On Tue, Feb 16, 2016 at 4:56 AM, Patrick Steinhardt <ps@pks.im> wrote:\n>> Rename git_config_set_or_die functions to git_config_set, leading\n>> to the new default behavior of dying whenever a configuration\n>> error occurs.\n>>\n>> By now all callers that shall die on error have been transitioned\n>> to the _or_die variants, thus making this patch a simple rename\n>> of the functions.\n>>\n>> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n>> ---\n>>  builtin/branch.c            |  6 +++---\n>>  builtin/clone.c             |  8 ++++----\n>>  builtin/init-db.c           | 20 ++++++++++----------\n>>  builtin/remote.c            | 32 ++++++++++++++++----------------\n>>  builtin/submodule--helper.c |  4 ++--\n>>  cache.h                     |  8 ++++----\n>>  config.c                    | 24 ++++++++++++------------\n>>  sequencer.c                 | 22 +++++++++++-----------\n>>  submodule.c                 |  6 +++---\n>>  9 files changed, 65 insertions(+), 65 deletions(-)\n>>\n>> diff --git a/builtin/branch.c b/builtin/branch.c\n>> index c043cfc..7b45b6b 100644\n>> --- a/builtin/branch.c\n>> +++ b/builtin/branch.c\n>> @@ -594,7 +594,7 @@ static int edit_branch_description(const char *branch_name)\n>>         strbuf_stripspace(&buf, 1);\n>>\n>>         strbuf_addf(&name, \"branch.%s.description\", branch_name);\n>> -       git_config_set_or_die(name.buf, buf.len ? buf.buf : NULL);\n>> +       git_config_set(name.buf, buf.len ? buf.buf : NULL);\n>>         strbuf_release(&name);\n>>         strbuf_release(&buf);\n>>\n>> @@ -790,10 +790,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n>>                         die(_(\"Branch '%s' has no upstream information\"), branch->name);\n>>\n>>                 strbuf_addf(&buf, \"branch.%s.remote\", branch->name);\n>> -               git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n>> +               git_config_set_multivar(buf.buf, NULL, NULL, 1);\n>>                 strbuf_reset(&buf);\n>>                 strbuf_addf(&buf, \"branch.%s.merge\", branch->name);\n>> -               git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n>> +               git_config_set_multivar(buf.buf, NULL, NULL, 1);\n>>                 strbuf_release(&buf);\n>>         } else if (argc > 0 && argc <= 2) {\n>>                 struct branch *branch = branch_get(argv[0]);\n>> diff --git a/builtin/clone.c b/builtin/clone.c\n>> index 38094d4..b47c73f 100644\n>> --- a/builtin/clone.c\n>> +++ b/builtin/clone.c\n>> @@ -786,12 +786,12 @@ static void write_refspec_config(const char *src_ref_prefix,\n>>                 /* Configure the remote */\n>>                 if (value.len) {\n>>                         strbuf_addf(&key, \"remote.%s.fetch\", option_origin);\n>> -                       git_config_set_multivar_or_die(key.buf, value.buf, \"^$\", 0);\n>> +                       git_config_set_multivar(key.buf, value.buf, \"^$\", 0);\n>>                         strbuf_reset(&key);\n>>\n>>                         if (option_mirror) {\n>>                                 strbuf_addf(&key, \"remote.%s.mirror\", option_origin);\n>> -                               git_config_set_or_die(key.buf, \"true\");\n>> +                               git_config_set(key.buf, \"true\");\n>>                                 strbuf_reset(&key);\n>>                         }\n>>                 }\n>> @@ -949,14 +949,14 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n>>                         src_ref_prefix = \"refs/\";\n>>                 strbuf_addstr(&branch_top, src_ref_prefix);\n>>\n>> -               git_config_set_or_die(\"core.bare\", \"true\");\n>> +               git_config_set(\"core.bare\", \"true\");\n>>         } else {\n>>                 strbuf_addf(&branch_top, \"refs/remotes/%s/\", option_origin);\n>>         }\n>>\n>>         strbuf_addf(&value, \"+%s*:%s*\", src_ref_prefix, branch_top.buf);\n>>         strbuf_addf(&key, \"remote.%s.url\", option_origin);\n>> -       git_config_set_or_die(key.buf, repo);\n>> +       git_config_set(key.buf, repo);\n>>         strbuf_reset(&key);\n>>\n>>         if (option_reference.nr)\n>> diff --git a/builtin/init-db.c b/builtin/init-db.c\n>> index ef19048..6223b7d 100644\n>> --- a/builtin/init-db.c\n>> +++ b/builtin/init-db.c\n>> @@ -227,7 +227,7 @@ static int create_default_files(const char *template_path)\n>>         /* This forces creation of new config file */\n>>         xsnprintf(repo_version_string, sizeof(repo_version_string),\n>>                   \"%d\", GIT_REPO_VERSION);\n>> -       git_config_set_or_die(\"core.repositoryformatversion\", repo_version_string);\n>> +       git_config_set(\"core.repositoryformatversion\", repo_version_string);\n>>\n>>         /* Check filemode trustability */\n>>         path = git_path_buf(&buf, \"config\");\n>> @@ -241,18 +241,18 @@ static int create_default_files(const char *template_path)\n>>                 if (filemode && !reinit && (st1.st_mode & S_IXUSR))\n>>                         filemode = 0;\n>>         }\n>> -       git_config_set_or_die(\"core.filemode\", filemode ? \"true\" : \"false\");\n>> +       git_config_set(\"core.filemode\", filemode ? \"true\" : \"false\");\n>>\n>>         if (is_bare_repository())\n>> -               git_config_set_or_die(\"core.bare\", \"true\");\n>> +               git_config_set(\"core.bare\", \"true\");\n>>         else {\n>>                 const char *work_tree = get_git_work_tree();\n>> -               git_config_set_or_die(\"core.bare\", \"false\");\n>> +               git_config_set(\"core.bare\", \"false\");\n>>                 /* allow template config file to override the default */\n>>                 if (log_all_ref_updates == -1)\n>> -                       git_config_set_or_die(\"core.logallrefupdates\", \"true\");\n>> +                       git_config_set(\"core.logallrefupdates\", \"true\");\n>>                 if (needs_work_tree_config(get_git_dir(), work_tree))\n>> -                       git_config_set_or_die(\"core.worktree\", work_tree);\n>> +                       git_config_set(\"core.worktree\", work_tree);\n>>         }\n>>\n>>         if (!reinit) {\n>> @@ -265,12 +265,12 @@ static int create_default_files(const char *template_path)\n>>                     S_ISLNK(st1.st_mode))\n>>                         unlink(path); /* good */\n>>                 else\n>> -                       git_config_set_or_die(\"core.symlinks\", \"false\");\n>> +                       git_config_set(\"core.symlinks\", \"false\");\n>>\n>>                 /* Check if the filesystem is case-insensitive */\n>>                 path = git_path_buf(&buf, \"CoNfIg\");\n>>                 if (!access(path, F_OK))\n>> -                       git_config_set_or_die(\"core.ignorecase\", \"true\");\n>> +                       git_config_set(\"core.ignorecase\", \"true\");\n>>                 probe_utf8_pathname_composition();\n>>         }\n>>\n>> @@ -386,8 +386,8 @@ int init_db(const char *template_dir, unsigned int flags)\n>>                         xsnprintf(buf, sizeof(buf), \"%d\", OLD_PERM_EVERYBODY);\n>>                 else\n>>                         die(\"BUG: invalid value for shared_repository\");\n>> -               git_config_set_or_die(\"core.sharedrepository\", buf);\n>> -               git_config_set_or_die(\"receive.denyNonFastforwards\", \"true\");\n>> +               git_config_set(\"core.sharedrepository\", buf);\n>> +               git_config_set(\"receive.denyNonFastforwards\", \"true\");\n>>         }\n>>\n>>         if (!(flags & INIT_DB_QUIET)) {\n>> diff --git a/builtin/remote.c b/builtin/remote.c\n>> index abd5f67..ecb9b26 100644\n>> --- a/builtin/remote.c\n>> +++ b/builtin/remote.c\n>> @@ -119,7 +119,7 @@ static void add_branch(const char *key, const char *branchname,\n>>         else\n>>                 strbuf_addf(tmp, \"refs/heads/%s:refs/remotes/%s/%s\",\n>>                                 branchname, remotename, branchname);\n>> -       git_config_set_multivar_or_die(key, tmp->buf, \"^$\", 0);\n>> +       git_config_set_multivar(key, tmp->buf, \"^$\", 0);\n>>  }\n>>\n>>  static const char mirror_advice[] =\n>> @@ -197,7 +197,7 @@ static int add(int argc, const char **argv)\n>>                 die(_(\"'%s' is not a valid remote name\"), name);\n>>\n>>         strbuf_addf(&buf, \"remote.%s.url\", name);\n>> -       git_config_set_or_die(buf.buf, url);\n>> +       git_config_set(buf.buf, url);\n>>\n>>         if (!mirror || mirror & MIRROR_FETCH) {\n>>                 strbuf_reset(&buf);\n>> @@ -213,14 +213,14 @@ static int add(int argc, const char **argv)\n>>         if (mirror & MIRROR_PUSH) {\n>>                 strbuf_reset(&buf);\n>>                 strbuf_addf(&buf, \"remote.%s.mirror\", name);\n>> -               git_config_set_or_die(buf.buf, \"true\");\n>> +               git_config_set(buf.buf, \"true\");\n>>         }\n>>\n>>         if (fetch_tags != TAGS_DEFAULT) {\n>>                 strbuf_reset(&buf);\n>>                 strbuf_addf(&buf, \"remote.%s.tagopt\", name);\n>> -               git_config_set_or_die(buf.buf,\n>> -                                     fetch_tags == TAGS_SET ? \"--tags\" : \"--no-tags\");\n>> +               git_config_set(buf.buf,\n>> +                              fetch_tags == TAGS_SET ? \"--tags\" : \"--no-tags\");\n>>         }\n>>\n>>         if (fetch && fetch_remote(name))\n>> @@ -588,15 +588,15 @@ static int migrate_file(struct remote *remote)\n>>\n>>         strbuf_addf(&buf, \"remote.%s.url\", remote->name);\n>>         for (i = 0; i < remote->url_nr; i++)\n>> -               git_config_set_multivar_or_die(buf.buf, remote->url[i], \"^$\", 0);\n>> +               git_config_set_multivar(buf.buf, remote->url[i], \"^$\", 0);\n>>         strbuf_reset(&buf);\n>>         strbuf_addf(&buf, \"remote.%s.push\", remote->name);\n>>         for (i = 0; i < remote->push_refspec_nr; i++)\n>> -               git_config_set_multivar_or_die(buf.buf, remote->push_refspec[i], \"^$\", 0);\n>> +               git_config_set_multivar(buf.buf, remote->push_refspec[i], \"^$\", 0);\n>>         strbuf_reset(&buf);\n>>         strbuf_addf(&buf, \"remote.%s.fetch\", remote->name);\n>>         for (i = 0; i < remote->fetch_refspec_nr; i++)\n>> -               git_config_set_multivar_or_die(buf.buf, remote->fetch_refspec[i], \"^$\", 0);\n>> +               git_config_set_multivar(buf.buf, remote->fetch_refspec[i], \"^$\", 0);\n>>         if (remote->origin == REMOTE_REMOTES)\n>>                 unlink_or_warn(git_path(\"remotes/%s\", remote->name));\n>>         else if (remote->origin == REMOTE_BRANCHES)\n>> @@ -648,7 +648,7 @@ static int mv(int argc, const char **argv)\n>>\n>>         strbuf_reset(&buf);\n>>         strbuf_addf(&buf, \"remote.%s.fetch\", rename.new);\n>> -       git_config_set_multivar_or_die(buf.buf, NULL, NULL, 1);\n>> +       git_config_set_multivar(buf.buf, NULL, NULL, 1);\n>>         strbuf_addf(&old_remote_context, \":refs/remotes/%s/\", rename.old);\n>>         for (i = 0; i < oldremote->fetch_refspec_nr; i++) {\n>>                 char *ptr;\n>> @@ -668,7 +668,7 @@ static int mv(int argc, const char **argv)\n>>                                   \"\\tPlease update the configuration manually if necessary.\"),\n>>                                 buf2.buf);\n>>\n>> -               git_config_set_multivar_or_die(buf.buf, buf2.buf, \"^$\", 0);\n>> +               git_config_set_multivar(buf.buf, buf2.buf, \"^$\", 0);\n>>         }\n>>\n>>         read_branches();\n>> @@ -678,7 +678,7 @@ static int mv(int argc, const char **argv)\n>>                 if (info->remote_name && !strcmp(info->remote_name, rename.old)) {\n>>                         strbuf_reset(&buf);\n>>                         strbuf_addf(&buf, \"branch.%s.remote\", item->string);\n>> -                       git_config_set_or_die(buf.buf, rename.new);\n>> +                       git_config_set(buf.buf, rename.new);\n>>                 }\n>>         }\n>>\n>> @@ -776,7 +776,7 @@ static int rm(int argc, const char **argv)\n>>                                 strbuf_reset(&buf);\n>>                                 strbuf_addf(&buf, \"branch.%s.%s\",\n>>                                                 item->string, *k);\n>> -                               git_config_set_or_die(buf.buf, NULL);\n>> +                               git_config_set(buf.buf, NULL);\n>>                         }\n>>                 }\n>>         }\n>> @@ -1560,10 +1560,10 @@ static int set_url(int argc, const char **argv)\n>>         /* Special cases that add new entry. */\n>>         if ((!oldurl && !delete_mode) || add_mode) {\n>>                 if (add_mode)\n>> -                       git_config_set_multivar_or_die(name_buf.buf, newurl,\n>> +                       git_config_set_multivar(name_buf.buf, newurl,\n>>                                                        \"^$\", 0);\n>>                 else\n>> -                       git_config_set_or_die(name_buf.buf, newurl);\n>> +                       git_config_set(name_buf.buf, newurl);\n>>                 strbuf_release(&name_buf);\n>>\n>>                 return 0;\n>> @@ -1586,9 +1586,9 @@ static int set_url(int argc, const char **argv)\n>>         regfree(&old_regex);\n>>\n>>         if (!delete_mode)\n>> -               git_config_set_multivar_or_die(name_buf.buf, newurl, oldurl, 0);\n>> +               git_config_set_multivar(name_buf.buf, newurl, oldurl, 0);\n>>         else\n>> -               git_config_set_multivar_or_die(name_buf.buf, NULL, oldurl, 1);\n>> +               git_config_set_multivar(name_buf.buf, NULL, oldurl, 1);\n>>         return 0;\n>>  }\n>>\n>> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\n>> index c7e1ea2..f4c3eff 100644\n>> --- a/builtin/submodule--helper.c\n>> +++ b/builtin/submodule--helper.c\n>> @@ -245,8 +245,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)\n>>         p = git_pathdup_submodule(path, \"config\");\n>>         if (!p)\n>>                 die(_(\"could not get submodule directory for '%s'\"), path);\n>> -       git_config_set_in_file_or_die(p, \"core.worktree\",\n>> -                                     relative_path(sb.buf, sm_gitdir, &rel_path));\n>> +       git_config_set_in_file(p, \"core.worktree\",\n>> +                              relative_path(sb.buf, sm_gitdir, &rel_path));\n>>         strbuf_release(&sb);\n>>         strbuf_release(&rel_path);\n>>         free(sm_gitdir);\n>> diff --git a/cache.h b/cache.h\n>> index 2d48aef..63fb85e 100644\n>> --- a/cache.h\n>> +++ b/cache.h\n>> @@ -1526,15 +1526,15 @@ extern int git_config_maybe_bool(const char *, const char *);\n>>  extern int git_config_string(const char **, const char *, const char *);\n>>  extern int git_config_pathname(const char **, const char *, const char *);\n>>  extern int git_config_set_in_file_gently(const char *, const char *, const char *);\n>> -extern void git_config_set_in_file_or_die(const char *, const char *, const char *);\n>> +extern void git_config_set_in_file(const char *, const char *, const char *);\n>>  extern int git_config_set_gently(const char *, const char *);\n>> -extern void git_config_set_or_die(const char *, const char *);\n>> +extern void git_config_set(const char *, const char *);\n>>  extern int git_config_parse_key(const char *, char **, int *);\n>>  extern int git_config_key_is_valid(const char *key);\n>>  extern int git_config_set_multivar_gently(const char *, const char *, const char *, int);\n>> -extern void git_config_set_multivar_or_die(const char *, const char *, const char *, int);\n>> +extern void git_config_set_multivar(const char *, const char *, const char *, int);\n>>  extern int git_config_set_multivar_in_file_gently(const char *, const char *, const char *, const char *, int);\n>> -extern void git_config_set_multivar_in_file_or_die(const char *, const char *, const char *, const char *, int);\n>> +extern void git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int);\n>>  extern int git_config_rename_section(const char *, const char *);\n>>  extern int git_config_rename_section_in_file(const char *, const char *, const char *);\n>>  extern const char *git_etc_gitconfig(void);\n>> diff --git a/config.c b/config.c\n>> index e7f42da..325c3ea 100644\n>> --- a/config.c\n>> +++ b/config.c\n>> @@ -1831,10 +1831,10 @@ int git_config_set_in_file_gently(const char *config_filename,\n>>         return git_config_set_multivar_in_file_gently(config_filename, key, value, NULL, 0);\n>>  }\n>>\n>> -void git_config_set_in_file_or_die(const char *config_filename,\n>> -                       const char *key, const char *value)\n>> +void git_config_set_in_file(const char *config_filename,\n>> +                           const char *key, const char *value)\n>>  {\n>> -       git_config_set_multivar_in_file_or_die(config_filename, key, value, NULL, 0);\n>> +       git_config_set_multivar_in_file(config_filename, key, value, NULL, 0);\n>>  }\n>>\n>>  int git_config_set_gently(const char *key, const char *value)\n>> @@ -1842,9 +1842,9 @@ int git_config_set_gently(const char *key, const char *value)\n>>         return git_config_set_multivar_gently(key, value, NULL, 0);\n>>  }\n>>\n>> -void git_config_set_or_die(const char *key, const char *value)\n>> +void git_config_set(const char *key, const char *value)\n>>  {\n>> -       git_config_set_multivar_or_die(key, value, NULL, 0);\n>> +       git_config_set_multivar(key, value, NULL, 0);\n>>  }\n>>\n>>  /*\n>> @@ -2191,9 +2191,9 @@ write_err_out:\n>>\n>>  }\n>>\n>> -void git_config_set_multivar_in_file_or_die(const char *config_filename,\n>> -                               const char *key, const char *value,\n>> -                               const char *value_regex, int multi_replace)\n>> +void git_config_set_multivar_in_file(const char *config_filename,\n>> +                                    const char *key, const char *value,\n>> +                                    const char *value_regex, int multi_replace)\n>>  {\n>>         if (git_config_set_multivar_in_file_gently(config_filename, key, value,\n>>                                                    value_regex, multi_replace) < 0)\n>> @@ -2207,11 +2207,11 @@ int git_config_set_multivar_gently(const char *key, const char *value,\n>>                                                       multi_replace);\n>>  }\n>>\n>> -void git_config_set_multivar_or_die(const char *key, const char *value,\n>> -                       const char *value_regex, int multi_replace)\n>> +void git_config_set_multivar(const char *key, const char *value,\n>> +                            const char *value_regex, int multi_replace)\n>>  {\n>> -       git_config_set_multivar_in_file_or_die(NULL, key, value, value_regex,\n>> -                                              multi_replace);\n>> +       git_config_set_multivar_in_file(NULL, key, value, value_regex,\n>> +                                       multi_replace);\n>>  }\n>>\n>>  static int section_name_match (const char *buf, const char *name)\n>> diff --git a/sequencer.c b/sequencer.c\n>> index 3590248..8048786 100644\n>> --- a/sequencer.c\n>> +++ b/sequencer.c\n>> @@ -933,31 +933,31 @@ static void save_opts(struct replay_opts *opts)\n>>         const char *opts_file = git_path_opts_file();\n>>\n>>         if (opts->no_commit)\n>> -               git_config_set_in_file_or_die(opts_file, \"options.no-commit\", \"true\");\n>> +               git_config_set_in_file(opts_file, \"options.no-commit\", \"true\");\n>>         if (opts->edit)\n>> -               git_config_set_in_file_or_die(opts_file, \"options.edit\", \"true\");\n>> +               git_config_set_in_file(opts_file, \"options.edit\", \"true\");\n>>         if (opts->signoff)\n>> -               git_config_set_in_file_or_die(opts_file, \"options.signoff\", \"true\");\n>> +               git_config_set_in_file(opts_file, \"options.signoff\", \"true\");\n>>         if (opts->record_origin)\n>> -               git_config_set_in_file_or_die(opts_file, \"options.record-origin\", \"true\");\n>> +               git_config_set_in_file(opts_file, \"options.record-origin\", \"true\");\n>>         if (opts->allow_ff)\n>> -               git_config_set_in_file_or_die(opts_file, \"options.allow-ff\", \"true\");\n>> +               git_config_set_in_file(opts_file, \"options.allow-ff\", \"true\");\n>>         if (opts->mainline) {\n>>                 struct strbuf buf = STRBUF_INIT;\n>>                 strbuf_addf(&buf, \"%d\", opts->mainline);\n>> -               git_config_set_in_file_or_die(opts_file, \"options.mainline\", buf.buf);\n>> +               git_config_set_in_file(opts_file, \"options.mainline\", buf.buf);\n>>                 strbuf_release(&buf);\n>>         }\n>>         if (opts->strategy)\n>> -               git_config_set_in_file_or_die(opts_file, \"options.strategy\", opts->strategy);\n>> +               git_config_set_in_file(opts_file, \"options.strategy\", opts->strategy);\n>>         if (opts->gpg_sign)\n>> -               git_config_set_in_file_or_die(opts_file, \"options.gpg-sign\", opts->gpg_sign);\n>> +               git_config_set_in_file(opts_file, \"options.gpg-sign\", opts->gpg_sign);\n>>         if (opts->xopts) {\n>>                 int i;\n>>                 for (i = 0; i < opts->xopts_nr; i++)\n>> -                       git_config_set_multivar_in_file_or_die(opts_file,\n>> -                                                              \"options.strategy-option\",\n>> -                                                              opts->xopts[i], \"^$\", 0);\n>> +                       git_config_set_multivar_in_file(opts_file,\n>> +                                                       \"options.strategy-option\",\n>> +                                                       opts->xopts[i], \"^$\", 0);\n>>         }\n>>  }\n>>\n>> diff --git a/submodule.c b/submodule.c\n>> index be8b5cc..b3fc6ac 100644\n>> --- a/submodule.c\n>> +++ b/submodule.c\n>> @@ -1087,9 +1087,9 @@ void connect_work_tree_and_git_dir(const char *work_tree, const char *git_dir)\n>>         /* Update core.worktree setting */\n>>         strbuf_reset(&file_name);\n>>         strbuf_addf(&file_name, \"%s/config\", git_dir);\n>> -       git_config_set_in_file_or_die(file_name.buf, \"core.worktree\",\n>> -                                     relative_path(real_work_tree, git_dir,\n>> -                                                   &rel_path));\n>> +       git_config_set_in_file(file_name.buf, \"core.worktree\",\n>> +                              relative_path(real_work_tree, git_dir,\n>> +                                            &rel_path));\n>>\n>>         strbuf_release(&file_name);\n>>         strbuf_release(&rel_path);\n>> --\n>> 2.7.1\n>>\n>> --\n>> To unsubscribe from this list: send the line \"unsubscribe git\" in\n>> the body of a message to majordomo@vger.kernel.org\n>> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n> This fails to compile on my mac:\n>\n>     CC unix-socket.o\n>     CC compat/sha1-chunked.o\n>     CC thread-utils.o\n>     CC compat/precompose_utf8.o\n> compat/precompose_utf8.c:53:3: warning: implicit declaration of\n> function 'git_config_set_or_die' is invalid in C99\n> [-Wimplicit-function-declaration]\n>                 git_config_set_or_die(\"core.precomposeunicode\",\n>                 ^\n> 1 warning generated.\n>     AR libgit.a\n>     LINK git-credential-store\n> Undefined symbols for architecture x86_64:\n>   \"_git_config_set_or_die\", referenced from:\n>       _probe_utf8_pathname_composition in libgit.a(precompose_utf8.o)\n> ld: symbol(s) not found for architecture x86_64\n> clang: error: linker command failed with exit code 1 (use -v to see invocation)\n> make: *** [git-credential-store] Error 1\n\nLooks like there's one more use of git_config_set_or_die that needs to\nbe removed.\n"},{"id":"278508","messageId":"xmqqh9h7hwmy.fsf@gitster.mtv.corp.google.com","threadId":"41423","inReplyTo":"CAO2U3QjYKV_fPWb7CBYqvHXhQjcgZC+ht6VMQso4PBaHXas99Q@mail.gmail.com","subject":"Re: [PATCH v5 15/15] config: rename git_config_set_or_die to git_config_set","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-17T21:09:25Z","receivedAt":"2016-02-17T21:09:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Michael Blume <blume.mike@gmail.com> writes:\n\n[administrivia: please cull unnecessary parts from your quote]\n\n>> 1 warning generated.\n>>     AR libgit.a\n>>     LINK git-credential-store\n>> Undefined symbols for architecture x86_64:\n>>   \"_git_config_set_or_die\", referenced from:\n>>       _probe_utf8_pathname_composition in libgit.a(precompose_utf8.o)\n>> ld: symbol(s) not found for architecture x86_64\n>> clang: error: linker command failed with exit code 1 (use -v to see invocation)\n>> make: *** [git-credential-store] Error 1\n>\n> Looks like there's one more use of git_config_set_or_die that needs to\n> be removed.\n\nThanks; let's squash this in.\n\n compat/precompose_utf8.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c\nindex 9ff1ebe..dfbe6d8 100644\n--- a/compat/precompose_utf8.c\n+++ b/compat/precompose_utf8.c\n@@ -50,8 +50,8 @@ void probe_utf8_pathname_composition(void)\n \t\tclose(output_fd);\n \t\tgit_path_buf(&path, \"%s\", auml_nfd);\n \t\tprecomposed_unicode = access(path.buf, R_OK) ? 0 : 1;\n-\t\tgit_config_set_or_die(\"core.precomposeunicode\",\n-\t\t\t\t      precomposed_unicode ? \"true\" : \"false\");\n+\t\tgit_config_set(\"core.precomposeunicode\",\n+\t\t\t       precomposed_unicode ? \"true\" : \"false\");\n \t\tgit_path_buf(&path, \"%s\", auml_nfc);\n \t\tif (unlink(path.buf))\n \t\t\tdie_errno(_(\"failed to unlink '%s'\"), path.buf);\n"}]}