| Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 | 
|  | 2 | # | 
|  | 3 | # Wrapper around 'git' that doesn't think we are root | 
|  | 4 |  | 
|  | 5 | import os | 
|  | 6 | import shutil | 
|  | 7 | import sys | 
|  | 8 |  | 
|  | 9 | os.environ['PSEUDO_UNLOAD'] = '1' | 
|  | 10 |  | 
|  | 11 | # calculate path to the real 'git' | 
|  | 12 | path = os.environ['PATH'] | 
|  | 13 | # we need to remove our path but also any other copy of this script which | 
|  | 14 | # may be present, e.g. eSDK. | 
|  | 15 | replacements = [os.path.dirname(sys.argv[0])] | 
|  | 16 | for p in path.split(":"): | 
|  | 17 | if p.endswith("/scripts"): | 
|  | 18 | replacements.append(p) | 
|  | 19 | for r in replacements: | 
|  | 20 | path = path.replace(r, '/ignoreme') | 
|  | 21 | real_git = shutil.which('git', path=path) | 
|  | 22 |  | 
|  | 23 | if len(sys.argv) == 1: | 
|  | 24 | os.execl(real_git, 'git') | 
|  | 25 |  | 
|  | 26 | os.execv(real_git, sys.argv) |