[PATCH] fetch-pack: avoid fixing thin packs when unnecessary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When we know that there are no common commits, the pack must be
closed (i.e. non-thin) already. Avoid "fixing" it in that case.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@xxxxxx>

---

	On Mon, 18 Dec 2006, Johannes Schindelin wrote:

	> On Mon, 18 Dec 2006, Randal L. Schwartz wrote:
	> 
	> > But then it took nearly an *hour* at the next phase:
	> > 
	> >   Resolving 313037 deltas.
	> >    100% (313037/313037) done
	> 
	> Ouch.
	> 
	> We try to avoid unpacking the thin packs received by git-fetch.
	> This means completing that pack (since it can contain deltas 
	> against objects which are part of another pack).
	> 
	> However, for the clone this is utter overkill. We really should 
	> try to avoid resolving unnecessarily. This is really for the 
	> clone case, since we do not have _any_ objects in the local 
	> repository.
	> 
	> It happens that the other case -- fetching an independent branch 
	> -- is easy enough: we already have the check for it in 
	> fetch-pack.c:586.

	... and here is a lightly tested fix.

	Can you please apply this patch and try again?

 fetch-pack.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/fetch-pack.c b/fetch-pack.c
index 3bb8242..5952ff7 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -529,7 +529,7 @@ static int explode_rx_pack(int xd[2])
 	return get_pack(xd, argv);
 }
 
-static int keep_rx_pack(int xd[2])
+static int keep_rx_pack(int xd[2], int fix_thin)
 {
 	const char *argv[6];
 	char keep_arg[256];
@@ -539,7 +539,7 @@ static int keep_rx_pack(int xd[2])
 	argv[n++] = "--stdin";
 	if (!quiet)
 		argv[n++] = "-v";
-	if (use_thin_pack)
+	if (fix_thin)
 		argv[n++] = "--fix-thin";
 	if (keep_pack > 1) {
 		int s = sprintf(keep_arg, "--keep=fetch-pack %i on ", getpid());
@@ -555,7 +555,7 @@ static int fetch_pack(int fd[2], int nr_match, char **match)
 {
 	struct ref *ref;
 	unsigned char sha1[20];
-	int status;
+	int status, fix_thin;
 
 	get_remote_heads(fd[0], &ref, 0, NULL, 0);
 	if (is_repository_shallow() && !server_supports("shallow"))
@@ -583,14 +583,17 @@ static int fetch_pack(int fd[2], int nr_match, char **match)
 		packet_flush(fd[1]);
 		goto all_done;
 	}
-	if (find_common(fd, sha1, ref) < 0)
+	fix_thin = use_thin_pack;
+	if (find_common(fd, sha1, ref) < 0) {
+		fix_thin = 0;
 		if (keep_pack != 1)
 			/* When cloning, it is not unusual to have
 			 * no common commit.
 			 */
 			fprintf(stderr, "warning: no common commits\n");
+	}
 
-	status = (keep_pack) ? keep_rx_pack(fd) : explode_rx_pack(fd);
+	status = (keep_pack) ? keep_rx_pack(fd, fix_thin) : explode_rx_pack(fd);
 	if (status)
 		die("git-fetch-pack: fetch failed.");
 
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]