Merge branch 'jx/branch-vv-always-compare-with-upstream'
"git branch -v -v" (and "git status") did not distinguish among a branch that does not build on any other branch, a branch that is in sync with the branch it builds on, and a branch that is configured to build on some other branch that no longer exists. * jx/branch-vv-always-compare-with-upstream: status: always show tracking branch even no change branch: report invalid tracking branch as gone
This commit is contained in:
@ -423,19 +423,19 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
|
||||
char *ref = NULL;
|
||||
struct branch *branch = branch_get(branch_name);
|
||||
struct strbuf fancy = STRBUF_INIT;
|
||||
int upstream_is_gone = 0;
|
||||
|
||||
if (!stat_tracking_info(branch, &ours, &theirs)) {
|
||||
if (branch && branch->merge && branch->merge[0]->dst &&
|
||||
show_upstream_ref) {
|
||||
ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
|
||||
if (want_color(branch_use_color))
|
||||
strbuf_addf(stat, "[%s%s%s] ",
|
||||
branch_get_color(BRANCH_COLOR_UPSTREAM),
|
||||
ref, branch_get_color(BRANCH_COLOR_RESET));
|
||||
else
|
||||
strbuf_addf(stat, "[%s] ", ref);
|
||||
}
|
||||
switch (stat_tracking_info(branch, &ours, &theirs)) {
|
||||
case 0:
|
||||
/* no base */
|
||||
return;
|
||||
case -1:
|
||||
/* with "gone" base */
|
||||
upstream_is_gone = 1;
|
||||
break;
|
||||
default:
|
||||
/* with base */
|
||||
break;
|
||||
}
|
||||
|
||||
if (show_upstream_ref) {
|
||||
@ -448,19 +448,25 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
|
||||
strbuf_addstr(&fancy, ref);
|
||||
}
|
||||
|
||||
if (!ours) {
|
||||
if (ref)
|
||||
if (upstream_is_gone) {
|
||||
if (show_upstream_ref)
|
||||
strbuf_addf(stat, _("[%s: gone]"), fancy.buf);
|
||||
} else if (!ours && !theirs) {
|
||||
if (show_upstream_ref)
|
||||
strbuf_addf(stat, _("[%s]"), fancy.buf);
|
||||
} else if (!ours) {
|
||||
if (show_upstream_ref)
|
||||
strbuf_addf(stat, _("[%s: behind %d]"), fancy.buf, theirs);
|
||||
else
|
||||
strbuf_addf(stat, _("[behind %d]"), theirs);
|
||||
|
||||
} else if (!theirs) {
|
||||
if (ref)
|
||||
if (show_upstream_ref)
|
||||
strbuf_addf(stat, _("[%s: ahead %d]"), fancy.buf, ours);
|
||||
else
|
||||
strbuf_addf(stat, _("[ahead %d]"), ours);
|
||||
} else {
|
||||
if (ref)
|
||||
if (show_upstream_ref)
|
||||
strbuf_addf(stat, _("[%s: ahead %d, behind %d]"),
|
||||
fancy.buf, ours, theirs);
|
||||
else
|
||||
|
Reference in New Issue
Block a user