]> git.ipfire.org Git - thirdparty/git.git/blob - compat/unsetenv.c
sha1_file.c: move find_cached_object up so sha1_object_info can use it
[thirdparty/git.git] / compat / unsetenv.c
1 #include "../git-compat-util.h"
2
3 void gitunsetenv (const char *name)
4 {
5 extern char **environ;
6 int src, dst;
7 size_t nmln;
8
9 nmln = strlen(name);
10
11 for (src = dst = 0; environ[src]; ++src) {
12 size_t enln;
13 enln = strlen(environ[src]);
14 if (enln > nmln) {
15 /* might match, and can test for '=' safely */
16 if (0 == strncmp (environ[src], name, nmln)
17 && '=' == environ[src][nmln])
18 /* matches, so skip */
19 continue;
20 }
21 environ[dst] = environ[src];
22 ++dst;
23 }
24 environ[dst] = NULL;
25 }