diff options
Diffstat (limited to 'scripts/git')
-rwxr-xr-x | scripts/git | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/git b/scripts/git new file mode 100755 index 0000000000..689adbf9dd --- /dev/null +++ b/scripts/git | |||
@@ -0,0 +1,30 @@ | |||
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 | |||
9 | import os | ||
10 | import shutil | ||
11 | import sys | ||
12 | |||
13 | os.environ['PSEUDO_UNLOAD'] = '1' | ||
14 | |||
15 | # calculate path to the real 'git' | ||
16 | path = os.environ['PATH'] | ||
17 | # we need to remove our path but also any other copy of this script which | ||
18 | # may be present, e.g. eSDK. | ||
19 | replacements = [os.path.dirname(sys.argv[0])] | ||
20 | for p in path.split(":"): | ||
21 | if p.endswith("/scripts"): | ||
22 | replacements.append(p) | ||
23 | for r in replacements: | ||
24 | path = path.replace(r, '/ignoreme') | ||
25 | real_git = shutil.which('git', path=path) | ||
26 | |||
27 | if len(sys.argv) == 1: | ||
28 | os.execl(real_git, 'git') | ||
29 | |||
30 | os.execv(real_git, sys.argv) | ||