git-bundle: only die if pack would be empty, warn if ref is skipped
A use case for git-bundle expected to be quite common is this: $ git bundle create daily.bundle --since=10.days.ago --all The expected outcome is _not_ to error out if only a couple of the refs were not changed during the last 10 days. This patch complains loudly about refs which are skipped due to the pack not containing the corresponding objects, but dies only if no objects would be in the pack _at all_. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
Mar 9, 2007 at 17:30 UTC
34572ed2c809c2e0b00dc660bdb2dd201c5ff85f
1 file changed
+8
-3
builtin-bundle.c
+8
-3
@@ -263,7 +263,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
263
int bundle_fd = -1;
264
const char **argv_boundary = xmalloc((argc + 4) * sizeof(const char *));
265
const char **argv_pack = xmalloc(5 * sizeof(const char *));
266
- int pid, in, out, i, status;
266
+ int pid, in, out, i, status, ref_count = 0;
267
char buffer[1024];
268
struct rev_info revs;
269
@@ -328,15 +328,20 @@ static int create_bundle(struct bundle_header *header, const char *path,
328
* other limiting options could have prevented all the tips
329
* from getting output.
330
*/
331
- if (!(e->item->flags & SHOWN))
332
- die("ref '%s' is excluded by the rev-list options",
331
+ if (!(e->item->flags & SHOWN)) {
332
+ warn("ref '%s' is excluded by the rev-list options",
333
e->name);
334
+ continue;
335
+ }
336
+ ref_count++;
337
write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40);
338
write_or_die(bundle_fd, " ", 1);
339
write_or_die(bundle_fd, ref, strlen(ref));
340
write_or_die(bundle_fd, "\n", 1);
341
free(ref);
342
}
343
+ if (!ref_count)
344
+ die ("Refusing to create empty bundle.");
345
346
/* end header */
347
write_or_die(bundle_fd, "\n", 1);