From b3aa41afcca829cfb3e2e71be052078152497b3c Mon Sep 17 00:00:00 2001 From: Alberto Cortés Date: Wed, 1 Mar 2017 18:09:18 +0100 Subject: difftree: simplify hash comparison with deprecated files modes Difftree hash comparisson was quite complex because the hashes of deprecated files were diferent from the hashes of regular files. But git's difftree really treat them as equal. This patch fix this by making treenoder return the same hash for regular files than for deprecated files; now the hash comparison function is just a bytes.Equal call. --- plumbing/object/treenoder.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'plumbing/object/treenoder.go') diff --git a/plumbing/object/treenoder.go b/plumbing/object/treenoder.go index 89fcdb1..80cd9b0 100644 --- a/plumbing/object/treenoder.go +++ b/plumbing/object/treenoder.go @@ -45,7 +45,17 @@ func (t *treeNoder) String() string { return "treeNoder <" + t.name + ">" } +// The hash of a treeNoder is the result of concatenating the hash of +// its contents and its mode; that way the difftree algorithm will +// detect changes in the contents of files and also in their mode. +// +// Files with Regular and Deprecated file modes are considered the same +// for the purpose of difftree, so Regular will be used as the mode for +// Deprecated files here. func (t *treeNoder) Hash() []byte { + if t.mode == filemode.Deprecated { + return append(t.hash[:], filemode.Regular.Bytes()...) + } return append(t.hash[:], t.mode.Bytes()...) } -- cgit