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

[PATCH] git-bundle: die if the bundle is empty.

From
Mark Levedahl <mdl123@verizon.net>
Date
Mar 9, 2007, 03:51 UTC
Message-ID
<11734123161927-git-send-email-mdl123@verizon.net>
In-Reply-To
<Pine.LNX.4.63.0703090348300.22628@wbgn013.biozentrum.uni-wuerzburg.de>

A common use of bundle is to schedule nightly emailed updates to a remote system containing all updates made over a given period. We want bundle to complain only if the resulting bundle would be empty, but not if at least one of the given refs has an update resulting in a non-empty bundle.

Signed-off-by: Mark Levedahl <mdl123@verizon.net>
---
 builtin-bundle.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/builtin-bundle.c b/builtin-bundle.c
index c85f996..b888a9f 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -261,6 +261,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
 		int argc, const char **argv)
 {
 	int bundle_fd = -1;
+	int isempty = 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;
@@ -328,17 +329,17 @@ 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)) {
-			warn("ref '%s' is excluded by the rev-list options",
-				e->name);
-			continue;
+		if ((e->item->flags & SHOWN)) {
+			isempty = 0;
+			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);
 		}
-		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 (isempty)
+		die("Bundle is empty");
 
 	/* end header */
 	write_or_die(bundle_fd, "\n", 1);
-- 
1.5.0.3.927.g2432c-dirty
Previous: Mark Levedahl
Message 21 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.