git 638 B

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