Skip to content

Commit 2c6fc31

Browse files
peffgitster
authored andcommitted
t5551: handle trailing slashes in expected cookies output
We check in t5551 that curl updates the expected list of cookies after making a request. We do this by telling it to read and write cookies from a particular text file, and then checking that after curl runs, the file has the expected content. However, in the upcoming curl 8.18.0, the output file has changed slightly: curl will canonicalize the paths it writes, due to commit a093c93994 (cookie: only keep and use the canonical cleaned up path, 2025-12-07). In particular, it strips trailing slashes from the paths we see in the cookies.txt file. This doesn't matter to Git, as the cookie handling is all internal to curl. But our test is overly brittle and breaks as a result. We can fix it by matching either format. We'll expect the new format (without trailing slashes) and strip the slashes from curl's output before comparing. That lets us pass with both old and new versions (I tested against curl's 8_17_0 and rc-8_18_0-2 tags, which are respectively before and after the curl change). In theory it might be nice to try to future-proof this test more by looking only for the bits we care about, rather than a byte-wise comparison of the whole file. But after removing comments and blank lines (which we already do), we care about most of what's there. So it's not clear to me what a more liberal test would look like. Given that the format doesn't change all that often, it's probably OK to stop here and see if it ever breaks again. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 9a2fb14 commit 2c6fc31

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

t/t5551-http-fetch-smart.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,12 @@ test_expect_success 'dumb clone via http-backend respects namespace' '
333333

334334
test_expect_success 'cookies stored in http.cookiefile when http.savecookies set' '
335335
cat >cookies.txt <<-\EOF &&
336-
127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue
336+
127.0.0.1 FALSE /smart_cookies FALSE 0 othername othervalue
337337
EOF
338338
sort >expect_cookies.txt <<-\EOF &&
339-
127.0.0.1 FALSE /smart_cookies/ FALSE 0 othername othervalue
340-
127.0.0.1 FALSE /smart_cookies/repo.git/ FALSE 0 name value
341-
127.0.0.1 FALSE /smart_cookies/repo.git/info/ FALSE 0 name value
339+
127.0.0.1 FALSE /smart_cookies FALSE 0 othername othervalue
340+
127.0.0.1 FALSE /smart_cookies/repo.git FALSE 0 name value
341+
127.0.0.1 FALSE /smart_cookies/repo.git/info FALSE 0 name value
342342
EOF
343343
git config http.cookiefile cookies.txt &&
344344
git config http.savecookies true &&
@@ -351,8 +351,11 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
351351
tag -m "foo" cookie-tag &&
352352
git fetch $HTTPD_URL/smart_cookies/repo.git cookie-tag &&
353353
354-
grep "^[^#]" cookies.txt | sort >cookies_stripped.txt &&
355-
test_cmp expect_cookies.txt cookies_stripped.txt
354+
# Strip trailing slashes from cookie paths to handle output from both
355+
# old curl ("/smart_cookies/") and new ("/smart_cookies").
356+
HT=" " &&
357+
grep "^[^#]" cookies.txt | sed "s,/$HT,$HT," | sort >cookies_clean.txt &&
358+
test_cmp expect_cookies.txt cookies_clean.txt
356359
'
357360

358361
test_expect_success 'transfer.hiderefs works over smart-http' '

0 commit comments

Comments
 (0)