blob: 689adbf9ddac2425bbedab78408f42dd9ee7f8eb [file] [log] [blame]
Andrew Geisslerd5838332022-05-27 11:33:10 -05001#!/usr/bin/env python3
2#
Patrick Williams92b42cb2022-09-03 06:53:57 -05003# Copyright OpenEmbedded Contributors
4#
5# SPDX-License-Identifier: MIT
6#
Andrew Geisslerd5838332022-05-27 11:33:10 -05007# Wrapper around 'git' that doesn't think we are root
8
9import os
10import shutil
11import sys
12
13os.environ['PSEUDO_UNLOAD'] = '1'
14
15# calculate path to the real 'git'
16path = 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.
19replacements = [os.path.dirname(sys.argv[0])]
20for p in path.split(":"):
21 if p.endswith("/scripts"):
22 replacements.append(p)
23for r in replacements:
24 path = path.replace(r, '/ignoreme')
25real_git = shutil.which('git', path=path)
26
27if len(sys.argv) == 1:
28 os.execl(real_git, 'git')
29
30os.execv(real_git, sys.argv)