summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d26f9fe)
raw | patch | inline | side by side (parent: d26f9fe)
author | Lars Hjemli <hjemli@gmail.com> | |
Fri, 6 Apr 2007 12:13:00 +0000 (14:13 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 6 Apr 2007 23:54:39 +0000 (16:54 -0700) |
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>
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>
builtin-branch.c | patch | blob | history | |
refs.c | patch | blob | history |
diff --git a/builtin-branch.c b/builtin-branch.c
index a4494ee337d70a400664e529e84f90d475a03b92..7408285050a0f41a33d31c73e79c2fdefe567593 100644 (file)
--- a/builtin-branch.c
+++ b/builtin-branch.c
{
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.");
/* 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)
index 2ac6384949636d67ebb5284a113c4137b402556a..d2b7b7fb56f76294bb48526496429968d86e49b2 100644 (file)
--- a/refs.c
+++ b/refs.c
goto rollback;
}
- if (!prefixcmp(oldref, "refs/heads/") &&
- !prefixcmp(newref, "refs/heads/")) {
- char oldsection[1024], newsection[1024];
-
- snprintf(oldsection, 1024, "branch.%s", oldref + 11);
- snprintf(newsection, 1024, "branch.%s", newref + 11);
- if (git_config_rename_section(oldsection, newsection) < 0)
- error("unable to update config-file");
- }
-
return 0;
rollback: