aboutsummaryrefslogtreecommitdiff
path: root/builtin-bundle.c
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-03-09 17:30:15 +0100
committerJunio C Hamano <junkio@cox.net>2007-03-11 23:55:46 -0700
commit34572ed2c809c2e0b00dc660bdb2dd201c5ff85f (patch)
tree4b1c5cd7eda6242cdb1359c0b05a6ee27f3e00f6 /builtin-bundle.c
parent4a62d3f5b237fb9fab7df778ecf62906ff892065 (diff)
downloadgit-34572ed2c809c2e0b00dc660bdb2dd201c5ff85f.tar.gz
git-34572ed2c809c2e0b00dc660bdb2dd201c5ff85f.tar.xz
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>
Diffstat (limited to 'builtin-bundle.c')
-rw-r--r--builtin-bundle.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin-bundle.c b/builtin-bundle.c
index 55f6d0abc..786808081 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -263,7 +263,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
int bundle_fd = -1;
const char **argv_boundary = xmalloc((argc + 4) * sizeof(const char *));
const char **argv_pack = xmalloc(5 * sizeof(const char *));
- int pid, in, out, i, status;
+ int pid, in, out, i, status, ref_count = 0;
char buffer[1024];
struct rev_info revs;
@@ -328,15 +328,20 @@ static int create_bundle(struct bundle_header *header, const char *path,
* other limiting options could have prevented all the tips
* from getting output.
*/
- if (!(e->item->flags & SHOWN))
- die("ref '%s' is excluded by the rev-list options",
+ if (!(e->item->flags & SHOWN)) {
+ warn("ref '%s' is excluded by the rev-list options",
e->name);
+ continue;
+ }
+ ref_count++;
write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40);
write_or_die(bundle_fd, " ", 1);
write_or_die(bundle_fd, ref, strlen(ref));
write_or_die(bundle_fd, "\n", 1);
free(ref);
}
+ if (!ref_count)
+ die ("Refusing to create empty bundle.");
/* end header */
write_or_die(bundle_fd, "\n", 1);