{"thread":{"id":"41469","subject":"[PATCH v6 00/15] config: make git_config_set die on failure","startedAt":"2016-02-22T11:23:21Z","lastAt":"2016-02-22T11:23:36Z","messageCount":16,"participants":["Patrick Steinhardt"],"isPatch":true,"patchVersion":6,"patchTotal":15},"messages":[{"id":"278860","messageId":"1456140216-24169-1-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":null,"subject":"[PATCH v6 00/15] config: make git_config_set die on failure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:21Z","receivedAt":"2016-02-22T11:23:21Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"Next revision of my patch series to improve error handling on\ngit_config_set. Only three small changes to v5 [1], thanks for\npointing these out:\n\n    - fixed missing conversion of git_config_set_or_die in\n      compat/precompose_utf8.c\n    - fixed indentation in install_branch_config\n    - improved advise message to give the complete command for\n      fixing up the upstream configuration, including the actual\n      tracking branch\n\n[1]: http://article.gmane.org/gmane.comp.version-control.git/286355\n\nInterdiff to v5:\n\ndiff --git a/branch.c b/branch.c\nindex 06942ef..c50ea42 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -53,7 +53,7 @@ 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+\"\\\"git branch --set-upstream-to=%s%s%s\\\".\");\n \n int install_branch_config(int flag, const char *local, const char *origin, const char *remote)\n {\n@@ -82,7 +82,7 @@ int install_branch_config(int flag, const char *local, const char *origin, const\n \t\tstrbuf_reset(&key);\n \t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n \t\tif (git_config_set_gently(key.buf, \"true\") < 0)\n-\t\t    goto out_err;\n+\t\t\tgoto out_err;\n \t}\n \tstrbuf_release(&key);\n \n@@ -117,7 +117,12 @@ int install_branch_config(int flag, const char *local, const char *origin, const\n out_err:\n \tstrbuf_release(&key);\n \terror(_(\"Unable to write upstream branch configuration\"));\n-\tadvise(_(tracking_advice));\n+\n+\tadvise(_(tracking_advice),\n+\t       origin ? origin : \"\",\n+\t       origin ? \"/\" : \"\",\n+\t       shortname ? shortname : remote);\n+\n \treturn -1;\n }\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\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                 | 50 ++++++++++++++++++++++++----------\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, 159 insertions(+), 105 deletions(-)\n\n-- \n2.7.1\n"},{"id":"278861","messageId":"1456140216-24169-2-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 01/15] config: introduce set_or_die wrappers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:22Z","receivedAt":"2016-02-22T11:23:22Z","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 26640b4..209d8c8 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 b95ac3a..261853a 100644\n--- a/config.c\n+++ b/config.c\n@@ -1855,11 +1855,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@@ -2203,6 +2214,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@@ -2210,6 +2230,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":"278872","messageId":"1456140216-24169-3-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 02/15] branch: report errors in tracking branch setup","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:23Z","receivedAt":"2016-02-22T11:23:23Z","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          | 50 ++++++++++++++++++++++++++++++++++++--------------\n branch.h          |  3 ++-\n t/t3200-branch.sh |  9 ++++++++-\n 3 files changed, 46 insertions(+), 16 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 7ff3f20..713ceda 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=%s%s%s\\\".\");\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\tgoto out_err;\n \t}\n \tstrbuf_release(&key);\n \n@@ -102,6 +111,19 @@ 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+\n+\tadvise(_(tracking_advice),\n+\t       origin ? origin : \"\",\n+\t       origin ? \"/\" : \"\",\n+\t       shortname ? shortname : remote);\n+\n+\treturn -1;\n }\n \n /*\n@@ -109,8 +131,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 +140,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 +149,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":"278875","messageId":"1456140216-24169-4-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 03/15] branch: die on config error when unsetting upstream","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:24Z","receivedAt":"2016-02-22T11:23:24Z","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":"278874","messageId":"1456140216-24169-5-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 04/15] branch: die on config error when editing branch description","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:25Z","receivedAt":"2016-02-22T11:23:25Z","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":"278862","messageId":"1456140216-24169-6-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 05/15] submodule: die on config error when linking modules","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:26Z","receivedAt":"2016-02-22T11:23:26Z","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":"278864","messageId":"1456140216-24169-7-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 06/15] submodule--helper: die on config error when cloning module","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:27Z","receivedAt":"2016-02-22T11:23:27Z","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":"278873","messageId":"1456140216-24169-8-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 07/15] remote: die on config error when setting URL","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:28Z","receivedAt":"2016-02-22T11:23:28Z","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":"278865","messageId":"1456140216-24169-9-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 08/15] remote: die on config error when setting/adding branches","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:29Z","receivedAt":"2016-02-22T11:23:29Z","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":"278866","messageId":"1456140216-24169-10-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 09/15] remote: die on config error when manipulating remotes","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:30Z","receivedAt":"2016-02-22T11:23:30Z","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":"278867","messageId":"1456140216-24169-11-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 10/15] clone: die on config error in cmd_clone","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:31Z","receivedAt":"2016-02-22T11:23:31Z","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":"278863","messageId":"1456140216-24169-12-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 11/15] init-db: die on config errors when initializing empty repo","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:32Z","receivedAt":"2016-02-22T11:23:32Z","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":"278868","messageId":"1456140216-24169-13-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 12/15] sequencer: die on config error when saving replay opts","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:33Z","receivedAt":"2016-02-22T11:23:33Z","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":"278870","messageId":"1456140216-24169-14-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 13/15] compat: die when unable to set core.precomposeunicode","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:34Z","receivedAt":"2016-02-22T11:23:34Z","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":"278869","messageId":"1456140216-24169-15-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 14/15] config: rename git_config_set to git_config_set_gently","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:35Z","receivedAt":"2016-02-22T11:23:35Z","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 713ceda..c50ea42 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\tgoto 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 209d8c8..4dcf473 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 261853a..a75f60c 100644\n--- a/config.c\n+++ b/config.c\n@@ -1849,10 +1849,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@@ -1861,9 +1861,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@@ -1985,9 +1985,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@@ -2218,16 +2219,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":"278871","messageId":"1456140216-24169-16-git-send-email-ps@pks.im","threadId":"41469","inReplyTo":"1456140216-24169-1-git-send-email-ps@pks.im","subject":"[PATCH v6 15/15] config: rename git_config_set_or_die to git_config_set","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-22T11:23:36Z","receivedAt":"2016-02-22T11:23:36Z","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 compat/precompose_utf8.c    |  4 ++--\n config.c                    | 24 ++++++++++++------------\n sequencer.c                 | 22 +++++++++++-----------\n submodule.c                 |  6 +++---\n 10 files changed, 67 insertions(+), 67 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 4dcf473..451507e 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/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);\ndiff --git a/config.c b/config.c\nindex a75f60c..8b2e3a4 100644\n--- a/config.c\n+++ b/config.c\n@@ -1855,10 +1855,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@@ -1866,9 +1866,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@@ -2215,9 +2215,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@@ -2231,11 +2231,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"}]}