tree-diff: no need to manually verify that there is no mode change for a path
Because if there is, such two tree entries would never be compared as equal - the code in base_name_compare() explicitly compares modes, if there is a change for dir bit, even for equal paths, entries would compare as different. The code I'm removing here is from 2005 April 262e82b4 (Fix diff-tree recursion), which pre-dates base_name_compare() introduction in 958ba6c9 (Introduce "base_name_compare()" helper function) by a month. Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kirill Smelkov committed
Feb 3, 2014 at 16:47 UTC
e197c2b650316f62e6dfee4fadcb4198a03b8325
1 file changed
+5
-10
tree-diff.c
+5
-10
@@ -23,6 +23,11 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2,
23
24
pathlen1 = tree_entry_len(&t1->entry);
25
pathlen2 = tree_entry_len(&t2->entry);
26
+
27
+ /*
28
+ * NOTE files and directories *always* compare differently,
29
+ * even when having the same name.
30
+ */
31
cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);
32
if (cmp < 0) {
33
show_entry(opt, "-", t1, base);
@@ -35,16 +40,6 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2,
40
if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)
41
return 0;
42
38
- /*
39
- * If the filemode has changed to/from a directory from/to a regular
40
- * file, we need to consider it a remove and an add.
41
- */
42
- if (S_ISDIR(mode1) != S_ISDIR(mode2)) {
43
- show_entry(opt, "-", t1, base);
44
- show_entry(opt, "+", t2, base);
45
- return 0;
46
- }
47
-
43
strbuf_add(base, path1, pathlen1);
44
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
45
if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {