From: Sahil Dua Date: Wed, 31 May 2017 23:35:12 GMT Subject: [PATCH/RFC v2 6/6] branch: don't copy or rename config when same branch name Message-ID: <0102015c60dcf6cf-b17cfda3-0d72-4271-a5ba-63e5db0af952-000000@eu-west-1.amazonses.com> In-Reply-To: <0102015c60dcf5f6-057de56f-3355-40dc-a0d3-ee62fa9b8259-000000@eu-west-1.amazonses.com> It doesn't make sense to trigger config section copy or rename method if both the branch names are same. For example - git branch -C a a In such a case, it shouldn't try to copy or rename the git config section. Signed-off-by: Sahil Dua --- builtin/branch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/branch.c b/builtin/branch.c index f3cd180e8d4cb..df82f196a4bba 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -502,7 +502,7 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int strbuf_release(&oldref); strbuf_addf(&newsection, "branch.%s", newref.buf + 11); strbuf_release(&newref); - if (git_config_copy_or_rename_section(oldsection.buf, newsection.buf, copy) < 0) + if (strcmp(oldname, newname) && git_config_copy_or_rename_section(oldsection.buf, newsection.buf, copy) < 0) die(_("Branch is %s, but update of config-file failed"), (copy ? "copied" : "renamed")); strbuf_release(&oldsection); -- https://github.com/git/git/pull/363