aboutsummaryrefslogtreecommitdiff
path: root/builtin/checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-12-13 22:53:08 -0800
committerJunio C Hamano <gitster@pobox.com>2011-12-13 22:53:08 -0800
commitb2dd02112052aff875e8dc7d12b9915c91feafe2 (patch)
tree575640076625dbc13dd950e78f8c0ab5f23e2b06 /builtin/checkout.c
parenta96a89f7153150c7e59d5481dd22773173b5a877 (diff)
parent39bd6f726109942c6f77f59638f6763c9f00706c (diff)
downloadgit-b2dd02112052aff875e8dc7d12b9915c91feafe2.tar.gz
git-b2dd02112052aff875e8dc7d12b9915c91feafe2.tar.xz
Merge branch 'jn/branch-move-to-self'
* jn/branch-move-to-self: Allow checkout -B <current-branch> to update the current branch branch: allow a no-op "branch -M <current-branch> HEAD"
Diffstat (limited to 'builtin/checkout.c')
-rw-r--r--builtin/checkout.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/builtin/checkout.c b/builtin/checkout.c
index b7c630287..3f5d9b629 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -540,7 +540,9 @@ static void update_refs_for_switch(struct checkout_opts *opts,
else
create_branch(old->name, opts->new_branch, new->name,
opts->new_branch_force ? 1 : 0,
- opts->new_branch_log, opts->track);
+ opts->new_branch_log,
+ opts->new_branch_force ? 1 : 0,
+ opts->track);
new->name = opts->new_branch;
setup_branch_path(new);
}
@@ -565,8 +567,12 @@ static void update_refs_for_switch(struct checkout_opts *opts,
create_symref("HEAD", new->path, msg.buf);
if (!opts->quiet) {
if (old->path && !strcmp(new->path, old->path)) {
- fprintf(stderr, _("Already on '%s'\n"),
- new->name);
+ if (opts->new_branch_force)
+ fprintf(stderr, _("Reset branch '%s'\n"),
+ new->name);
+ else
+ fprintf(stderr, _("Already on '%s'\n"),
+ new->name);
} else if (opts->new_branch) {
if (opts->branch_exists)
fprintf(stderr, _("Switched to and reset branch '%s'\n"), new->name);
@@ -1059,7 +1065,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
struct strbuf buf = STRBUF_INIT;
opts.branch_exists = validate_new_branchname(opts.new_branch, &buf,
- !!opts.new_branch_force, 0);
+ !!opts.new_branch_force,
+ !!opts.new_branch_force);
strbuf_release(&buf);
}