diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 09:49:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 09:49:36 +0000 |
commit | 5ec6074f0633939fd17d94111d10c6c6b062978c (patch) | |
tree | bfaa17b5a64abc66c918e9c70969e519d9e1df8e /compat/unsetenv.c | |
parent | Initial commit. (diff) | |
download | git-upstream.tar.xz git-upstream.zip |
Adding upstream version 1:2.30.2.upstream/1%2.30.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compat/unsetenv.c')
-rw-r--r-- | compat/unsetenv.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/compat/unsetenv.c b/compat/unsetenv.c new file mode 100644 index 0000000..bf5fd70 --- /dev/null +++ b/compat/unsetenv.c @@ -0,0 +1,27 @@ +#include "../git-compat-util.h" + +void gitunsetenv (const char *name) +{ +#if !defined(__MINGW32__) + extern char **environ; +#endif + int src, dst; + size_t nmln; + + nmln = strlen(name); + + for (src = dst = 0; environ[src]; ++src) { + size_t enln; + enln = strlen(environ[src]); + if (enln > nmln) { + /* might match, and can test for '=' safely */ + if (0 == strncmp (environ[src], name, nmln) + && '=' == environ[src][nmln]) + /* matches, so skip */ + continue; + } + environ[dst] = environ[src]; + ++dst; + } + environ[dst] = NULL; +} |