Catch errors when writing an index that contains invalid objects.
[gitweb.git] / path.c
diff --git a/path.c b/path.c
index bb89fb02dc9a8a1a09492fb32d8708f952afe47e..d2c076d7cbad3a16a002897d926cc13633be4f77 100644 (file)
--- a/path.c
+++ b/path.c
@@ -279,7 +279,7 @@ int adjust_shared_perm(const char *path)
                            : 0));
        if (S_ISDIR(mode))
                mode |= S_ISGID;
-       if (chmod(path, mode) < 0)
+       if ((mode & st.st_mode) != mode && chmod(path, mode) < 0)
                return -2;
        return 0;
 }