X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=bundle.c;h=0ba5df17e15d679b03fe38af40260c118c9588fa;hb=acd3b9eca82e38950f94e4708b528b7dae09a7c8;hp=bd12ec8537781c5c82e77637312ccabb708d5040;hpb=c0284cea3149cb20e24ee5e25b475e5f8edba84f;p=thirdparty%2Fgit.git diff --git a/bundle.c b/bundle.c index bd12ec8537..7d17a1fde1 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; @@ -185,7 +186,8 @@ int create_bundle(struct bundle_header *header, const char *path, if (bundle_to_stdout) bundle_fd = 1; else - bundle_fd = hold_lock_file_for_update(&lock, path, 1); + bundle_fd = hold_lock_file_for_update(&lock, path, + LOCK_DIE_ON_ERROR); /* write signature */ write_or_die(bundle_fd, bundle_signature, strlen(bundle_signature)); @@ -227,8 +229,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; @@ -333,10 +343,12 @@ int create_bundle(struct bundle_header *header, const char *path, write_or_die(rls.in, sha1_to_hex(object->sha1), 40); write_or_die(rls.in, "\n", 1); } + close(rls.in); if (finish_command(&rls)) return error ("pack-objects died"); - - return bundle_to_stdout ? close(bundle_fd) : commit_lock_file(&lock); + if (!bundle_to_stdout) + commit_lock_file(&lock); + return 0; } int unbundle(struct bundle_header *header, int bundle_fd)