Skip to content

Commit 58f2ed0

Browse files
pcloudsgitster
authored andcommitted
remote-curl: pass ref SHA-1 to fetch-pack as well
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b016918 commit 58f2ed0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

builtin/fetch-pack.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ static void add_sought_entry_mem(struct ref ***sought, int *nr, int *alloc,
1313
const char *name, int namelen)
1414
{
1515
struct ref *ref = xcalloc(1, sizeof(*ref) + namelen + 1);
16+
unsigned char sha1[20];
17+
18+
if (namelen > 41 && name[40] == ' ' && !get_sha1_hex(name, sha1)) {
19+
hashcpy(ref->old_sha1, sha1);
20+
name += 41;
21+
namelen -= 41;
22+
}
1623

1724
memcpy(ref->name, name, namelen);
1825
ref->name[namelen] = '\0';

remote-curl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -719,7 +719,8 @@ static int fetch_git(struct discovery *heads,
719719
struct ref *ref = to_fetch[i];
720720
if (!ref->name || !*ref->name)
721721
die("cannot fetch by sha1 over smart http");
722-
packet_buf_write(&preamble, "%s\n", ref->name);
722+
packet_buf_write(&preamble, "%s %s\n",
723+
sha1_to_hex(ref->old_sha1), ref->name);
723724
}
724725
packet_buf_flush(&preamble);
725726

0 commit comments

Comments
 (0)