summaryrefslogtreecommitdiff
path: root/revision.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2007-03-14 20:12:18 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-03-14 23:21:19 (GMT)
commit0a4ba7f8c6140c516f0ee073a6b71d0db24d6242 (patch)
tree3e05d7d4dbee708134f89884f2ac9f3d3be4313e /revision.c
parent822cac015589889c1a9e6d49a2c054b7f1b838ba (diff)
downloadgit-0a4ba7f8c6140c516f0ee073a6b71d0db24d6242.zip
git-0a4ba7f8c6140c516f0ee073a6b71d0db24d6242.tar.gz
git-0a4ba7f8c6140c516f0ee073a6b71d0db24d6242.tar.bz2
revision.c: explain what tree_difference does
This explains how tree_difference variable is used, and updates two places where the code knows symbolic constant REV_TREE_SAME is 0. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'revision.c')
-rw-r--r--revision.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/revision.c b/revision.c
index 3c2eb12..129d197 100644
--- a/revision.c
+++ b/revision.c
@@ -213,6 +213,13 @@ static int everybody_uninteresting(struct commit_list *orig)
return 1;
}
+/*
+ * The goal is to get REV_TREE_NEW as the result only if the
+ * diff consists of all '+' (and no other changes), and
+ * REV_TREE_DIFFERENT otherwise (of course if the trees are
+ * the same we want REV_TREE_SAME). That means that once we
+ * get to REV_TREE_DIFFERENT, we do not have to look any further.
+ */
static int tree_difference = REV_TREE_SAME;
static void file_add_remove(struct diff_options *options,
@@ -277,11 +284,11 @@ int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)
empty.buf = "";
empty.size = 0;
- tree_difference = 0;
+ tree_difference = REV_TREE_SAME;
retval = diff_tree(&empty, &real, "", &revs->pruning);
free(tree);
- return retval >= 0 && !tree_difference;
+ return retval >= 0 && (tree_difference == REV_TREE_SAME);
}
static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)