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

[PATCH] git-bundle: add --stdin

From
Adam Brewster <adambrewster@gmail.com>
Date
Jul 5, 2008, 21:26 UTC
Message-ID
<1215293200-28199-3-git-send-email-adambrewster@gmail.com>
In-Reply-To
<1215293200-28199-2-git-send-email-adambrewster@gmail.com>
Teach git-bundle to read revision arguments from stdin like git-rev-list.

This patch allows the caller to feed the revision parameters to git-bundle from its standard input. This way, a script do not have to worry about limitation of the length of command line.

Documentation/git-bundle.txt says that git-bundle takes arguments acceptable to git-rev-list. Obviously some arguments that git-rev-list handles don't make sense for git-bundle (e.g. --bisect) but --stdin is pretty reasonable.

Signed-off-by: Adam Brewster <adambrewster@gmail.com>
---
 bundle.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/bundle.c b/bundle.c
index 0ba5df1..00b2aab 100644
--- a/bundle.c
+++ b/bundle.c
@@ -178,6 +178,7 @@ int create_bundle(struct bundle_header *header, const char *path,
 	int i, ref_count = 0;
 	char buffer[1024];
 	struct rev_info revs;
+	int read_from_stdin = 0;
 	struct child_process rls;
 	FILE *rls_fout;
 
@@ -227,8 +228,16 @@ int create_bundle(struct bundle_header *header, const char *path,
 
 	/* write references */
 	argc = setup_revisions(argc, argv, &revs, NULL);
-	if (argc > 1)
-		return error("unrecognized argument: %s'", argv[1]);
+
+	for (i = 1; i < argc; i++) {
+		if (!strcmp(argv[i], "--stdin")) {
+			if (read_from_stdin++)
+				die("--stdin given twice?");
+			read_revisions_from_stdin(&revs);
+			continue;
+		}
+		return error("unrecognized argument: %s'", argv[i]);
+	}
 
 	for (i = 0; i < revs.pending.nr; i++) {
 		struct object_array_entry *e = revs.pending.objects + i;
-- 
1.5.5.1.211.g65ea3.dirty
Previous: Adam BrewsterNext: Junio C Hamano
Message 11 of 18 in “bundle.c: added --stdin option to git-bundle”
  1. bundle.c: added --stdin option to git-bundleAdam Brewster, Jul 5, 2008
  2. Jakub NarebskiJul 5, 2008
  3. Junio C HamanoJul 5, 2008
  4. 0/3 Adam Brewster, Jul 5, 2008
  5. Move read_revisions_from_stdin from builtin-rev-list.c to revision.cAdam Brewster, Jul 5, 2008
  6. git-bundle: add --stdinAdam Brewster, Jul 5, 2008
  7. Add git-basis.perl to contrib directoryAdam Brewster, Jul 5, 2008
  8. Miklos VajnaJul 5, 2008
  9. Adam Brewster, Jul 5, 2008
  10. Move read_revisions_from_stdin from builtin-rev-list.c to revision.cAdam Brewster, Jul 5, 2008
  11. git-bundle: add --stdinAdam Brewster, Jul 5, 2008
  12. Junio C HamanoJul 6, 2008
  13. Adam BrewsterJul 6, 2008
  14. git-rev-list: tolerate multiple --stdin optionsAdam Brewster, Jul 6, 2008
  15. Teach git-bundle to read revision arguments from stdin likeAdam Brewster, Jul 6, 2008
  16. Junio C HamanoJul 6, 2008
  17. Adam BrewsterJul 6, 2008
  18. Junio C HamanoJul 6, 2008

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.