rev-parse: don't trim bisect refnames
Using for_each_ref_in() with a full refname has always been a questionable practice, but it became an error with b9c8e7f2fb (prefix_ref_iterator: don't trim too much, 2017-05-22), making "git rev-parse --bisect" pretty reliably show a BUG. Commit 03df567fbf (for_each_bisect_ref(): don't trim refnames, 2017-06-18) fixed this case for revision.c, but rev-parse handles this option on its own. We can use the same solution here (and piggy-back on its test). Signed-off-by: Jeff King <peff@peff.net> Acked-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Sep 6, 2017 at 07:53 UTC
1d0538e4860f3827bb711a4a05dbc2f194f767be
2 files changed
+18
-4
builtin/rev-parse.c
+2
-2
@@ -756,8 +756,8 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
756
continue;
757
}
758
if (!strcmp(arg, "--bisect")) {
759
- for_each_ref_in("refs/bisect/bad", show_reference, NULL);
760
- for_each_ref_in("refs/bisect/good", anti_reference, NULL);
759
+ for_each_fullref_in("refs/bisect/bad", show_reference, NULL, 0);
760
+ for_each_fullref_in("refs/bisect/good", anti_reference, NULL, 0);
761
continue;
762
}
763
if (opt_with_value(arg, "--branches", &arg)) {
t/t6002-rev-list-bisect.sh
+16
-2
@@ -236,17 +236,31 @@ test_sequence "--bisect"
236
#
237
#
238
239
-test_expect_success '--bisect can default to good/bad refs' '
239
+test_expect_success 'set up fake --bisect refs' '
240
git update-ref refs/bisect/bad c3 &&
241
good=$(git rev-parse b1) &&
242
git update-ref refs/bisect/good-$good $good &&
243
good=$(git rev-parse c1) &&
244
- git update-ref refs/bisect/good-$good $good &&
244
+ git update-ref refs/bisect/good-$good $good
245
+'
246
247
+test_expect_success 'rev-list --bisect can default to good/bad refs' '
248
# the only thing between c3 and c1 is c2
249
git rev-parse c2 >expect &&
250
git rev-list --bisect >actual &&
251
test_cmp expect actual
252
'
253
254
+test_expect_success 'rev-parse --bisect can default to good/bad refs' '
255
+ git rev-parse c3 ^b1 ^c1 >expect &&
256
+ git rev-parse --bisect >actual &&
257
+
258
+ # output order depends on the refnames, which in turn depends on
259
+ # the exact sha1s. We just want to make sure we have the same set
260
+ # of lines in any order.
261
+ sort <expect >expect.sorted &&
262
+ sort <actual >actual.sorted &&
263
+ test_cmp expect.sorted actual.sorted
264
+'
265
+
266
test_done