1
0
Fork 0

hashcache now permits partial hash matches (common practice in git)

master
Mike Gerwitz 2013-03-09 09:44:37 -05:00
parent 3c06dfc763
commit a096f7ea19
No known key found for this signature in database
GPG Key ID: F22BB8158EE30EAB
1 changed files with 10 additions and 2 deletions

View File

@ -39,7 +39,15 @@ _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);
# 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" \ grep "^$hash" "$cachefile" \
| tail -n1 \ | tail -n1 \
| cut -d' ' -f2- | cut -d' ' -f2-