# [PATCH 2/3] init-db.c: normalize env var handling.

4 messages from 2005-04-20 to 2005-04-20. Participants: Zach Welch, Linus Torvalds.
Thread: https://gitlist.dev/t/156

## Zach Welch, 2005-04-20 04:28

Subject: [PATCH 2/3] init-db.c: normalize env var handling.
Message-ID: <mailbox-1242-1113971319-971926@spoon>
URL: https://gitlist.dev/e/mailbox-1242-1113971319-971926%40spoon

```
This patch applies on top of:
        [PATCH 1/3] init-db.c: cleanup comments

 init-db.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

Signed-Off-By: Zach Welch <zw@superlucidity.net>

Normalize init-db environment variable handling, allowing the creation
of object directories with something other than DEFAULT_DB_ENVIRONMENT.

--- a/init-db.c
+++ b/init-db.c
@@ -22,15 +22,10 @@ int main(int argc, char **argv)
 	}
 
 	sha1_dir = getenv(DB_ENVIRONMENT);
-	if (sha1_dir) {
-		struct stat st;
-		if (!stat(sha1_dir, &st) && S_ISDIR(st.st_mode))
-			return 0;
-		fprintf(stderr, "DB_ENVIRONMENT set to bad directory %s: ", sha1_dir);
+	if (!sha1_dir) {
+		sha1_dir = DEFAULT_DB_ENVIRONMENT;
+		fprintf(stderr, "defaulting to local storage area\n");
 	}
-
-	sha1_dir = DEFAULT_DB_ENVIRONMENT;
-	fprintf(stderr, "defaulting to private storage area\n");
 	len = strlen(sha1_dir);
 	if (mkdir(sha1_dir, 0755) < 0) {
 		if (errno != EEXIST) {

```

## Linus Torvalds, 2005-04-20 04:45

Subject: Re: [PATCH 2/3] init-db.c: normalize env var handling.
Message-ID: <Pine.LNX.4.58.0504192142040.6467@ppc970.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.58.0504192142040.6467%40ppc970.osdl.org
In-Reply-To: <mailbox-1242-1113971319-971926@spoon>

```


On Tue, 19 Apr 2005, Zach Welch wrote:
>
> This patch applies on top of:
>         [PATCH 1/3] init-db.c: cleanup comments
> 
>  init-db.c |   11 +++--------
>  1 files changed, 3 insertions(+), 8 deletions(-)
> 
> Signed-Off-By: Zach Welch <zw@superlucidity.net>
> 
> Normalize init-db environment variable handling, allowing the creation
> of object directories with something other than DEFAULT_DB_ENVIRONMENT.
> 
> --- a/init-db.c
> +++ b/init-db.c

For future reference, this is in the wrong order.

You should have "checkin comment" first, then "signed-off-by", then a line 
with three dashes, and then "administrative trivia".

Ie I'd much rather see the email look like

	Normalize init-db environment variable handling, allowing the creation
	of object directories with something other than DEFAULT_DB_ENVIRONMENT.
	
	Signed-Off-By: Zach Welch <zw@superlucidity.net>
	---
	This patch applies on top of:
	        [PATCH 1/3] init-db.c: cleanup comments
	
	 init-db.c |   11 +++--------
	 1 files changed, 3 insertions(+), 8 deletions(-)
	
	.. actual patch goes here ..

since otherwise I'll just have to edit it that way. I like seeing the 
administrative stuff (diffstat etc), but I don't want to have it in the 
commit message, and that's exactly what the "---" marker is for - my tools 
will automatically cut it off as if it was a signature (or the beginning 
of the patch).

		Linus

```

## Zach Welch, 2005-04-20 04:55

Subject: Re: [PATCH 2/3] init-db.c: normalize env var handling.
Message-ID: <4265E0BB.4040700@superlucidity.net>
URL: https://gitlist.dev/e/4265E0BB.4040700%40superlucidity.net
In-Reply-To: <Pine.LNX.4.58.0504192142040.6467@ppc970.osdl.org>

```
Linus Torvalds wrote:
> For future reference, this is in the wrong order.

I feel even more abashed for my earlier scripting faux pas. Would you
like me to resend them to you off-list?

Cheers,

Zach



```

## Linus Torvalds, 2005-04-20 04:59

Subject: Re: [PATCH 2/3] init-db.c: normalize env var handling.
Message-ID: <Pine.LNX.4.58.0504192159000.6467@ppc970.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.58.0504192159000.6467%40ppc970.osdl.org
In-Reply-To: <4265E0BB.4040700@superlucidity.net>

```


On Tue, 19 Apr 2005, Zach Welch wrote:
> 
> I feel even more abashed for my earlier scripting faux pas. Would you
> like me to resend them to you off-list?

No, I edited them and applied them (the first series, I'll have to think 
about the second one).

It's only when there are tens of patches that it gets really old really 
quickly to edit things by hand. Three I can handle ;)

		Linus

```
