mirror of
https://github.com/frej/fast-export.git
synced 2026-01-21 05:32:04 +01:00
Avoid crash during rev-parse when the default encoding is ascii
In some locales the default encoding is ascii in which case subprocess.check_output() will fail if it is given a non-ascii ref as one of the arguments. By forcing the ref to be utf8 we will avoid a crash while still behaving correctly when the default encoding is utf8. The credits for this fix go to Nikita Bazhinov for discovering the fix and Chris J Billington for explaining it. Co-Authored-By: Nikita Bazhinov <nbazhinov@syntellect.ru> Co-Authored-By: Chris J Billington <chrisjbillington@gmail.com>
This commit is contained in:
@@ -132,7 +132,8 @@ def get_git_sha1(name,type='heads'):
|
||||
try:
|
||||
# use git-rev-parse to support packed refs
|
||||
ref="refs/%s/%s" % (type,name.decode('utf8'))
|
||||
l=subprocess.check_output(["git", "rev-parse", "--verify", "--quiet", ref])
|
||||
l=subprocess.check_output(["git", "rev-parse", "--verify",
|
||||
"--quiet", ref.encode('utf8')])
|
||||
if l == None or len(l) == 0:
|
||||
return None
|
||||
return l[0:40]
|
||||
|
||||
Reference in New Issue
Block a user