Skip to content

Commit b9d147f

Browse files
pks-tgitster
authored andcommitted
environment: make getenv_safe() a public function
The `getenv_safe()` helper function helps to safely retrieve multiple environment values without the need to depend on platform-specific behaviour for the return value's lifetime. We'll make use of this function in a following patch, so let's make it available by making it non-static and adding a declaration. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1ff21c0 commit b9d147f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

environment.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
#include "cache.h"
1111
#include "branch.h"
12+
#include "environment.h"
1213
#include "repository.h"
1314
#include "config.h"
1415
#include "refs.h"
@@ -152,11 +153,7 @@ static char *expand_namespace(const char *raw_namespace)
152153
return strbuf_detach(&buf, NULL);
153154
}
154155

155-
/*
156-
* Wrapper of getenv() that returns a strdup value. This value is kept
157-
* in argv to be freed later.
158-
*/
159-
static const char *getenv_safe(struct strvec *argv, const char *name)
156+
const char *getenv_safe(struct strvec *argv, const char *name)
160157
{
161158
const char *value = getenv(name);
162159

environment.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef ENVIRONMENT_H
2+
#define ENVIRONMENT_H
3+
4+
#include "strvec.h"
5+
6+
/*
7+
* Wrapper of getenv() that returns a strdup value. This value is kept
8+
* in argv to be freed later.
9+
*/
10+
const char *getenv_safe(struct strvec *argv, const char *name);
11+
12+
#endif

0 commit comments

Comments
 (0)