summaryrefslogtreecommitdiff
path: root/bundle.c
diff options
context:
space:
mode:
authorAdam Brewster <adambrewster@gmail.com>2008-07-05 17:26:40 -0400
committerJunio C Hamano <gitster@pobox.com>2008-07-07 01:31:24 -0700
commit22568f0a336ac37ae7329c917857b455839d1d09 (patch)
tree83b61b96de4ef6d0889cf6d432e82ce79aa252bb /bundle.c
parent44701c67fd1d5d771b440c8646b7b268d4f1402d (diff)
downloadgit-22568f0a336ac37ae7329c917857b455839d1d09.tar.gz
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>
Diffstat (limited to 'bundle.c')
-rw-r--r--bundle.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/bundle.c b/bundle.c
index 0ba5df17e1..00b2aabefc 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;