Skip to content

Commit 22568f0

Browse files
adambrewstergitster
authored andcommitted
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>
1 parent 44701c6 commit 22568f0

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

bundle.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ int create_bundle(struct bundle_header *header, const char *path,
178178
int i, ref_count = 0;
179179
char buffer[1024];
180180
struct rev_info revs;
181+
int read_from_stdin = 0;
181182
struct child_process rls;
182183
FILE *rls_fout;
183184

@@ -227,8 +228,16 @@ int create_bundle(struct bundle_header *header, const char *path,
227228

228229
/* write references */
229230
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+
}
232241

233242
for (i = 0; i < revs.pending.nr; i++) {
234243
struct object_array_entry *e = revs.pending.objects + i;

0 commit comments

Comments
 (0)