summaryrefslogtreecommitdiff
path: root/tree-diff.c
diff options
context:
space:
mode:
authorKirill Smelkov <kirr@mns.spb.ru>2014-02-24 16:21:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-03-20 22:04:32 (GMT)
commit9bc0619655dfd183eb5d0d47b4d63a511acd5c64 (patch)
tree0263de146ea5cab07d8d75a20fb7346219654970 /tree-diff.c
parent903bba68abb8153f181d854e9a7075b893f1303f (diff)
downloadgit-9bc0619655dfd183eb5d0d47b4d63a511acd5c64.zip
git-9bc0619655dfd183eb5d0d47b4d63a511acd5c64.tar.gz
git-9bc0619655dfd183eb5d0d47b4d63a511acd5c64.tar.bz2
tree-diff: rename compare_tree_entry -> tree_entry_pathcmp
Since previous commit, this function does not compare entry hashes, and mode are compared fully outside of it. So what it does is compare entry names and DIR bit in modes. Reflect this in its name. Add documentation stating the semantics, and move the note about files/dirs comparison to it. Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'tree-diff.c')
-rw-r--r--tree-diff.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/tree-diff.c b/tree-diff.c
index ce3ca72..58e790a 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -9,7 +9,14 @@
static void show_path(struct strbuf *base, struct diff_options *opt,
struct tree_desc *t1, struct tree_desc *t2);
-static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2)
+/*
+ * Compare two tree entries, taking into account only path/S_ISDIR(mode),
+ * but not their sha1's.
+ *
+ * NOTE files and directories *always* compare differently, even when having
+ * the same name - thanks to base_name_compare().
+ */
+static int tree_entry_pathcmp(struct tree_desc *t1, struct tree_desc *t2)
{
unsigned mode1, mode2;
const char *path1, *path2;
@@ -22,10 +29,6 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2)
pathlen1 = tree_entry_len(&t1->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);
return cmp;
}
@@ -168,7 +171,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
continue;
}
- cmp = compare_tree_entry(t1, t2);
+ cmp = tree_entry_pathcmp(t1, t2);
/* t1 = t2 */
if (cmp == 0) {