File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -717,7 +717,10 @@ static void populate_value(struct refinfo *ref)
717717 starts_with (name , "upstream" )) {
718718 char buf [40 ];
719719
720- stat_tracking_info (branch , & num_ours , & num_theirs );
720+ if (stat_tracking_info (branch , & num_ours ,
721+ & num_theirs ) != 1 )
722+ continue ;
723+
721724 if (!num_ours && !num_theirs )
722725 v -> s = "" ;
723726 else if (!num_ours ) {
@@ -735,7 +738,11 @@ static void populate_value(struct refinfo *ref)
735738 } else if (!strcmp (formatp , "trackshort" ) &&
736739 starts_with (name , "upstream" )) {
737740 assert (branch );
738- stat_tracking_info (branch , & num_ours , & num_theirs );
741+
742+ if (stat_tracking_info (branch , & num_ours ,
743+ & num_theirs ) != 1 )
744+ continue ;
745+
739746 if (!num_ours && !num_theirs )
740747 v -> s = "=" ;
741748 else if (!num_ours )
Original file line number Diff line number Diff line change @@ -334,6 +334,19 @@ test_expect_success 'Check that :track[short] cannot be used with other atoms' '
334334 test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null
335335'
336336
337+ test_expect_success ' Check that :track[short] works when upstream is invalid' '
338+ cat >expected <<-\EOF &&
339+
340+
341+ EOF
342+ test_when_finished "git config branch.master.merge refs/heads/master" &&
343+ git config branch.master.merge refs/heads/does-not-exist &&
344+ git for-each-ref \
345+ --format="%(upstream:track)$LF%(upstream:trackshort)" \
346+ refs/heads >actual &&
347+ test_cmp expected actual
348+ '
349+
337350cat > expected << EOF
338351$( git rev-parse --short HEAD)
339352EOF
You can’t perform that action at this time.
0 commit comments