t5516: fix test order flakiness
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>
Derrick Stolee committed
May 19, 2026 at 16:24 UTC
4e5b2a37956f40acd016f078b1e9a883e97a9f27
1 file changed
+1
-1
t/t5516-fetch-push.sh
+1
-1
@@ -1349,7 +1349,7 @@ test_expect_success 'fetch follows tags by default' '
1349
git for-each-ref >tmp1 &&
1350
sed -n "p; s|refs/heads/main$|refs/remotes/origin/main|p" tmp1 |
1351
sed -n "p; s|refs/heads/main$|refs/remotes/origin/HEAD|p" |
1352
- sort -k 4 >../expect
1352
+ sort -k 3 >../expect
1353
) &&
1354
test_when_finished "rm -rf dst" &&
1355
git init dst &&