提交 401a317a 编写于 作者: J Junio C Hamano

Merge branch 'rc/for-each-ref-tracking'

* rc/for-each-ref-tracking:
  for-each-ref: always check stat_tracking_info()'s return value
...@@ -717,7 +717,10 @@ static void populate_value(struct refinfo *ref) ...@@ -717,7 +717,10 @@ static void populate_value(struct refinfo *ref)
starts_with(name, "upstream")) { starts_with(name, "upstream")) {
char buf[40]; char buf[40];
stat_tracking_info(branch, &num_ours, &num_theirs); if (stat_tracking_info(branch, &num_ours,
&num_theirs) != 1)
continue;
if (!num_ours && !num_theirs) if (!num_ours && !num_theirs)
v->s = ""; v->s = "";
else if (!num_ours) { else if (!num_ours) {
...@@ -735,7 +738,11 @@ static void populate_value(struct refinfo *ref) ...@@ -735,7 +738,11 @@ static void populate_value(struct refinfo *ref)
} else if (!strcmp(formatp, "trackshort") && } else if (!strcmp(formatp, "trackshort") &&
starts_with(name, "upstream")) { starts_with(name, "upstream")) {
assert(branch); assert(branch);
stat_tracking_info(branch, &num_ours, &num_theirs);
if (stat_tracking_info(branch, &num_ours,
&num_theirs) != 1)
continue;
if (!num_ours && !num_theirs) if (!num_ours && !num_theirs)
v->s = "="; v->s = "=";
else if (!num_ours) else if (!num_ours)
......
...@@ -334,6 +334,19 @@ test_expect_success 'Check that :track[short] cannot be used with other atoms' ' ...@@ -334,6 +334,19 @@ test_expect_success 'Check that :track[short] cannot be used with other atoms' '
test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null test_must_fail git for-each-ref --format="%(refname:trackshort)" 2>/dev/null
' '
test_expect_success 'Check that :track[short] works when upstream is invalid' '
cat >expected <<-\EOF &&
EOF
test_when_finished "git config branch.master.merge refs/heads/master" &&
git config branch.master.merge refs/heads/does-not-exist &&
git for-each-ref \
--format="%(upstream:track)$LF%(upstream:trackshort)" \
refs/heads >actual &&
test_cmp expected actual
'
cat >expected <<EOF cat >expected <<EOF
$(git rev-parse --short HEAD) $(git rev-parse --short HEAD)
EOF EOF
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册