diff options
author | Junio C Hamano <junkio@cox.net> | 2007-02-03 22:14:40 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-02-03 23:05:34 -0800 |
commit | d77ee72662a821d66ae218056f0103eb24d8d4b4 (patch) | |
tree | e22abdbd11735a0669362f934ae723d233c87e2b /builtin-branch.c | |
parent | eb8381c88518b10d683a29deea1d43ed671f14ec (diff) | |
parent | 8d0fc48f27304ac1bc7abf802ec53fe66fedb15a (diff) | |
download | git-d77ee72662a821d66ae218056f0103eb24d8d4b4.tar.gz |
Merge branch 'master' into np/dreflog
This is to resolve conflicts early in preparation for possible
inclusion of "reflog on detached HEAD" series by Nico, as having
it in 1.5.0 would really help us remove confusion between
detached and attached states.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-branch.c')
-rw-r--r-- | builtin-branch.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/builtin-branch.c b/builtin-branch.c index 76f174fd89..2d8d61b453 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -316,6 +316,7 @@ static void create_branch(const char *name, const char *start_name, struct commit *commit; unsigned char sha1[20]; char ref[PATH_MAX], msg[PATH_MAX + 20]; + int forcing = 0; snprintf(ref, sizeof ref, "refs/heads/%s", name); if (check_ref_format(ref)) @@ -326,6 +327,7 @@ static void create_branch(const char *name, const char *start_name, die("A branch named '%s' already exists.", name); else if (!is_bare_repository() && !strcmp(head, name)) die("Cannot force update the current branch."); + forcing = 1; } if (start_sha1) @@ -342,11 +344,15 @@ static void create_branch(const char *name, const char *start_name, if (!lock) die("Failed to lock ref for update: %s.", strerror(errno)); - if (reflog) { + if (reflog) log_all_ref_updates = 1; + + if (forcing) + snprintf(msg, sizeof msg, "branch: Reset from %s", + start_name); + else snprintf(msg, sizeof msg, "branch: Created from %s", start_name); - } if (write_ref_sha1(lock, sha1, msg) < 0) die("Failed to write ref: %s.", strerror(errno)); @@ -358,7 +364,7 @@ static void rename_branch(const char *oldname, const char *newname, int force) unsigned char sha1[20]; if (!oldname) - die("cannot rename the curren branch while not on any."); + die("cannot rename the current branch while not on any."); if (snprintf(oldref, sizeof(oldref), "refs/heads/%s", oldname) > sizeof(oldref)) die("Old branchname too long"); |