diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-03-04 12:49:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-04 12:49:07 +0100 |
commit | f64e4b856865bc37f45e55ef094060481b53928e (patch) | |
tree | ddb2dc0c762cf47cd01e0110354ee0ba6d4c4558 /plumbing/object/treenoder.go | |
parent | 199317f082082fb8f168ad40a5cae134acfe4a16 (diff) | |
parent | b3aa41afcca829cfb3e2e71be052078152497b3c (diff) | |
download | go-git-f64e4b856865bc37f45e55ef094060481b53928e.tar.gz |
Merge pull request #300 from alcortesm/improvement-difftree-simplify-deprecated
difftree: simplify hash comparison with deprecated files modes
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()...) } |