From: Kevin Bracey <kevin@bracey.fi>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Kevin Bracey <kevin@bracey.fi>
Subject: [PATCH v3 10/9] revision.c: treat A...B merge bases as if manually specified
Date: Mon, 6 May 2013 19:51:36 +0300 [thread overview]
Message-ID: <1367859096-25909-1-git-send-email-kevin@bracey.fi> (raw)
In-Reply-To: <1367767977-14513-1-git-send-email-kevin@bracey.fi>
The documentation assures users that "A...B" is defined as 'r1 r2 --not
$(git merge-base --all r1 r2)'. This isn't in fact quite true, because
the calculated merge bases are not sent to add_rev_cmdline().
Previously, the effect was pretty minor - all that I can think of is
that "git rev-list --ancestry-path A B ^AB_base" works, but "git
rev-list --ancestry-path A...B" fails with a "no bottom commits" error.
But now that all history walking cares about bottom commits, this
failure to note the merge bases as bottoms can lead to worse results for
"A...B" compared to "A B ^AB_base".
So ensure that the calculated merge bases are sent to add_rev_cmdline(),
flagged as 'REV_CMD_MERGE_BASE'.
Signed-off-by: Kevin Bracey <kevin@bracey.fi>
---
revision.c | 9 +++++++--
revision.h | 2 ++
t/t6111-rev-list-treesame.sh | 4 ++++
3 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index 99a3432..aad16a6 100644
--- a/revision.c
+++ b/revision.c
@@ -1305,12 +1305,16 @@ void init_revisions(struct rev_info *revs, const char *prefix)
static void add_pending_commit_list(struct rev_info *revs,
struct commit_list *commit_list,
+ int whence,
unsigned int flags)
{
while (commit_list) {
struct object *object = &commit_list->item->object;
+ const char *sha1 = sha1_to_hex(object->sha1);
object->flags |= flags;
- add_pending_object(revs, object, sha1_to_hex(object->sha1));
+ if (whence != REV_CMD_NONE)
+ add_rev_cmdline(revs, object, sha1, whence, flags);
+ add_pending_object(revs, object, sha1);
commit_list = commit_list->next;
}
}
@@ -1332,7 +1336,7 @@ static void prepare_show_merge(struct rev_info *revs)
add_pending_object(revs, &head->object, "HEAD");
add_pending_object(revs, &other->object, "MERGE_HEAD");
bases = get_merge_bases(head, other, 1);
- add_pending_commit_list(revs, bases, UNINTERESTING);
+ add_pending_commit_list(revs, bases, REV_CMD_MERGE_BASE, UNINTERESTING);
free_commit_list(bases);
head->object.flags |= SYMMETRIC_LEFT;
@@ -1420,6 +1424,7 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
if (symmetric) {
exclude = get_merge_bases(a, b, 1);
add_pending_commit_list(revs, exclude,
+ REV_CMD_MERGE_BASE,
flags_exclude);
free_commit_list(exclude);
a_flags = flags | SYMMETRIC_LEFT;
diff --git a/revision.h b/revision.h
index 765630a..b2ac5a3 100644
--- a/revision.h
+++ b/revision.h
@@ -32,10 +32,12 @@ struct rev_cmdline_info {
struct object *item;
const char *name;
enum {
+ REV_CMD_NONE,
REV_CMD_REF,
REV_CMD_PARENTS_ONLY,
REV_CMD_LEFT,
REV_CMD_RIGHT,
+ REV_CMD_MERGE_BASE,
REV_CMD_REV
} whence;
unsigned flags;
diff --git a/t/t6111-rev-list-treesame.sh b/t/t6111-rev-list-treesame.sh
index 689d357..ded0b1a 100755
--- a/t/t6111-rev-list-treesame.sh
+++ b/t/t6111-rev-list-treesame.sh
@@ -161,6 +161,10 @@ check_result 'F' B..F --ancestry-path --simplify-merges -- file
check_result 'F D' B..F --first-parent
check_result 'F' B..F --first-parent -- file
+# E...F should be equivalent to E F ^B, and be able to drop D as above.
+check_result 'F' E F ^B -- file
+check_result 'F' E...F -- file
+
# Any sort of full history of C..F should show D, as it's the connection to C,
# and it differs from it.
check_result 'F D B' C..F
--
1.8.3.rc0.28.g4b02ef5
next prev parent reply other threads:[~2013-05-06 19:19 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-05 15:32 [PATCH v3 0/9] History traversal refinements Kevin Bracey
2013-05-05 15:32 ` [PATCH v3 1/9] decorate.c: compact table when growing Kevin Bracey
2013-05-05 15:32 ` [PATCH v3 2/9] t6019: test file dropped in -s ours merge Kevin Bracey
2013-05-05 15:32 ` [PATCH v3 3/9] t6111: new TREESAME test set Kevin Bracey
2013-05-06 19:37 ` Junio C Hamano
2013-05-06 20:36 ` Junio C Hamano
2013-05-07 15:19 ` Kevin Bracey
2013-05-07 16:28 ` Junio C Hamano
2013-05-05 15:32 ` [PATCH v3 4/9] rev-list-options.txt: correct TREESAME for P Kevin Bracey
2013-05-05 15:32 ` [PATCH v3 5/9] revision.c: Make --full-history consider more merges Kevin Bracey
2013-05-06 20:45 ` Junio C Hamano
2013-05-07 14:46 ` Kevin Bracey
2013-05-07 15:21 ` Junio C Hamano
2013-05-05 15:32 ` [PATCH v3 6/9] t6012: update test for tweaked full-history traversal Kevin Bracey
2013-05-05 15:32 ` [PATCH v3 7/9] simplify-merges: never remove all TREESAME parents Kevin Bracey
2013-05-05 15:32 ` [PATCH v3 8/9] simplify-merges: drop merge from irrelevant side branch Kevin Bracey
2013-05-05 15:32 ` [PATCH v3 9/9] revision.c: discount side branches when computing TREESAME Kevin Bracey
2013-05-06 16:51 ` Kevin Bracey [this message]
2013-05-06 21:24 ` [PATCH v3 10/9] revision.c: treat A...B merge bases as if manually specified Junio C Hamano
2013-05-07 15:52 ` Kevin Bracey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1367859096-25909-1-git-send-email-kevin@bracey.fi \
--to=kevin@bracey.fi \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).