mirror of
https://github.com/git/git
synced 2024-08-25 02:35:46 +00:00
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 April262e82b4
(Fix diff-tree recursion), which pre-dates base_name_compare() introduction in958ba6c9
(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>
This commit is contained in:
parent
eeb3f32868
commit
e197c2b650
15
tree-diff.c
15
tree-diff.c
|
@ -23,6 +23,11 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2,
|
||||||
|
|
||||||
pathlen1 = tree_entry_len(&t1->entry);
|
pathlen1 = tree_entry_len(&t1->entry);
|
||||||
pathlen2 = tree_entry_len(&t2->entry);
|
pathlen2 = tree_entry_len(&t2->entry);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE files and directories *always* compare differently,
|
||||||
|
* even when having the same name.
|
||||||
|
*/
|
||||||
cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);
|
cmp = base_name_compare(path1, pathlen1, mode1, path2, pathlen2, mode2);
|
||||||
if (cmp < 0) {
|
if (cmp < 0) {
|
||||||
show_entry(opt, "-", t1, base);
|
show_entry(opt, "-", t1, base);
|
||||||
|
@ -35,16 +40,6 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2,
|
||||||
if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)
|
if (!DIFF_OPT_TST(opt, FIND_COPIES_HARDER) && !hashcmp(sha1, sha2) && mode1 == mode2)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*
|
|
||||||
* If the filemode has changed to/from a directory from/to a regular
|
|
||||||
* file, we need to consider it a remove and an add.
|
|
||||||
*/
|
|
||||||
if (S_ISDIR(mode1) != S_ISDIR(mode2)) {
|
|
||||||
show_entry(opt, "-", t1, base);
|
|
||||||
show_entry(opt, "+", t2, base);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
strbuf_add(base, path1, pathlen1);
|
strbuf_add(base, path1, pathlen1);
|
||||||
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
|
if (DIFF_OPT_TST(opt, RECURSIVE) && S_ISDIR(mode1)) {
|
||||||
if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {
|
if (DIFF_OPT_TST(opt, TREE_IN_RECURSIVE)) {
|
||||||
|
|
Loading…
Reference in a new issue