Skip to content

Commit 31ec6ab

Browse files
author
Junio C Hamano
committed
clone-pack: make it usable for partial branch cloning.
clone-pack had some logic to accept subset of remote refs from the command line and clone from there. However, it was never used in practice and its problems were not found out so far. This commit changes the command to output the object names of refs to the standard output instead of making a clone of the remote repository when explicit <head> parameters are given; the output format is the same as fetch-pack. The traditional behaviour of cloning the whole repository by giving no explicit <head> parameters stays the same. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent 294c695 commit 31ec6ab

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

Documentation/git-clone-pack.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ OPTIONS
4343
The heads to update. This is relative to $GIT_DIR
4444
(e.g. "HEAD", "refs/heads/master"). When unspecified,
4545
all heads are updated to match the remote repository.
46-
46+
+
47+
Usually all the refs from existing repository are stored
48+
under the same name in the new repository. Giving explicit
49+
<head> arguments instead writes the object names and refs to
50+
the standard output, just like get-fetch-pack does.
4751

4852
Author
4953
------

clone-pack.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,17 @@ static int clone_pack(int fd[2], int nr_match, char **match)
259259

260260
status = clone_without_unpack(fd);
261261

262-
if (!status)
263-
write_refs(refs);
262+
if (!status) {
263+
if (nr_match == 0)
264+
write_refs(refs);
265+
else
266+
while (refs) {
267+
printf("%s %s\n",
268+
sha1_to_hex(refs->old_sha1),
269+
refs->name);
270+
refs = refs->next;
271+
}
272+
}
264273
return status;
265274
}
266275

0 commit comments

Comments
 (0)