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

[PATCH] git-bundle: only die if pack would be empty, warn if ref is skipped

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 9, 2007, 16:30 UTC
Message-ID
<Pine.LNX.4.63.0703091726530.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<45F17EF0.5060008@gmail.com>
A use case for git-bundle expected to be quite common is this:
	$ git bundle create daily.bundle --since=10.days.ago --all

The expected outcome is _not_ to error out if only a couple of the refs were not changed during the last 10 days.

This patch complains loudly about refs which are skipped due to the pack not containing the corresponding objects, but dies only if no objects would be in the pack _at all_.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
	On Fri, 9 Mar 2007, Mark Levedahl wrote:
	> Junio C Hamano wrote:
	> > If I were doing a nightly script, I would probably be doing
	> > something like this:
	> > 
	> > 	#!/bin/sh
	> > 	yesterday=$(git bundle list-heads yesterday.bdl | sed -e 's/ .*//')
	> > 	git bundle create today.bdl --all --not $yesterday
	> > 	# mail it out
	>
	> Thinking about this further, the above has a problem (or should, 
	> but see below). [...]
	I see another problem, too: if at least one ref was not updated 
	since yesterday, "create" would fail with the latest patches.
	This fixes it.
	BTW I had a little laugh when seeing what git-describe made of my 
	current version :-)
 builtin-bundle.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/builtin-bundle.c b/builtin-bundle.c
index 55f6d0a..7868080 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -263,7 +263,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
 	int bundle_fd = -1;
 	const char **argv_boundary = xmalloc((argc + 4) * sizeof(const char *));
 	const char **argv_pack = xmalloc(5 * sizeof(const char *));
-	int pid, in, out, i, status;
+	int pid, in, out, i, status, ref_count = 0;
 	char buffer[1024];
 	struct rev_info revs;
 
@@ -328,15 +328,20 @@ static int create_bundle(struct bundle_header *header, const char *path,
 		 * other limiting options could have prevented all the tips
 		 * from getting output.
 		 */
-		if (!(e->item->flags & SHOWN))
-			die("ref '%s' is excluded by the rev-list options",
+		if (!(e->item->flags & SHOWN)) {
+			warn("ref '%s' is excluded by the rev-list options",
 				e->name);
+			continue;
+		}
+		ref_count++;
 		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);
 	}
+	if (!ref_count)
+		die ("Refusing to create empty bundle.");
 
 	/* end header */
 	write_or_die(bundle_fd, "\n", 1);
-- 
1.5.0.3.2621.gaaaa-dirty
Previous: Mark LevedahlNext: Mark Levedahl
Message 6 of 21 in “git-bundle: die if a given ref is not included in bundle”
  1. 2/3 git-bundle: die if a given ref is not included in bundleJohannes Schindelin, Mar 9, 2007
  2. Mark LevedahlMar 9, 2007
  3. Junio C HamanoMar 9, 2007
  4. Mark LevedahlMar 9, 2007
  5. Mark LevedahlMar 9, 2007
  6. git-bundle: only die if pack would be empty, warn if ref is skippedJohannes Schindelin, Mar 9, 2007
  7. Mark LevedahlMar 10, 2007
  8. Junio C HamanoMar 9, 2007
  9. Mark LevedahlMar 10, 2007
  10. Johannes SchindelinMar 10, 2007
  11. Mark LevedahlMar 10, 2007
  12. Johannes SchindelinMar 10, 2007
  13. Mark LevedahlMar 10, 2007
  14. Johannes SchindelinMar 11, 2007
  15. Junio C HamanoMar 11, 2007
  16. Johannes SchindelinMar 11, 2007
  17. Mark LevedahlMar 11, 2007
  18. Junio C HamanoMar 11, 2007
  19. Johannes SchindelinMar 11, 2007
  20. Mark LevedahlMar 13, 2007
  21. git-bundle: die if the bundle is empty.Mark Levedahl, Mar 9, 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.