summaryrefslogtreecommitdiff
path: root/builtin-branch.c
diff options
context:
space:
mode:
authorLars Hjemli <hjemli@gmail.com>2007-04-06 14:13:00 +0200
committerJunio C Hamano <junkio@cox.net>2007-04-06 16:54:39 -0700
commit19eba1515a7d3b0dac6d4ee73492d978c3c2149b (patch)
tree467d51b8c8154cf6b8fcbbad40001f42ea833cb8 /builtin-branch.c
parentd26f9fef470443dfb0d09c08341634208f4fb6f7 (diff)
downloadgit-19eba1515a7d3b0dac6d4ee73492d978c3c2149b.tar.gz
Make builtin-branch.c handle the git config file
This moves the knowledge about .git/config usage out of refs.c and into builtin-branch.c instead, which allows git-branch to update HEAD to point at the moved branch before attempting to update the config file. It also allows git-branch to exit with an error code if updating the config file should fail. Signed-off-by: Lars Hjemli <hjemli@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-branch.c')
-rw-r--r--builtin-branch.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/builtin-branch.c b/builtin-branch.c
index a4494ee337..7408285050 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -493,6 +493,7 @@ static void rename_branch(const char *oldname, const char *newname, int force)
{
char oldref[PATH_MAX], newref[PATH_MAX], logmsg[PATH_MAX*2 + 100];
unsigned char sha1[20];
+ char oldsection[PATH_MAX], newsection[PATH_MAX];
if (!oldname)
die("cannot rename the current branch while not on any.");
@@ -521,6 +522,11 @@ static void rename_branch(const char *oldname, const char *newname, int force)
/* no need to pass logmsg here as HEAD didn't really move */
if (!strcmp(oldname, head) && create_symref("HEAD", newref, NULL))
die("Branch renamed to %s, but HEAD is not updated!", newname);
+
+ snprintf(oldsection, sizeof(oldsection), "branch.%s", oldref + 11);
+ snprintf(newsection, sizeof(newsection), "branch.%s", newref + 11);
+ if (git_config_rename_section(oldsection, newsection) < 0)
+ die("Branch is renamed, but update of config-file failed");
}
int cmd_branch(int argc, const char **argv, const char *prefix)