login
Header Space

 
 

[PATCH] git-bundle: add --stdin

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git@...>
Cc: <gitster@...>, <mdl123@...>, <Johannes.Schindelin@...>, <jnareb@...>, <adambrewster@...>, <vmiklos@...>
Date: Saturday, July 5, 2008 - 5:26 pm

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH/v3] bundle.c: added --stdin option to git-bundle, Adam Brewster, (Sat Jul 5, 12:30 pm)
[PATCH v4 0/3], Adam Brewster, (Sat Jul 5, 4:40 pm)
[PATCH v5], Adam Brewster, (Sat Jul 5, 5:26 pm)
Re: [PATCH v5], Junio C Hamano, (Sat Jul 5, 9:50 pm)
Re: [PATCH v5], Adam Brewster, (Sat Jul 5, 10:49 pm)
[PATCH] git-bundle: add --stdin, Adam Brewster, (Sat Jul 5, 5:26 pm)
[PATCH] git-bundle: add --stdin, Adam Brewster, (Sat Jul 5, 4:40 pm)
[PATCH] Add git-basis.perl to contrib directory, Adam Brewster, (Sat Jul 5, 4:40 pm)
speck-geostationary