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