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

[PATCH 3/4] git-bundle: various fixups

From
Junio C Hamano <junkio@cox.net>
Date
Mar 6, 2007, 00:41 UTC
Message-ID
<7vtzwzurss.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vk5xvw6mg.fsf@assigned-by-dhcp.cox.net>

verify_bundle() returned with an error early only when all prerequisite commits were missing. It should error out much earlier when some are missing.

When the rev-list is limited in ways other than revision range (e.g. --max-count or --max-age), create_bundle() listed all positive refs given from the command line as if they are available, but resulting pack may not have some of them. Add a logic to make sure all of them are included, and error out otherwise.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 builtin-bundle.c |   46 +++++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/builtin-bundle.c b/builtin-bundle.c
index 0265845..9286f3d 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -189,7 +189,7 @@ static int verify_bundle(struct bundle_header *header)
 			error(message);
 		error("%s %s", sha1_to_hex(e->sha1), e->name);
 	}
-	if (revs.pending.nr == 0)
+	if (revs.pending.nr != p->nr)
 		return ret;
 	req_nr = revs.pending.nr;
 	setup_revisions(2, argv, &revs, NULL);
@@ -274,6 +274,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
 	int pid, in, out, i, status;
 	char buffer[1024];
 	struct rev_info revs;
+	struct object_array tips;
 
 	bundle_fd = (!strcmp(path, "-") ? 1 :
 			open(path, O_CREAT | O_WRONLY, 0666));
@@ -311,19 +312,23 @@ static int create_bundle(struct bundle_header *header, const char *path,
 	argc = setup_revisions(argc, argv, &revs, NULL);
 	if (argc > 1)
 		return error("unrecognized argument: %s'", argv[1]);
+
+	memset(&tips, 0, sizeof(tips));
 	for (i = 0; i < revs.pending.nr; i++) {
 		struct object_array_entry *e = revs.pending.objects + i;
-		if (!(e->item->flags & UNINTERESTING)) {
-			unsigned char sha1[20];
-			char *ref;
-			if (dwim_ref(e->name, strlen(e->name), sha1, &ref) != 1)
-				continue;
-			write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40);
-			write_or_die(bundle_fd, " ", 1);
-			write_or_die(bundle_fd, ref, strlen(ref));
-			write_or_die(bundle_fd, "\n", 1);
-			free(ref);
-		}
+		unsigned char sha1[20];
+		char *ref;
+
+		if (e->item->flags & UNINTERESTING)
+			continue;
+		if (dwim_ref(e->name, strlen(e->name), sha1, &ref) != 1)
+			continue;
+		write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40);
+		write_or_die(bundle_fd, " ", 1);
+		write_or_die(bundle_fd, ref, strlen(ref));
+		write_or_die(bundle_fd, "\n", 1);
+		add_object_array(e->item, e->name, &tips);
+		free(ref);
 	}
 
 	/* end header */
@@ -350,7 +355,22 @@ static int create_bundle(struct bundle_header *header, const char *path,
 			return -1;
 	if (!WIFEXITED(status) || WEXITSTATUS(status))
 		return error ("pack-objects died");
-	return 0;
+
+	/*
+	 * Make sure the refs we wrote out is correct; --max-count and
+	 * other limiting options could have prevented all the tips
+	 * from getting output.
+	 */
+	status = 0;
+	for (i = 0; i < tips.nr; i++) {
+		if (!(tips.objects[i].item->flags & SHOWN)) {
+			status = 1;
+			error("%s: not included in the resulting pack",
+			      tips.objects[i].name);
+		}
+	}
+
+	return status;
 }
 
 static int unbundle(struct bundle_header *header, int bundle_fd,
-- 
1.5.0.3.862.g71037
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 23 of 26 in “[BUG] git-rev-list: --topo-order --boundary and --max-count”
  1. Santi BéjarMar 5, 2007
  2. Junio C HamanoMar 5, 2007
  3. Junio C HamanoMar 5, 2007
  4. Linus TorvaldsMar 5, 2007
  5. revision walker: Fix --boundary when limitedJohannes Schindelin, Mar 5, 2007
  6. Johannes SchindelinMar 5, 2007
  7. Linus TorvaldsMar 5, 2007
  8. Linus TorvaldsMar 5, 2007
  9. Junio C HamanoMar 5, 2007
  10. Johannes SchindelinMar 6, 2007
  11. Junio C HamanoMar 6, 2007
  12. Johannes SchindelinMar 6, 2007
  13. Junio C HamanoMar 6, 2007
  14. Johannes SchindelinMar 5, 2007
  15. Junio C HamanoMar 6, 2007
  16. 2/4 revision traversal: retire BOUNDARY_SHOWJunio C Hamano, Mar 6, 2007
  17. Johannes SchindelinMar 6, 2007
  18. Junio C HamanoMar 6, 2007
  19. SHOWN means shownJunio C Hamano, Mar 6, 2007
  20. Johannes SchindelinMar 6, 2007
  21. Junio C HamanoMar 6, 2007
  22. Johannes SchindelinMar 6, 2007
  23. 3/4 git-bundle: various fixupsJunio C Hamano, Mar 6, 2007
  24. Johannes SchindelinMar 6, 2007
  25. 4/4 git-bundle: --list-prereqsJunio C Hamano, Mar 6, 2007
  26. Junio C HamanoMar 5, 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.