Skip to content

Commit 64af775

Browse files
bk2204gitster
authored andcommitted
t1405: sort reflog entries in a hash-independent way
The test enumerates reflog entries in an arbitrary order and then sorts them. For SHA-1, this produces results that happen to sort in alphabetical order, but for other hash algorithms they sort differently. Ensure we sort the reflog entries in a hash-independent way by sorting on the ref name instead of the object ID. Remove an assumption about the length of a hash by using cut with the delimiter and field options instead of the character range option. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0dc3ad9 commit 64af775

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

t/t1405-main-ref-store.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test_expect_success 'rename_refs(master, new-master)' '
4545
'
4646

4747
test_expect_success 'for_each_ref(refs/heads/)' '
48-
$RUN for-each-ref refs/heads/ | cut -c 42- >actual &&
48+
$RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
4949
cat >expected <<-\EOF &&
5050
master 0x0
5151
new-master 0x0
@@ -71,7 +71,7 @@ test_expect_success 'verify_ref(new-master)' '
7171
'
7272

7373
test_expect_success 'for_each_reflog()' '
74-
$RUN for-each-reflog | sort | cut -c 42- >actual &&
74+
$RUN for-each-reflog | sort -k2 | cut -c 42- >actual &&
7575
cat >expected <<-\EOF &&
7676
HEAD 0x1
7777
refs/heads/master 0x0

0 commit comments

Comments
 (0)