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>
Junio C Hamano committed
Mar 14, 2007 at 13:12 UTC
0a4ba7f8c6140c516f0ee073a6b71d0db24d6242
1 file changed
+9
-2
revision.c
+9
-2
@@ -213,6 +213,13 @@ static int everybody_uninteresting(struct commit_list *orig)
213
return 1;
214
}
215
216
+/*
217
+ * The goal is to get REV_TREE_NEW as the result only if the
218
+ * diff consists of all '+' (and no other changes), and
219
+ * REV_TREE_DIFFERENT otherwise (of course if the trees are
220
+ * the same we want REV_TREE_SAME). That means that once we
221
+ * get to REV_TREE_DIFFERENT, we do not have to look any further.
222
+ */
223
static int tree_difference = REV_TREE_SAME;
224
225
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)
284
empty.buf = "";
285
empty.size = 0;
286
280
- tree_difference = 0;
287
+ tree_difference = REV_TREE_SAME;
288
retval = diff_tree(&empty, &real, "", &revs->pruning);
289
free(tree);
290
284
- return retval >= 0 && !tree_difference;
291
+ return retval >= 0 && (tree_difference == REV_TREE_SAME);
292
}
293
294
static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)