summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-10-28 10:43:16 -0700
committerJunio C Hamano <gitster@pobox.com>2013-10-28 10:43:16 -0700
commit2d99baab2f054926a1b26f7854fc50b701151bd7 (patch)
treebca89c2a53d6e85ef18d8c10bf84a85c798664f7 /revision.c
parente22c1c7f19914aa0dc1b6fe65bbfafed265d6e7f (diff)
parent895c5ba3c1c927c68e581ebb0e13d9a123e477ab (diff)
downloadgit-2d99baab2f054926a1b26f7854fc50b701151bd7.tar.gz
Merge branch 'jc/revision-range-unpeel'
"git rev-list --objects ^v1.0^ v1.0" gave v1.0 tag itself in the output, but "git rev-list --objects v1.0^..v1.0" did not. * jc/revision-range-unpeel: revision: do not peel tags used in range notation
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c59
1 files changed, 37 insertions, 22 deletions
diff --git a/revision.c b/revision.c
index 0173e0148b..7e03e154f4 100644
--- a/revision.c
+++ b/revision.c
@@ -1419,26 +1419,40 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
}
if (!get_sha1_committish(this, from_sha1) &&
!get_sha1_committish(next, sha1)) {
- struct commit *a, *b;
- struct commit_list *exclude;
-
- a = lookup_commit_reference(from_sha1);
- b = lookup_commit_reference(sha1);
- if (!a || !b) {
- if (revs->ignore_missing)
- return 0;
- die(symmetric ?
- "Invalid symmetric difference expression %s...%s" :
- "Invalid revision range %s..%s",
- arg, next);
- }
+ struct object *a_obj, *b_obj;
if (!cant_be_filename) {
*dotdot = '.';
verify_non_filename(revs->prefix, arg);
}
- if (symmetric) {
+ a_obj = parse_object(from_sha1);
+ b_obj = parse_object(sha1);
+ if (!a_obj || !b_obj) {
+ missing:
+ if (revs->ignore_missing)
+ return 0;
+ die(symmetric
+ ? "Invalid symmetric difference expression %s"
+ : "Invalid revision range %s", arg);
+ }
+
+ if (!symmetric) {
+ /* just A..B */
+ a_flags = flags_exclude;
+ } else {
+ /* A...B -- find merge bases between the two */
+ struct commit *a, *b;
+ struct commit_list *exclude;
+
+ a = (a_obj->type == OBJ_COMMIT
+ ? (struct commit *)a_obj
+ : lookup_commit_reference(a_obj->sha1));
+ b = (b_obj->type == OBJ_COMMIT
+ ? (struct commit *)b_obj
+ : lookup_commit_reference(b_obj->sha1));
+ if (!a || !b)
+ goto missing;
exclude = get_merge_bases(a, b, 1);
add_rev_cmdline_list(revs, exclude,
REV_CMD_MERGE_BASE,
@@ -1446,17 +1460,18 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
add_pending_commit_list(revs, exclude,
flags_exclude);
free_commit_list(exclude);
+
a_flags = flags | SYMMETRIC_LEFT;
- } else
- a_flags = flags_exclude;
- a->object.flags |= a_flags;
- b->object.flags |= flags;
- add_rev_cmdline(revs, &a->object, this,
+ }
+
+ a_obj->flags |= a_flags;
+ b_obj->flags |= flags;
+ add_rev_cmdline(revs, a_obj, this,
REV_CMD_LEFT, a_flags);
- add_rev_cmdline(revs, &b->object, next,
+ add_rev_cmdline(revs, b_obj, next,
REV_CMD_RIGHT, flags);
- add_pending_object(revs, &a->object, this);
- add_pending_object(revs, &b->object, next);
+ add_pending_object(revs, a_obj, this);
+ add_pending_object(revs, b_obj, next);
return 0;
}
*dotdot = '.';