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>
Junio C Hamano committed
Feb 20, 2008 at 19:42 UTC
b56fca07d2bac20339d59218ab98de38a9363e77
1 file changed
+5
-5
builtin-checkout.c
+5
-5
@@ -289,7 +289,7 @@ static int merge_working_tree(struct checkout_opts *opts,
289
return 0;
290
}
291
292
-static void adjust_to_tracking(struct branch_info *new, struct checkout_opts *opts)
292
+static void report_tracking(struct branch_info *new, struct checkout_opts *opts)
293
{
294
/*
295
* 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
305
int rev_argc;
306
int num_ours, num_theirs;
307
const char *remote_msg;
308
- struct branch *branch = branch_get(NULL);
308
+ struct branch *branch = branch_get(new->name);
309
310
/*
311
* Nothing to report unless we are marked to build on top of
312
* somebody else.
313
*/
314
- if (!branch || !branch->merge)
314
+ if (!branch || !branch->merge || !branch->merge[0] || !branch->merge[0]->dst)
315
return;
316
317
/*
@@ -369,7 +369,7 @@ static void adjust_to_tracking(struct branch_info *new, struct checkout_opts *op
369
remote_msg, base,
370
num_ours, (num_ours == 1) ? "" : "s");
371
else if (!num_ours)
372
- printf("Your branch is behind of the tracked%s branch '%s' "
372
+ printf("Your branch is behind the tracked%s branch '%s' "
373
"by %d commit%s,\n"
374
"and can be fast-forwarded.\n",
375
remote_msg, base,
@@ -425,7 +425,7 @@ static void update_refs_for_switch(struct checkout_opts *opts,
425
remove_branch_state();
426
strbuf_release(&msg);
427
if (!opts->quiet && (new->path || !strcmp(new->name, "HEAD")))
428
- adjust_to_tracking(new, opts);
428
+ report_tracking(new, opts);
429
}
430
431
static int switch_branches(struct checkout_opts *opts, struct branch_info *new)