summaryrefslogtreecommitdiff
path: root/builtin-checkout.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-02-20 19:42:53 -0800
committerJunio C Hamano <gitster@pobox.com>2008-02-21 15:46:05 -0800
commitb56fca07d2bac20339d59218ab98de38a9363e77 (patch)
treefc2c0a0703a248e8702f30c9153309d100a2cb29 /builtin-checkout.c
parent75ea38df66910dcb9d09f1320ae2787b5bc8211e (diff)
downloadgit-b56fca07d2bac20339d59218ab98de38a9363e77.tar.gz
checkout: updates to tracking report
Ask branch_get() for the new branch explicitly instead of letting it return a potentially stale information. Tighten the logic to find the tracking branch to deal better with misconfigured repositories (i.e. branch.*.merge can exist but it may not have a refspec that fetches to .it) Also fixes grammar in a message, as pointed out by Jeff King. The function is about reporting and not automatically fast-forwarding to the upstream, so stop calling it "adjust-to". Signed-off-by: Junio C Hamano <gitster@pobox.com> Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Diffstat (limited to 'builtin-checkout.c')
-rw-r--r--builtin-checkout.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/builtin-checkout.c b/builtin-checkout.c
index e89b8f8ee0..5f176c6c38 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -289,7 +289,7 @@ static int merge_working_tree(struct checkout_opts *opts,
return 0;
}
-static void adjust_to_tracking(struct branch_info *new, struct checkout_opts *opts)
+static void report_tracking(struct branch_info *new, struct checkout_opts *opts)
{
/*
* We have switched to a new branch; is it building on
@@ -305,13 +305,13 @@ static void adjust_to_tracking(struct branch_info *new, struct checkout_opts *op
int rev_argc;
int num_ours, num_theirs;
const char *remote_msg;
- struct branch *branch = branch_get(NULL);
+ struct branch *branch = branch_get(new->name);
/*
* Nothing to report unless we are marked to build on top of
* somebody else.
*/
- if (!branch || !branch->merge)
+ if (!branch || !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)
return;
/*
@@ -369,7 +369,7 @@ static void adjust_to_tracking(struct branch_info *new, struct checkout_opts *op
remote_msg, base,
num_ours, (num_ours == 1) ? "" : "s");
else if (!num_ours)
- printf("Your branch is behind of the tracked%s branch '%s' "
+ printf("Your branch is behind the tracked%s branch '%s' "
"by %d commit%s,\n"
"and can be fast-forwarded.\n",
remote_msg, base,
@@ -425,7 +425,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,
remove_branch_state();
strbuf_release(&msg);
if (!opts->quiet && (new->path || !strcmp(new->name, "HEAD")))
- adjust_to_tracking(new, opts);
+ report_tracking(new, opts);
}
static int switch_branches(struct checkout_opts *opts, struct branch_info *new)