summaryrefslogtreecommitdiff
path: root/builtin-bundle.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-08-09 05:04:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-08-11 05:19:15 (GMT)
commitc06793a4ed1bf81902c324d1ed88dd055c3aa468 (patch)
tree5e2e631672e382e16cb5083ba526f094d9527974 /builtin-bundle.c
parent7fa8254f9476de24661e93b2a90c6ce30dc10006 (diff)
downloadgit-c06793a4ed1bf81902c324d1ed88dd055c3aa468.zip
git-c06793a4ed1bf81902c324d1ed88dd055c3aa468.tar.gz
git-c06793a4ed1bf81902c324d1ed88dd055c3aa468.tar.bz2
allow git-bundle to create bottomless bundle
Mark Levedahl <mlevedahl@gmail.com> writes: > Junio C Hamano wrote: >> While "git bundle" was a useful way to sneakernet incremental >> changes, we did not allow: >> > Thanks - I've been thinking for months I could fix this bug, never > figured it out and didn't want to nag Dscho one more time. I confirm > that this allows creation of bundles with arbitrary refs, not just > those under refs/heads. Yahoo! Actually, there is another bug nearby. If you do: git bundle create v2.6-20-v2.6.22.bndl v2.6.20..v2.6.22 the bundle records that it requires v2.6.20^0 commit (correct) and gives you tag v2.6.22 (incorrect); the bug is that the object it lists in fact is the commit v2.6.22^0, not the tag. This is because the revision range operation .. is always about set of commits, but the code near where my patch touches does not validate that the sha1 value obtained from dwim_ref() against the commit object name e->item->sha1 before placing the head information in the commit. The attached patch attempts to fix this problem. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-bundle.c')
-rw-r--r--builtin-bundle.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/builtin-bundle.c b/builtin-bundle.c
index cb439ca..2d0e106 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -279,8 +279,41 @@ static int create_bundle(struct bundle_header *header, const char *path,
if (!(e->item->flags & SHOWN) && e->item->type == OBJ_COMMIT) {
warning("ref '%s' is excluded by the rev-list options",
e->name);
+ free(ref);
continue;
}
+ /*
+ * If you run "git bundle create bndl v1.0..v2.0", the
+ * name of the positive ref is "v2.0" but that is the
+ * commit that is referenced by the tag, and not the tag
+ * itself.
+ */
+ if (hashcmp(sha1, e->item->sha1)) {
+ /*
+ * Is this the positive end of a range expressed
+ * in terms of a tag (e.g. v2.0 from the range
+ * "v1.0..v2.0")?
+ */
+ struct commit *one = lookup_commit_reference(sha1);
+ struct object *obj;
+
+ if (e->item == &(one->object)) {
+ /*
+ * Need to include e->name as an
+ * independent ref to the pack-objects
+ * input, so that the tag is included
+ * in the output; otherwise we would
+ * end up triggering "empty bundle"
+ * error.
+ */
+ obj = parse_object(sha1);
+ obj->flags |= SHOWN;
+ add_pending_object(&revs, obj, e->name);
+ }
+ free(ref);
+ continue;
+ }
+
ref_count++;
write_or_die(bundle_fd, sha1_to_hex(e->item->sha1), 40);
write_or_die(bundle_fd, " ", 1);