Merge branch 'maint'
[gitweb.git] / sha1_file.c
index e89d24c01595aa8ea6c6306928639b40f3313a50..4e5ee1054f6a4f5d1f50c8f93a3f45d6a6b1c72a 100644 (file)
@@ -1399,9 +1399,10 @@ static int link_temp_to_file(const char *tmpfile, const char *filename)
        dir = strrchr(filename, '/');
        if (dir) {
                *dir = 0;
-               mkdir(filename, 0777);
-               if (adjust_shared_perm(filename))
+               if (!mkdir(filename, 0777) && adjust_shared_perm(filename)) {
+                       *dir = '/';
                        return -2;
+               }
                *dir = '/';
                if (!link(tmpfile, filename))
                        return 0;