git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-bundle: avoid packing objects which are in the prerequisites

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 7, 2007, 23:43 UTC
Message-ID
<Pine.LNX.4.63.0703080039420.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vfy8geikk.fsf@assigned-by-dhcp.cox.net>

When saying something like "--since=1.day.ago" or "--max-count=5", git-bundle finds the boundary commits which are recorded as prerequisites. However, it failed to tell pack-objects _not_ to pack the objects which are in these.

Fix that. And add a test for that.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Wed, 7 Mar 2007, Junio C Hamano wrote:
	> What's not fixed is that we still use "rev-list --objects 
	> --max-*" given by the user, which is not the semantics 
	> git-bundle wants.  We should rewrite the revspec to drive 
	> pack-objects when generating the packfile part of the bundle to 
	> do "<revs> --not <boundaries>" internally in git-bundle.
	Since we already calculate the prerequisites, it's easy to pass
	them as uninteresting, too. It does not hurt to keep the max*
	limiters, so they are not unset.
 builtin-bundle.c |   15 ++++++++++++---
 t/t5510-fetch.sh |   11 +++++++++++
 2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/builtin-bundle.c b/builtin-bundle.c
index 3b3bc25..70d4479 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -305,6 +305,10 @@ static int create_bundle(struct bundle_header *header, const char *path,
 	/* write signature */
 	write_or_die(bundle_fd, bundle_signature, strlen(bundle_signature));
 
+	/* init revs to list objects for pack-objects later */
+	save_commit_buffer = 0;
+	init_revisions(&revs, NULL);
+
 	/* write prerequisites */
 	memcpy(argv_boundary + 3, argv + 1, argc * sizeof(const char *));
 	argv_boundary[0] = "rev-list";
@@ -316,8 +320,15 @@ static int create_bundle(struct bundle_header *header, const char *path,
 	if (pid < 0)
 		return -1;
 	while ((i = read_string(out, buffer, sizeof(buffer))) > 0)
-		if (buffer[0] == '-')
+		if (buffer[0] == '-') {
+			unsigned char sha1[20];
 			write_or_die(bundle_fd, buffer, i);
+			if (!get_sha1_hex(buffer + 1, sha1)) {
+				struct object *object = parse_object(sha1);
+				object->flags |= UNINTERESTING;
+				add_pending_object(&revs, object, buffer);
+			}
+		}
 	while ((i = waitpid(pid, &status, 0)) < 0)
 		if (errno != EINTR)
 			return error("rev-list died");
@@ -325,8 +336,6 @@ static int create_bundle(struct bundle_header *header, const char *path,
 		return error("rev-list died %d", WEXITSTATUS(status));
 
 	/* write references */
-	save_commit_buffer = 0;
-	init_revisions(&revs, NULL);
 	revs.tag_objects = 1;
 	revs.tree_objects = 1;
 	revs.blob_objects = 1;
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index ce96b4b..7be9793 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -121,4 +121,15 @@ test_expect_success 'unbundle 2' '
 	test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"
 '
 
+test_expect_success 'bundle does not prerequisite objects' '
+	cd "$D" &&
+	touch file2 &&
+	git add file2 &&
+	git commit -m add.file2 file2 &&
+	git bundle create bundle3 -1 HEAD &&
+	sed "1,4d" < bundle3 > bundle.pack &&
+	git index-pack bundle.pack &&
+	test 4 = $(git verify-pack -v bundle.pack | wc -l)
+'
+
 test_done
-- 
1.5.0.3.2562.gfcfe0
Previous: Junio C HamanoNext: Mark Levedahl
Message 20 of 22 in “builtin git-bundle - pack contains many more objects than required”
  1. Mark LevedahlMar 6, 2007
  2. Junio C HamanoMar 6, 2007
  3. git-bundle: fix pack generation.Junio C Hamano, Mar 6, 2007
  4. Mark LevedahlMar 7, 2007
  5. Junio C HamanoMar 7, 2007
  6. Mark LevedahlMar 7, 2007
  7. Johannes SchindelinMar 7, 2007
  8. Mark LevedahlMar 7, 2007
  9. Johannes SchindelinMar 7, 2007
  10. Junio C HamanoMar 7, 2007
  11. Mark LevedahlMar 7, 2007
  12. Johannes SchindelinMar 7, 2007
  13. Linus TorvaldsMar 7, 2007
  14. git-bundle: Make thin packsJohannes Schindelin, Mar 8, 2007
  15. Linus TorvaldsMar 8, 2007
  16. Johannes SchindelinMar 8, 2007
  17. Junio C HamanoMar 8, 2007
  18. Johannes SchindelinMar 8, 2007
  19. Junio C HamanoMar 7, 2007
  20. git-bundle: avoid packing objects which are in the prerequisitesJohannes Schindelin, Mar 7, 2007
  21. Mark LevedahlMar 8, 2007
  22. Mark LevedahlMar 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.