Ensure config-directory exists before using it.

This commit is contained in:
Oliver Tappe
2013-10-15 21:35:13 +02:00
parent d679195b5a
commit c69048fe86

View File

@@ -1,4 +1,4 @@
From 8ad851dd7da047374242cc025bf16852f8829da0 Mon Sep 17 00:00:00 2001
From 54aaa3773f83a1706140ef842e537b5dc5f37568 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Tue, 13 Aug 2013 08:07:25 +0200
Subject: git-web--browse.sh: use "open" on Haiku
@@ -23,7 +23,7 @@ index 1d72ec7..e3f254c 100755
1.8.3.4
From 8f777b37b553698d5497b2742a01bfc4139c6b63 Mon Sep 17 00:00:00 2001
From e42686b933c0999c3c83cac79ceff073ce2bbc32 Mon Sep 17 00:00:00 2001
From: Ingo Weinhold <ingo_weinhold@gmx.de>
Date: Tue, 13 Aug 2013 21:03:59 +0200
Subject: On Haiku use the user settings directory instead of HOME
@@ -75,3 +75,39 @@ index 04ff148..8668534 100644
char *git_path_submodule(const char *path, const char *fmt, ...)
--
1.8.3.4
From 80ed8e810eaebbecf10a20bac95c1e43fc14d2d5 Mon Sep 17 00:00:00 2001
From: Oliver Tappe <zooey@hirschkaefer.de>
Date: Tue, 15 Oct 2013 21:34:09 +0200
Subject: Ensure config-directory exists before using it.
diff --git a/config.c b/config.c
index 7a85ebd..10be1af 100644
--- a/config.c
+++ b/config.c
@@ -1343,6 +1343,7 @@ int git_config_set_multivar_in_file(const char *config_filename,
int ret;
struct lock_file *lock = NULL;
char *filename_buf = NULL;
+ char *config_dir = NULL;
/* parse-key returns negative; flip the sign to feed exit(3) */
ret = 0 - git_config_parse_key(key, &store.key, &store.baselen);
@@ -1354,6 +1355,12 @@ int git_config_set_multivar_in_file(const char *config_filename,
if (!config_filename)
config_filename = filename_buf = git_pathdup("config");
+ config_dir = xstrdup(config_filename);
+ * find_last_dir_sep(config_dir) = '\0';
+ if (access(config_dir, F_OK) != 0)
+ mkdir(config_dir, 0755);
+ free(config_dir);
+
/*
* The lock serves a purpose in addition to locking: the new
* contents of .git/config will be written into it.
--
1.8.3.4