fetch: fetch objects by their exact SHA-1 object names
Teach "git fetch" to accept an exact SHA-1 object name the user may obtain out of band on the LHS of a pathspec, and send it on a "want" message when the server side advertises the allow-tip-sha1-in-want capability. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
@ -1064,4 +1064,38 @@ do
|
||||
'
|
||||
done
|
||||
|
||||
test_expect_success 'fetch exact SHA1' '
|
||||
mk_test heads/master hidden/one &&
|
||||
git push testrepo master:refs/hidden/one &&
|
||||
(
|
||||
cd testrepo &&
|
||||
git config transfer.hiderefs refs/hidden
|
||||
) &&
|
||||
check_push_result $the_commit hidden/one &&
|
||||
|
||||
mk_child child &&
|
||||
(
|
||||
cd child &&
|
||||
|
||||
# make sure $the_commit does not exist here
|
||||
git repack -a -d &&
|
||||
git prune &&
|
||||
test_must_fail git cat-file -t $the_commit &&
|
||||
|
||||
# fetching the hidden object should fail by default
|
||||
test_must_fail git fetch -v ../testrepo $the_commit:refs/heads/copy &&
|
||||
test_must_fail git rev-parse --verify refs/heads/copy &&
|
||||
|
||||
# the server side can allow it to succeed
|
||||
(
|
||||
cd ../testrepo &&
|
||||
git config uploadpack.allowtipsha1inwant true
|
||||
) &&
|
||||
|
||||
git fetch -v ../testrepo $the_commit:refs/heads/copy &&
|
||||
result=$(git rev-parse --verify refs/heads/copy) &&
|
||||
test "$the_commit" = "$result"
|
||||
)
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user