hashcache now permits partial hash matches (common practice in git)
parent
3c06dfc763
commit
a096f7ea19
12
hashcache
12
hashcache
|
@ -39,8 +39,16 @@ _retrieve()
|
||||||
hash="$1"
|
hash="$1"
|
||||||
|
|
||||||
# if multiple identical hashes exist, then the last one takes precedence
|
# if multiple identical hashes exist, then the last one takes precedence
|
||||||
# (ideally, such a thing should never happen, but it's best to be prepared)
|
# (ideally, such a thing should never happen, but it's best to be prepared);
|
||||||
grep "^$hash " "$cachefile" \
|
# note that we *do not* check for a space after the hash, which allows for
|
||||||
|
# partial hashes to be matched (common practice for Git due to its long
|
||||||
|
# hashes); this may cause problems with other version control systems---such
|
||||||
|
# as SVN---that use revision numbers, in which case this implementation will
|
||||||
|
# have to be changed to accept a flag for whether or not to accept partial
|
||||||
|
# matches, or it must operate under the assumption that the commits are always
|
||||||
|
# processed in reverse order and (as such) the tail in this pipeline will
|
||||||
|
# always return the intended result
|
||||||
|
grep "^$hash" "$cachefile" \
|
||||||
| tail -n1 \
|
| tail -n1 \
|
||||||
| cut -d' ' -f2-
|
| cut -d' ' -f2-
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue