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)
717
717
starts_with (name , "upstream" )) {
718
718
char buf [40 ];
719
719
720
- stat_tracking_info (branch , & num_ours , & num_theirs );
720
+ if (stat_tracking_info (branch , & num_ours ,
721
+ & num_theirs ) != 1 )
722
+ continue ;
723
+
721
724
if (!num_ours && !num_theirs )
722
725
v -> s = "" ;
723
726
else if (!num_ours ) {
@@ -735,7 +738,11 @@ static void populate_value(struct refinfo *ref)
735
738
} else if (!strcmp (formatp , "trackshort" ) &&
736
739
starts_with (name , "upstream" )) {
737
740
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
+
739
746
if (!num_ours && !num_theirs )
740
747
v -> s = "=" ;
741
748
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' '
334
334
test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null
335
335
'
336
336
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
+
337
350
cat > expected << EOF
338
351
$( git rev-parse --short HEAD)
339
352
EOF
You can’t perform that action at this time.
0 commit comments