Skip to content

Commit

Permalink
Merge branch 'gf/fetch-pack-direct-object-fetch'
Browse files Browse the repository at this point in the history
Fetching of history by naming a commit object name directly didn't
work across remote-curl transport.

* gf/fetch-pack-direct-object-fetch:
  fetch-pack: update the documentation for "<refs>..." arguments
  fetch-pack: fix object_id of exact sha1
  • Loading branch information
Junio C Hamano committed Apr 3, 2016
2 parents d4a2230 + 754ecb1 commit 9081cff
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Documentation/git-fetch-pack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ be in a separate packet, and the list must end with a flush packet.
The remote heads to update from. This is relative to
$GIT_DIR (e.g. "HEAD", "refs/heads/master"). When
unspecified, update from all heads the remote side has.
+
If the remote has enabled the options `uploadpack.allowTipSHA1InWant` or
`uploadpack.allowReachableSHA1InWant`, they may alternatively be 40-hex
sha1s present on the remote.

SEE ALSO
--------
Expand Down
16 changes: 13 additions & 3 deletions builtin/fetch-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,20 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc,
struct ref *ref;
struct object_id oid;

if (!get_oid_hex(name, &oid) && name[GIT_SHA1_HEXSZ] == ' ')
name += GIT_SHA1_HEXSZ + 1;
else
if (!get_oid_hex(name, &oid)) {
if (name[GIT_SHA1_HEXSZ] == ' ') {
/* <sha1> <ref>, find refname */
name += GIT_SHA1_HEXSZ + 1;
} else if (name[GIT_SHA1_HEXSZ] == '\0') {
; /* <sha1>, leave sha1 as name */
} else {
/* <ref>, clear cruft from oid */
oidclr(&oid);
}
} else {
/* <ref>, clear cruft from get_oid_hex */
oidclr(&oid);
}

ref = alloc_ref(name);
oidcpy(&ref->old_oid, &oid);
Expand Down
14 changes: 14 additions & 0 deletions t/t5500-fetch-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,20 @@ test_expect_success 'shallow fetch with tags does not break the repository' '
git fsck
)
'

test_expect_success 'fetch-pack can fetch a raw sha1' '
git init hidden &&
(
cd hidden &&
test_commit 1 &&
test_commit 2 &&
git update-ref refs/hidden/one HEAD^ &&
git config transfer.hiderefs refs/hidden &&
git config uploadpack.allowtipsha1inwant true
) &&
git fetch-pack hidden $(git -C hidden rev-parse refs/hidden/one)
'

check_prot_path () {
cat >expected <<-EOF &&
Diag: url=$1
Expand Down

0 comments on commit 9081cff

Please sign in to comment.