summaryrefslogtreecommitdiffstats
path: root/scripts/git
blob: 644055e54017028bf0d7e7ce132cbd030a273d06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
#
# Wrapper around 'git' that doesn't think we are root

import os
import shutil
import sys

os.environ['PSEUDO_UNLOAD'] = '1'

# calculate path to the real 'git'
path = os.environ['PATH']
# we need to remove our path but also any other copy of this script which
# may be present, e.g. eSDK.
replacements = [os.path.dirname(sys.argv[0])]
for p in path.split(":"):
    if p.endswith("/scripts"):
        replacements.append(p)
for r in replacements:
    path = path.replace(r, '/ignoreme')
real_git = shutil.which('git', path=path)

if len(sys.argv) == 1:
    os.execl(real_git, 'git')

os.execv(real_git, sys.argv)