]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t5516: fix test order flakiness
authorDerrick Stolee <stolee@gmail.com>
Tue, 19 May 2026 16:24:48 +0000 (16:24 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 May 2026 02:33:23 +0000 (11:33 +0900)
The 'fetch follows tags by default' test sorts using 'sort -k 4', but
for-each-ref output only has 3 columns. This relies on sort treating records
with fewer fields as having an empty fourth field, which may produce
unstable results depending on locale. This appears to be an accident added
in 3f763ddf28 (fetch: set remote/HEAD if it does not exist, 2024-11-22).

Use 'sort -k 3' to match the actual number of columns in the output.

Reviewed-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5516-fetch-push.sh

index 29e2f17608156127bc672374b6667d1bc010f353..ac8447f21ed9638f5f3724020a9ee6e517def848 100755 (executable)
@@ -1349,7 +1349,7 @@ test_expect_success 'fetch follows tags by default' '
                git for-each-ref >tmp1 &&
                sed -n "p; s|refs/heads/main$|refs/remotes/origin/main|p" tmp1 |
                sed -n "p; s|refs/heads/main$|refs/remotes/origin/HEAD|p"  |
-               sort -k 4 >../expect
+               sort -k 3 >../expect
        ) &&
        test_when_finished "rm -rf dst" &&
        git init dst &&