git 711 B

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