git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
ZWZach Welch <zw@superlucidity.net>
Date
Apr 20, 2005, 04:28 UTC
Message-ID
<mailbox-1242-1113971319-971926@spoon>
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) {
Next: Linus Torvalds
Message 1 of 4 in “init-db.c: normalize env var handling.”
  1. 2/3 init-db.c: normalize env var handling.Zach Welch, Apr 20, 2005
  2. Linus TorvaldsApr 20, 2005
  3. Zach WelchApr 20, 2005
  4. Linus TorvaldsApr 20, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.