summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 505739f)
raw | patch | inline | side by side (parent: 505739f)
author | Junio C Hamano <junkio@cox.net> | |
Fri, 19 Jan 2007 19:51:29 +0000 (11:51 -0800) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sat, 3 Feb 2007 20:54:49 +0000 (12:54 -0800) |
Even when -l is not given from the command line, the repository
may have the configuration variable core.logallrefupdates set,
or an old-timer might have done ": >.git/logs/refs/heads/new"
before running "git branch new". In these cases, the code gave
an uninitialized msg[] from the stack to be written out as the
reflog message.
This also passes a different message when '-f' option is used.
Saying "git branch -f branch some-commit" is a moral equilvalent
of doing "git-reset some-commit" while on the branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
may have the configuration variable core.logallrefupdates set,
or an old-timer might have done ": >.git/logs/refs/heads/new"
before running "git branch new". In these cases, the code gave
an uninitialized msg[] from the stack to be written out as the
reflog message.
This also passes a different message when '-f' option is used.
Saying "git branch -f branch some-commit" is a moral equilvalent
of doing "git-reset some-commit" while on the branch.
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-branch.c | patch | blob | history |
diff --git a/builtin-branch.c b/builtin-branch.c
index d60690bb084ef83ce99a56453ae9dfa56da12807..eaff54ec5f045c479fa08b9d2ba5d16a5e5dee47 100644 (file)
--- a/builtin-branch.c
+++ b/builtin-branch.c
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))
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)
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));