diff options
author | Alberto Cortés <alberto@sourced.tech> | 2017-03-01 18:09:18 +0100 |
---|---|---|
committer | Alberto Cortés <alberto@sourced.tech> | 2017-03-03 16:19:20 +0100 |
commit | b3aa41afcca829cfb3e2e71be052078152497b3c (patch) | |
tree | ee25a6cd5a310a2b50a7dcb74fe4275252c8298e /plumbing/object/treenoder.go | |
parent | 047a795df6d5a0d5dd0782297cea918e4a4a6e10 (diff) | |
download | go-git-b3aa41afcca829cfb3e2e71be052078152497b3c.tar.gz |
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.
Diffstat (limited to 'plumbing/object/treenoder.go')
-rw-r--r-- | plumbing/object/treenoder.go | 10 |
1 files changed, 10 insertions, 0 deletions
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()...) } |