Re: [PATCH] fetch: when deepening, check connectivity fully
From: Junio C Hamano <hidden>
Date: 2018-06-27 20:17:41
Jonathan Tan [off-list ref] writes:
+test_expect_success 'shallow fetches check connectivity without stopping at existing refs' ' + cp -R .git server.git && + + # Normally, the connectivity check stops at ancestors of existing refs. + git init client && + GIT_TRACE="$(pwd)/trace" git -C client fetch "$(pwd)/server.git" && + grep "run_command: git rev-list" trace >rev-list-command && + grep -e "--not --all" rev-list-command && + + # But it does not for a shallow fetch... + rm -rf client trace && + git init client && + GIT_TRACE="$(pwd)/trace" git -C client fetch --depth=1 "$(pwd)/server.git" && + grep "run_command: git rev-list" trace >rev-list-command && + ! grep -e "--not --all" rev-list-command && + + # ...and when deepening. + rm trace && + GIT_TRACE="$(pwd)/trace" git -C client fetch --unshallow "$(pwd)/server.git" && + grep "run_command: git rev-list" trace >rev-list-command && + ! grep -e "--not --all" rev-list-command +'
Hmph, don't we quote these in the trace output, requiring us to grep for "'--not' '--all'" or somesuch? I do not think of a better way to do the above without a huge effort offhand, and the approach taken by the above may be the best we could do, but it looks like quite a brittle test that knows too much about the current implementation. "rev-list $new_commits --not --all" is a so very common and useful pattern that it is not all that implausible that we may want to come up with a new option to do so, or more likely we may want to do that with an in-process API without spawning an external rev-list (hence making it impossible to observe via GIT_TRACE).