Skip to content

Commit

Permalink
Merge branch 'jx/branch-vv-always-compare-with-upstream'
Browse files Browse the repository at this point in the history
Hot-fix for a regression.

* jx/branch-vv-always-compare-with-upstream:
  branch: fix --verbose output column alignment
  • Loading branch information
Junio C Hamano committed Nov 18, 2013
2 parents 0397305 + 6b364d4 commit ab930f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
8 changes: 7 additions & 1 deletion builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
struct branch *branch = branch_get(branch_name);
struct strbuf fancy = STRBUF_INIT;
int upstream_is_gone = 0;
int added_decoration = 1;

switch (stat_tracking_info(branch, &ours, &theirs)) {
case 0:
Expand Down Expand Up @@ -451,9 +452,13 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
if (upstream_is_gone) {
if (show_upstream_ref)
strbuf_addf(stat, _("[%s: gone]"), fancy.buf);
else
added_decoration = 0;
} else if (!ours && !theirs) {
if (show_upstream_ref)
strbuf_addf(stat, _("[%s]"), fancy.buf);
else
added_decoration = 0;
} else if (!ours) {
if (show_upstream_ref)
strbuf_addf(stat, _("[%s: behind %d]"), fancy.buf, theirs);
Expand All @@ -474,7 +479,8 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
ours, theirs);
}
strbuf_release(&fancy);
strbuf_addch(stat, ' ');
if (added_decoration)
strbuf_addch(stat, ' ');
free(ref);
}

Expand Down
24 changes: 13 additions & 11 deletions t/t6040-tracking-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ test_expect_success setup '
advance h
'

script='s/^..\(b.\)[ 0-9a-f]*\[\([^]]*\)\].*/\1 \2/p'
script='s/^..\(b.\) *[0-9a-f]* \(.*\)$/\1 \2/p'
cat >expect <<\EOF
b1 ahead 1, behind 1
b2 ahead 1, behind 1
b3 behind 1
b4 ahead 2
b1 [ahead 1, behind 1] d
b2 [ahead 1, behind 1] d
b3 [behind 1] b
b4 [ahead 2] f
b5 g
b6 c
EOF

test_expect_success 'branch -v' '
Expand All @@ -57,12 +59,12 @@ test_expect_success 'branch -v' '
'

cat >expect <<\EOF
b1 origin/master: ahead 1, behind 1
b2 origin/master: ahead 1, behind 1
b3 origin/master: behind 1
b4 origin/master: ahead 2
b5 brokenbase: gone
b6 origin/master
b1 [origin/master: ahead 1, behind 1] d
b2 [origin/master: ahead 1, behind 1] d
b3 [origin/master: behind 1] b
b4 [origin/master: ahead 2] f
b5 [brokenbase: gone] g
b6 [origin/master] c
EOF

test_expect_success 'branch -vv' '
Expand Down

0 comments on commit ab930f0

Please sign in to comment.