{"thread":{"id":"41309","subject":"[PATCH v4 00/15] config: make git_config_set die on failure","startedAt":"2016-02-02T11:51:41Z","lastAt":"2016-02-08T14:05:51Z","messageCount":26,"participants":["Patrick Steinhardt","Eric Sunshine","Stefan Beller","Junio C Hamano"],"isPatch":true,"patchVersion":4,"patchTotal":15},"messages":[{"id":"277220","messageId":"1454413916-31984-1-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":null,"subject":"[PATCH v4 00/15] config: make git_config_set die on failure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:41Z","receivedAt":"2016-02-02T11:51:41Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"This is the fourth version of my patch series. Version three of\nthese patches can be found at [1]. These patches convert the\n`git_config_set` family of functions such that they die by\ndefault whenever an error is encountered in persisting configs.\nThis catches a lot of cases where we wrote configs without\nchecking the returned status code, thus leading to inconsistent\nstate witouth even notifying the user.\n\nThis version combines both version 2 ([2]) and version 3 of this\npatch series in that we first introduce `git_config_set_or_die`\nwrappers and converting most call sites to use these. After the\nconversion is done, we rename `git_config_set` to\n`git_config_set_gently` and adjusting remaining call sites. The\nlast step was to rename `git_config_set_or_die` to\n`git_config_set` in order to get the desired default behavior.\n\nThis back-and-forth should hopefully help easing the transition\nand review by breaking down the actual transition into small\npieces.\n\n[1]: http://article.gmane.org/gmane.comp.version-control.git/285198\n[2]: http://article.gmane.org/gmane.comp.version-control.git/285000\n\nPatrick Steinhardt (15):\n  config: introduce set_or_die wrappers\n  branch: die on error in setting up tracking branch\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                 | 13 +++++----\n branch.h                 |  1 +\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, 128 insertions(+), 97 deletions(-)\n\n-- \n2.7.0\n"},{"id":"277222","messageId":"1454413916-31984-2-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 01/15] config: introduce set_or_die wrappers","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:42Z","receivedAt":"2016-02-02T11:51:42Z","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 dfc459c..c1f844d 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1508,11 +1508,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.0\n"},{"id":"277224","messageId":"1454413916-31984-3-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 02/15] branch: die on error in setting up tracking branch","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:43Z","receivedAt":"2016-02-02T11:51:43Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"The setup_tracking function calls install_branch_config, which\nmay fail writing the configuration due to a locked configuration\nfile or other error conditions. setup_tracking can also fail when\ntrying to track ambiguous information for a reference. While this\ncondition is checked for and an error code is returned, this\nerror is not checked by the caller.\n\nFix both issues by dying early when error occur.\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n---\n branch.c          | 19 +++++++++----------\n branch.h          |  1 +\n t/t3200-branch.sh |  9 ++++++++-\n 3 files changed, 18 insertions(+), 11 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 7ff3f20..7106369 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -64,16 +64,16 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t}\n \n \tstrbuf_addf(&key, \"branch.%s.remote\", local);\n-\tgit_config_set(key.buf, origin ? origin : \".\");\n+\tgit_config_set_or_die(key.buf, origin ? origin : \".\");\n \n \tstrbuf_reset(&key);\n \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n-\tgit_config_set(key.buf, remote);\n+\tgit_config_set_or_die(key.buf, remote);\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\tgit_config_set_or_die(key.buf, \"true\");\n \t}\n \tstrbuf_release(&key);\n \n@@ -109,8 +109,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 +118,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 +127,17 @@ 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 \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..8ce22f8 100644\n--- a/branch.h\n+++ b/branch.h\n@@ -43,6 +43,7 @@ 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  */\n #define BRANCH_CONFIG_VERBOSE 01\n extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);\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.0\n"},{"id":"277226","messageId":"1454413916-31984-4-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 03/15] branch: die on config error when unsetting upstream","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:44Z","receivedAt":"2016-02-02T11:51:44Z","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.0\n"},{"id":"277221","messageId":"1454413916-31984-5-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 04/15] branch: die on config error when editing branch description","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:45Z","receivedAt":"2016-02-02T11:51:45Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"---\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.0\n"},{"id":"277223","messageId":"1454413916-31984-6-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 05/15] submodule: die on config error when linking modules","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:46Z","receivedAt":"2016-02-02T11:51:46Z","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.0\n"},{"id":"277225","messageId":"1454413916-31984-7-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 06/15] submodule--helper: die on config error when cloning module","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:47Z","receivedAt":"2016-02-02T11:51:47Z","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 instaed\nwe want to inform the user that something has gone wrong by\nprinting an 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.0\n"},{"id":"277228","messageId":"1454413916-31984-8-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 07/15] remote: die on config error when setting URL","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:48Z","receivedAt":"2016-02-02T11:51:48Z","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\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.0\n"},{"id":"277227","messageId":"1454413916-31984-9-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 08/15] remote: die on config error when setting/adding branches","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:49Z","receivedAt":"2016-02-02T11:51:49Z","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.0\n"},{"id":"277229","messageId":"1454413916-31984-10-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 09/15] remote: die on config error when manipulating remotes","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:50Z","receivedAt":"2016-02-02T11:51:50Z","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.0\n"},{"id":"277234","messageId":"1454413916-31984-11-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 10/15] clone: die on config error in cmd_clone","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:51Z","receivedAt":"2016-02-02T11:51:51Z","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 81e238f..f2a2f9a 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.0\n"},{"id":"277235","messageId":"1454413916-31984-12-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 11/15] init-db: die on config errors when initializing empty repo","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:52Z","receivedAt":"2016-02-02T11:51:52Z","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.0\n"},{"id":"277230","messageId":"1454413916-31984-13-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 12/15] sequencer: die on config error when saving replay opts","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:53Z","receivedAt":"2016-02-02T11:51:53Z","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.0\n"},{"id":"277231","messageId":"1454413916-31984-14-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 13/15] compat: die when unable to set core.precomposeunicode","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:54Z","receivedAt":"2016-02-02T11:51:54Z","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.0\n"},{"id":"277233","messageId":"1454413916-31984-15-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 14/15] config: rename git_config_set to git_config_set_gently","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:55Z","receivedAt":"2016-02-02T11:51:55Z","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 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 6 files changed, 37 insertions(+), 36 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex f2a2f9a..dccfab3 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 c1f844d..a97f677 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1469,7 +1469,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@@ -1507,15 +1507,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.0\n"},{"id":"277232","messageId":"1454413916-31984-16-git-send-email-ps@pks.im","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"[PATCH v4 15/15] config: rename git_config_set_or_die to git_config_set","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T11:51:56Z","receivedAt":"2016-02-02T11:51:56Z","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 branch.c                    |  6 +++---\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 10 files changed, 68 insertions(+), 68 deletions(-)\n\ndiff --git a/branch.c b/branch.c\nindex 7106369..0c11023 100644\n--- a/branch.c\n+++ b/branch.c\n@@ -64,16 +64,16 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n \t}\n \n \tstrbuf_addf(&key, \"branch.%s.remote\", local);\n-\tgit_config_set_or_die(key.buf, origin ? origin : \".\");\n+\tgit_config_set(key.buf, origin ? origin : \".\");\n \n \tstrbuf_reset(&key);\n \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n-\tgit_config_set_or_die(key.buf, remote);\n+\tgit_config_set(key.buf, remote);\n \n \tif (rebasing) {\n \t\tstrbuf_reset(&key);\n \t\tstrbuf_addf(&key, \"branch.%s.rebase\", local);\n-\t\tgit_config_set_or_die(key.buf, \"true\");\n+\t\tgit_config_set(key.buf, \"true\");\n \t}\n \tstrbuf_release(&key);\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 dccfab3..ecdd80a 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 a97f677..876106a 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1508,15 +1508,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.0\n"},{"id":"277236","messageId":"20160202120003.GA22942@pks-pc.localdomain","threadId":"41309","inReplyTo":"1454413916-31984-8-git-send-email-ps@pks.im","subject":"Re: [PATCH v4 07/15] remote: die on config error when setting URL","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-02T12:00:03Z","receivedAt":"2016-02-02T12:00:03Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Feb 02, 2016 at 12:51:48PM +0100, Patrick Steinhardt wrote:\n> When invoking `git-remote --set-url` we do not check the return\n> value when writing the actual new URL to the configuration file,\n> pretending to the user that the configuration has been set while\n> it was in fact not persisted.\n> \n> Fix this problem by dying early when setting the config fails.\n> \n> Signed-off-by: Patrick Steinhardt\n\nSigned-off-by: Patrick Steinhardt <ps@pks.im>\n\nSorry, borked up that signed-off-by. Will fix in a later revision\n(which I guess will be necessary anyway ;).\n\nPatrick\n"},{"id":"277264","messageId":"CAPig+cSLoXGHFXm96dpfjmkZkpXOFezEFZek-Jry85XkCwOsWA@mail.gmail.com","threadId":"41309","inReplyTo":"1454413916-31984-7-git-send-email-ps@pks.im","subject":"Re: [PATCH v4 06/15] submodule--helper: die on config error when cloning module","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2016-02-02T18:45:50Z","receivedAt":"2016-02-02T18:45:50Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Feb 2, 2016 at 6:51 AM, Patrick Steinhardt <ps@pks.im> wrote:\n> When setting the 'core.worktree' option for a newly cloned\n> submodule we ignore the return value of `git_config_set_in_file`.\n> As this leaves the submodule in an inconsistent state, we instaed\n> we want to inform the user that something has gone wrong by\n\ns/instaed/instead/\n\nAlso, there are too many \"we\"s, so dropping one would be a good idea:\neither \"we instead\" or \"instead we\".\n\n> printing an error and aborting the program.\n>\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n"},{"id":"277266","messageId":"CAGZ79kb-tATWrCgw5PFRK=W43JLH-mN-VSac7b5Z39Hpe3qXxw@mail.gmail.com","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"Re: [PATCH v4 00/15] config: make git_config_set die on failure","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-02-02T18:52:48Z","receivedAt":"2016-02-02T18:52:48Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Feb 2, 2016 at 3:51 AM, Patrick Steinhardt <ps@pks.im> wrote:\n>   submodule: die on config error when linking modules\n>   submodule--helper: die on config error when cloning module\n\nThe code in the submodule related patches looks fine to me.\n"},{"id":"277275","messageId":"xmqq60y6suqx.fsf@gitster.mtv.corp.google.com","threadId":"41309","inReplyTo":"1454413916-31984-3-git-send-email-ps@pks.im","subject":"Re: [PATCH v4 02/15] branch: die on error in setting up tracking branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-02T20:49:26Z","receivedAt":"2016-02-02T20:49:26Z","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> The setup_tracking function calls install_branch_config, which\n> may fail writing the configuration due to a locked configuration\n> file or other error conditions. setup_tracking can also fail when\n> trying to track ambiguous information for a reference. While this\n> condition is checked for and an error code is returned, this\n> error is not checked by the caller.\n>\n> Fix both issues by dying early when error occur.\n\nHmph.  I think create_branch() is written in such a way that all\ndie() come before the actual ref transaction attempts to create the\nbranch, but this change means that we have already created the\nbranch and then die without undoing the damage that is already done.\n\n\"The error is not checked by the caller\" is very true, but can the\ncaller do something better than just die?  I personally do not think\nit is such a big deal if we just died here, but I may have overlooked\nsomething.\n\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  branch.c          | 19 +++++++++----------\n>  branch.h          |  1 +\n>  t/t3200-branch.sh |  9 ++++++++-\n>  3 files changed, 18 insertions(+), 11 deletions(-)\n>\n> diff --git a/branch.c b/branch.c\n> index 7ff3f20..7106369 100644\n> --- a/branch.c\n> +++ b/branch.c\n> @@ -64,16 +64,16 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n>  \t}\n>  \n>  \tstrbuf_addf(&key, \"branch.%s.remote\", local);\n> -\tgit_config_set(key.buf, origin ? origin : \".\");\n> +\tgit_config_set_or_die(key.buf, origin ? origin : \".\");\n>  \n>  \tstrbuf_reset(&key);\n>  \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n> -\tgit_config_set(key.buf, remote);\n> +\tgit_config_set_or_die(key.buf, remote);\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\tgit_config_set_or_die(key.buf, \"true\");\n>  \t}\n>  \tstrbuf_release(&key);\n>  \n> @@ -109,8 +109,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 +118,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 +127,17 @@ 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>  \n>  \tfree(tracking.src);\n> -\treturn 0;\n>  }\n>  \n>  int read_branch_desc(struct strbuf *buf, const char *branch_name)\n> diff --git a/branch.h b/branch.h\n> index 58aa45f..8ce22f8 100644\n> --- a/branch.h\n> +++ b/branch.h\n> @@ -43,6 +43,7 @@ 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>   */\n>  #define BRANCH_CONFIG_VERBOSE 01\n>  extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n> diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\n> index 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"},{"id":"277276","messageId":"xmqqwpqmrfvo.fsf@gitster.mtv.corp.google.com","threadId":"41309","inReplyTo":"1454413916-31984-11-git-send-email-ps@pks.im","subject":"Re: [PATCH v4 10/15] clone: die on config error in cmd_clone","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-02T20:55:55Z","receivedAt":"2016-02-02T20:55: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> The clone command does not check for error codes returned by\n> `git_config_set` functions. This may cause the user to end up\n> with an inconsistent repository without any indication with what\n> went wrong.\n>\n> Fix this problem by dying with an error message when we are\n> unable to write the configuration files to disk.\n\nWhen this happens, the junk_mode is still JUNK_LEAVE_NONE, so upon\nhitting such an error, we'd remove everything and die.  And we\nhaven't wasted the effort for large object transfer yet.\n\nWhich all sounds sensible.\n\n> Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> ---\n>  builtin/clone.c | 8 ++++----\n>  1 file changed, 4 insertions(+), 4 deletions(-)\n>\n> diff --git a/builtin/clone.c b/builtin/clone.c\n> index 81e238f..f2a2f9a 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"},{"id":"277277","messageId":"xmqqpowerfr1.fsf@gitster.mtv.corp.google.com","threadId":"41309","inReplyTo":"1454413916-31984-1-git-send-email-ps@pks.im","subject":"Re: [PATCH v4 00/15] config: make git_config_set die on failure","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-02-02T20:58:42Z","receivedAt":"2016-02-02T20:58:42Z","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> Patrick Steinhardt (15):\n>   config: introduce set_or_die wrappers\n>   branch: die on error in setting up tracking branch\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\nThey mostly looked sensible; I commented on things that I noticed,\nbut I don't think I spotted anything that needs a huge fix.\n\nThanks.\n"},{"id":"277380","messageId":"20160204085654.GA11303@pks-pc.localdomain","threadId":"41309","inReplyTo":"xmqqpowerfr1.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4 00/15] config: make git_config_set die on failure","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-04T08:56:54Z","receivedAt":"2016-02-04T08:56:54Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Feb 02, 2016 at 12:58:42PM -0800, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > Patrick Steinhardt (15):\n> >   config: introduce set_or_die wrappers\n> >   branch: die on error in setting up tracking branch\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> They mostly looked sensible; I commented on things that I noticed,\n> but I don't think I spotted anything that needs a huge fix.\n> \n> Thanks.\n\nThanks for the feedback. Will post v5 next week.\n\nPatrick\n"},{"id":"277726","messageId":"20160208134232.GA697@pks-xps","threadId":"41309","inReplyTo":"xmqq60y6suqx.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v4 02/15] branch: die on error in setting up tracking branch","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-08T13:42:32Z","receivedAt":"2016-02-08T13:42:32Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Feb 02, 2016 at 12:49:26PM -0800, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > The setup_tracking function calls install_branch_config, which\n> > may fail writing the configuration due to a locked configuration\n> > file or other error conditions. setup_tracking can also fail when\n> > trying to track ambiguous information for a reference. While this\n> > condition is checked for and an error code is returned, this\n> > error is not checked by the caller.\n> >\n> > Fix both issues by dying early when error occur.\n> \n> Hmph.  I think create_branch() is written in such a way that all\n> die() come before the actual ref transaction attempts to create the\n> branch, but this change means that we have already created the\n> branch and then die without undoing the damage that is already done.\n> \n> \"The error is not checked by the caller\" is very true, but can the\n> caller do something better than just die?  I personally do not think\n> it is such a big deal if we just died here, but I may have overlooked\n> something.\n\nWell, when dying here we do not record the tracking branch\nconfiguration for the newly set up branch. This is the only thing\nthat we are missing as right after setting up the tracking branch\nwe've finished and exit the command.\n\nThat being said it's somewhat unfortunate to die here as the user\ncannot simply try to repeat creating a branch and hope it works\nthis time as the branch has already been created and the command\nwould error out. Maybe we should instead die with an improved\nerror message hinting the user how to fix the issue, something\nalong the lines of\n\n\"We were unable to set the remote tracking information for the\nnewly created branch due to <REASON>. After fixing the underlying\nproblem you may set the remote tracking branch by executing `git\nbranch --set-upstream-to=<BRANCH>.\"\n\n> > ---\n> >  branch.c          | 19 +++++++++----------\n> >  branch.h          |  1 +\n> >  t/t3200-branch.sh |  9 ++++++++-\n> >  3 files changed, 18 insertions(+), 11 deletions(-)\n> >\n> > diff --git a/branch.c b/branch.c\n> > index 7ff3f20..7106369 100644\n> > --- a/branch.c\n> > +++ b/branch.c\n> > @@ -64,16 +64,16 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n> >  \t}\n> >  \n> >  \tstrbuf_addf(&key, \"branch.%s.remote\", local);\n> > -\tgit_config_set(key.buf, origin ? origin : \".\");\n> > +\tgit_config_set_or_die(key.buf, origin ? origin : \".\");\n> >  \n> >  \tstrbuf_reset(&key);\n> >  \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n> > -\tgit_config_set(key.buf, remote);\n> > +\tgit_config_set_or_die(key.buf, remote);\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\tgit_config_set_or_die(key.buf, \"true\");\n> >  \t}\n> >  \tstrbuf_release(&key);\n> >  \n> > @@ -109,8 +109,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 +118,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 +127,17 @@ 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> >  \n> >  \tfree(tracking.src);\n> > -\treturn 0;\n> >  }\n> >  \n> >  int read_branch_desc(struct strbuf *buf, const char *branch_name)\n> > diff --git a/branch.h b/branch.h\n> > index 58aa45f..8ce22f8 100644\n> > --- a/branch.h\n> > +++ b/branch.h\n> > @@ -43,6 +43,7 @@ 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> >   */\n> >  #define BRANCH_CONFIG_VERBOSE 01\n> >  extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n> > diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\n> > index 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"},{"id":"277729","messageId":"20160208140348.GB697@pks-xps","threadId":"41309","inReplyTo":"20160208134232.GA697@pks-xps","subject":"Re: [PATCH v4 02/15] branch: die on error in setting up tracking branch","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-08T14:03:48Z","receivedAt":"2016-02-08T14:03:48Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Mon, Feb 08, 2016 at 02:42:32PM +0100, Patrick Steinhardt wrote:\n> On Tue, Feb 02, 2016 at 12:49:26PM -0800, Junio C Hamano wrote:\n> > Patrick Steinhardt <ps@pks.im> writes:\n> > \n> > > The setup_tracking function calls install_branch_config, which\n> > > may fail writing the configuration due to a locked configuration\n> > > file or other error conditions. setup_tracking can also fail when\n> > > trying to track ambiguous information for a reference. While this\n> > > condition is checked for and an error code is returned, this\n> > > error is not checked by the caller.\n> > >\n> > > Fix both issues by dying early when error occur.\n> > \n> > Hmph.  I think create_branch() is written in such a way that all\n> > die() come before the actual ref transaction attempts to create the\n> > branch, but this change means that we have already created the\n> > branch and then die without undoing the damage that is already done.\n> > \n> > \"The error is not checked by the caller\" is very true, but can the\n> > caller do something better than just die?  I personally do not think\n> > it is such a big deal if we just died here, but I may have overlooked\n> > something.\n\nHum. I've actually forgot about the function not being static. It\nis actually used in transport.c:transport_push() and\nbuiltin/clone.c.\n\nFor the clone command I do not regard it as important as on\nfailure the user can simply re-invoke the command and clone a new\ncopy. Sure, this may me inefficient for large repos, but it is\nstill far more sensible than leaving the user with an\ninconsistent repository.\n\nIn transport.c we skip updating local tracking refs when\nwe die. As such, we might leave refs that have been deleted on\nthe remote. I guess those cases are easy to fix when followed\nup with a fetch or `fetch --prune`.\n\nAs said before, if we want to improve the just-die case we might\npropose how the user may fix up his repository afterwards.\n\n> \n> Well, when dying here we do not record the tracking branch\n> configuration for the newly set up branch. This is the only thing\n> that we are missing as right after setting up the tracking branch\n> we've finished and exit the command.\n> \n> That being said it's somewhat unfortunate to die here as the user\n> cannot simply try to repeat creating a branch and hope it works\n> this time as the branch has already been created and the command\n> would error out. Maybe we should instead die with an improved\n> error message hinting the user how to fix the issue, something\n> along the lines of\n> \n> \"We were unable to set the remote tracking information for the\n> newly created branch due to <REASON>. After fixing the underlying\n> problem you may set the remote tracking branch by executing `git\n> branch --set-upstream-to=<BRANCH>.\"\n> \n> > > ---\n> > >  branch.c          | 19 +++++++++----------\n> > >  branch.h          |  1 +\n> > >  t/t3200-branch.sh |  9 ++++++++-\n> > >  3 files changed, 18 insertions(+), 11 deletions(-)\n> > >\n> > > diff --git a/branch.c b/branch.c\n> > > index 7ff3f20..7106369 100644\n> > > --- a/branch.c\n> > > +++ b/branch.c\n> > > @@ -64,16 +64,16 @@ void install_branch_config(int flag, const char *local, const char *origin, cons\n> > >  \t}\n> > >  \n> > >  \tstrbuf_addf(&key, \"branch.%s.remote\", local);\n> > > -\tgit_config_set(key.buf, origin ? origin : \".\");\n> > > +\tgit_config_set_or_die(key.buf, origin ? origin : \".\");\n> > >  \n> > >  \tstrbuf_reset(&key);\n> > >  \tstrbuf_addf(&key, \"branch.%s.merge\", local);\n> > > -\tgit_config_set(key.buf, remote);\n> > > +\tgit_config_set_or_die(key.buf, remote);\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\tgit_config_set_or_die(key.buf, \"true\");\n> > >  \t}\n> > >  \tstrbuf_release(&key);\n> > >  \n> > > @@ -109,8 +109,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 +118,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 +127,17 @@ 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> > >  \n> > >  \tfree(tracking.src);\n> > > -\treturn 0;\n> > >  }\n> > >  \n> > >  int read_branch_desc(struct strbuf *buf, const char *branch_name)\n> > > diff --git a/branch.h b/branch.h\n> > > index 58aa45f..8ce22f8 100644\n> > > --- a/branch.h\n> > > +++ b/branch.h\n> > > @@ -43,6 +43,7 @@ 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> > >   */\n> > >  #define BRANCH_CONFIG_VERBOSE 01\n> > >  extern void install_branch_config(int flag, const char *local, const char *origin, const char *remote);\n> > > diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\n> > > index 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\n"},{"id":"277730","messageId":"20160208140551.GC697@pks-xps","threadId":"41309","inReplyTo":"CAPig+cSLoXGHFXm96dpfjmkZkpXOFezEFZek-Jry85XkCwOsWA@mail.gmail.com","subject":"Re: [PATCH v4 06/15] submodule--helper: die on config error when cloning module","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2016-02-08T14:05:51Z","receivedAt":"2016-02-08T14:05:51Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Feb 02, 2016 at 01:45:50PM -0500, Eric Sunshine wrote:\n> On Tue, Feb 2, 2016 at 6:51 AM, Patrick Steinhardt <ps@pks.im> wrote:\n> > When setting the 'core.worktree' option for a newly cloned\n> > submodule we ignore the return value of `git_config_set_in_file`.\n> > As this leaves the submodule in an inconsistent state, we instaed\n> > we want to inform the user that something has gone wrong by\n> \n> s/instaed/instead/\n> \n> Also, there are too many \"we\"s, so dropping one would be a good idea:\n> either \"we instead\" or \"instead we\".\n> \n> > printing an error and aborting the program.\n> >\n> > Signed-off-by: Patrick Steinhardt <ps@pks.im>\n\nThanks, fixed now.\n"}]}