Code

gitweb: accept trailing "/" in $project_list
[git.git] / sha1_file.c
index 7829d615d4b6d85283aa8469be5307c419d70292..889fe7183065ae8bc12821aadebb69a17bc7635c 100644 (file)
@@ -68,6 +68,35 @@ static struct cached_object *find_cached_object(const unsigned char *sha1)
        return NULL;
 }
 
+int mkdir_in_gitdir(const char *path)
+{
+       if (mkdir(path, 0777)) {
+               int saved_errno = errno;
+               struct stat st;
+               struct strbuf sb = STRBUF_INIT;
+
+               if (errno != EEXIST)
+                       return -1;
+               /*
+                * Are we looking at a path in a symlinked worktree
+                * whose original repository does not yet have it?
+                * e.g. .git/rr-cache pointing at its original
+                * repository in which the user hasn't performed any
+                * conflict resolution yet?
+                */
+               if (lstat(path, &st) || !S_ISLNK(st.st_mode) ||
+                   strbuf_readlink(&sb, path, st.st_size) ||
+                   !is_absolute_path(sb.buf) ||
+                   mkdir(sb.buf, 0777)) {
+                       strbuf_release(&sb);
+                       errno = saved_errno;
+                       return -1;
+               }
+               strbuf_release(&sb);
+       }
+       return adjust_shared_perm(path);
+}
+
 int safe_create_leading_directories(char *path)
 {
        char *pos = path + offset_1st_component(path);
@@ -1505,7 +1534,7 @@ static int unpack_object_header(struct packed_git *p,
        enum object_type type;
 
        /* use_pack() assures us we have [base, base + 20) available
-        * as a range that we can look at at.  (Its actually the hash
+        * as a range that we can look at.  (Its actually the hash
         * size that is assured.)  With our object header encoding
         * the maximum deflated object size is 2^137, which is just
         * insane, so we know won't exceed what we have been given.