Git development
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Brian Foster <brian.foster@innova-card.com>,
	Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: [PATCH 2/4] revision: make tree comparison functions take commits rather than trees
Date: Mon, 3 Nov 2008 11:35:35 -0800 (PST)	[thread overview]
Message-ID: <alpine.LFD.2.00.0811031133590.3419@nehalem.linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.2.00.0811031132520.3419@nehalem.linux-foundation.org>


From: Linus Torvalds <torvalds@linux-foundation.org>
Date: Mon, 3 Nov 2008 10:45:41 -0800
Subject: [PATCH 2/4] revision: make tree comparison functions take commits rather than trees

This will make it easier to do various clever things that don't depend
on the pure tree contents.  It also makes the parameter passing much
simpler - the callers doesn't really look at trees anywhere else, and
it's really the function that should look at the low-level details.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---

This is a trivial no-op change that just passes commits instead of trees 
to the commit compare functions. The whole point is that we can now start 
comparing them based on not just contents of the trees, but other 
attributes too.

The patch makes no semantic changes. Just preparation.

 revision.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/revision.c b/revision.c
index d45f05a..56b09eb 100644
--- a/revision.c
+++ b/revision.c
@@ -294,8 +294,11 @@ static void file_change(struct diff_options *options,
 	DIFF_OPT_SET(options, HAS_CHANGES);
 }
 
-static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)
+static int rev_compare_tree(struct rev_info *revs, struct commit *parent, struct commit *commit)
 {
+	struct tree *t1 = parent->tree;
+	struct tree *t2 = commit->tree;
+
 	if (!t1)
 		return REV_TREE_NEW;
 	if (!t2)
@@ -308,12 +311,13 @@ static int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree
 	return tree_difference;
 }
 
-static int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
+static int rev_same_tree_as_empty(struct rev_info *revs, struct commit *commit)
 {
 	int retval;
 	void *tree;
 	unsigned long size;
 	struct tree_desc empty, real;
+	struct tree *t1 = commit->tree;
 
 	if (!t1)
 		return 0;
@@ -347,7 +351,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 		return;
 
 	if (!commit->parents) {
-		if (rev_same_tree_as_empty(revs, commit->tree))
+		if (rev_same_tree_as_empty(revs, commit))
 			commit->object.flags |= TREESAME;
 		return;
 	}
@@ -367,7 +371,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 			die("cannot simplify commit %s (because of %s)",
 			    sha1_to_hex(commit->object.sha1),
 			    sha1_to_hex(p->object.sha1));
-		switch (rev_compare_tree(revs, p->tree, commit->tree)) {
+		switch (rev_compare_tree(revs, p, commit)) {
 		case REV_TREE_SAME:
 			tree_same = 1;
 			if (!revs->simplify_history || (p->object.flags & UNINTERESTING)) {
@@ -387,7 +391,7 @@ static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)
 
 		case REV_TREE_NEW:
 			if (revs->remove_empty_trees &&
-			    rev_same_tree_as_empty(revs, p->tree)) {
+			    rev_same_tree_as_empty(revs, p)) {
 				/* We are adding all the specified
 				 * paths from this parent, so the
 				 * history beyond this parent is not
-- 
1.6.0.3.616.gf1239d6.dirty

  reply	other threads:[~2008-11-03 19:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-03 13:39 [Q] Abbreviated history graph? Brian Foster
2008-11-03 14:20 ` Santi Béjar
2008-11-03 14:55   ` Santi Béjar
2008-11-03 15:46   ` Brian Foster
2008-11-03 16:08     ` Santi Béjar
2008-11-03 19:32 ` Linus Torvalds
2008-11-03 19:33   ` [PATCH 1/4] Add a 'source' decorator for commits Linus Torvalds
2008-11-03 19:35     ` Linus Torvalds [this message]
2008-11-03 19:39       ` [PATCH 3/4] Make '--decorate' set an explicit 'show_decorations' flag Linus Torvalds
2008-11-03 19:43         ` [PATCH 4/4] Add support for 'namespace' history simplification Linus Torvalds
2008-11-03 21:45           ` Santi Béjar
2008-11-03 22:05             ` Linus Torvalds
2008-11-03 22:34               ` Santi Béjar
2008-11-03 22:28           ` Robin Rosenberg
2008-11-04 21:33           ` Clemens Buchacher
2008-11-03 20:15   ` [Q] Abbreviated history graph? Linus Torvalds
2008-11-03 20:34     ` Linus Torvalds
2008-11-04  8:45     ` Junio C Hamano

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=alpine.LFD.2.00.0811031133590.3419@nehalem.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=brian.foster@innova-card.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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