summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Turner <dturner@twopensource.com>2015-11-10 11:42:38 (GMT)
committerJeff King <peff@peff.net>2015-11-20 09:52:01 (GMT)
commiteb33876c262bec79a127b82a3a853ad00665d894 (patch)
treefe8f353bfc0a177d4df5c345cf005625778c97ee
parent7bd9bcf372d4c03bb7034346d72ae1318e2d0742 (diff)
downloadgit-eb33876c262bec79a127b82a3a853ad00665d894.zip
git-eb33876c262bec79a127b82a3a853ad00665d894.tar.gz
git-eb33876c262bec79a127b82a3a853ad00665d894.tar.bz2
initdb: make safe_create_dir public
Soon we will want to create initdb functions for ref backends, and code from initdb that calls this function needs to move into the files backend. So this function needs to be public. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Jeff King <peff@peff.net>
-rw-r--r--builtin/init-db.c12
-rw-r--r--cache.h8
-rw-r--r--path.c12
3 files changed, 20 insertions, 12 deletions
diff --git a/builtin/init-db.c b/builtin/init-db.c
index f59f407..07229d6 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -24,18 +24,6 @@ static int init_shared_repository = -1;
static const char *init_db_template_dir;
static const char *git_link;
-static void safe_create_dir(const char *dir, int share)
-{
- if (mkdir(dir, 0777) < 0) {
- if (errno != EEXIST) {
- perror(dir);
- exit(1);
- }
- }
- else if (share && adjust_shared_perm(dir))
- die(_("Could not make %s writable by group"), dir);
-}
-
static void copy_templates_1(struct strbuf *path, struct strbuf *template,
DIR *dir)
{
diff --git a/cache.h b/cache.h
index 3ba0b8f..4e13ddb 100644
--- a/cache.h
+++ b/cache.h
@@ -1747,4 +1747,12 @@ void stat_validity_update(struct stat_validity *sv, int fd);
int versioncmp(const char *s1, const char *s2);
void sleep_millisec(int millisec);
+/*
+ * Create a directory and (if share is nonzero) adjust its permissions
+ * according to the shared_repository setting. Only use this for
+ * directories under $GIT_DIR. Don't use it for working tree
+ * directories.
+ */
+void safe_create_dir(const char *dir, int share);
+
#endif /* CACHE_H */
diff --git a/path.c b/path.c
index c740c4f..9d1ab1f 100644
--- a/path.c
+++ b/path.c
@@ -740,6 +740,18 @@ int adjust_shared_perm(const char *path)
return 0;
}
+void safe_create_dir(const char *dir, int share)
+{
+ if (mkdir(dir, 0777) < 0) {
+ if (errno != EEXIST) {
+ perror(dir);
+ exit(1);
+ }
+ }
+ else if (share && adjust_shared_perm(dir))
+ die(_("Could not make %s writable by group"), dir);
+}
+
static int have_same_root(const char *path1, const char *path2)
{
int is_abs1, is_abs2;