aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorJavi Fontan <jfontan@gmail.com>2018-07-26 12:24:26 +0200
committerJavi Fontan <jfontan@gmail.com>2018-07-26 14:17:56 +0200
commit7418b411660aaa3d8d54eb602fda8accaed2833f (patch)
tree5f1bcba54814c30d74a29af8477e2e08cf83b5ca /plumbing
parenta716126aa7f9b77030d2e697db24d206d944f05d (diff)
downloadgo-git-7418b411660aaa3d8d54eb602fda8accaed2833f.tar.gz
plumbing/idxfile: fix bug searching in MemoryIndex
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/format/idxfile/idxfile.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/plumbing/format/idxfile/idxfile.go b/plumbing/format/idxfile/idxfile.go
index b196608..adeba44 100644
--- a/plumbing/format/idxfile/idxfile.go
+++ b/plumbing/format/idxfile/idxfile.go
@@ -72,7 +72,7 @@ func (idx *MemoryIndex) findHashIndex(h plumbing.Hash) int {
low := uint64(0)
for {
mid := (low + high) >> 1
- offset := mid + (mid << 2)
+ offset := mid * objectIDLength
cmp := bytes.Compare(h[:], data[offset:offset+objectIDLength])
if cmp < 0 {
@@ -83,7 +83,7 @@ func (idx *MemoryIndex) findHashIndex(h plumbing.Hash) int {
low = mid + 1
}
- if low < high {
+ if low > high {
break
}
}