@matheusbsbs / matheus-bagliano / commits / 22568f0a33
Fork 0

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Adam Brewster committed Jul 5, 2008 at 17:26 UTC 22568f0a336ac37ae7329c917857b455839d1d09
1 file changed +11 -2
bundle.c
+11 -2
@@ -178,6 +178,7 @@ int create_bundle(struct bundle_header *header, const char *path,
178 int i, ref_count = 0;
179 char buffer[1024];
180 struct rev_info revs;
181 + int read_from_stdin = 0;
182 struct child_process rls;
183 FILE *rls_fout;
184
@@ -227,8 +228,16 @@ int create_bundle(struct bundle_header *header, const char *path,
228
229 /* write references */
230 argc = setup_revisions(argc, argv, &revs, NULL);
230 - if (argc > 1)
231 - return error("unrecognized argument: %s'", argv[1]);
231 +
232 + for (i = 1; i < argc; i++) {
233 + if (!strcmp(argv[i], "--stdin")) {
234 + if (read_from_stdin++)
235 + die("--stdin given twice?");
236 + read_revisions_from_stdin(&revs);
237 + continue;
238 + }
239 + return error("unrecognized argument: %s'", argv[i]);
240 + }
241
242 for (i = 0; i < revs.pending.nr; i++) {
243 struct object_array_entry *e = revs.pending.objects + i;