]> git.ipfire.org Git - thirdparty/git.git/blobdiff - path.c
dir.h: move DTYPE defines from cache.h
[thirdparty/git.git] / path.c
diff --git a/path.c b/path.c
index d73146b6cd266a9d051c334ae63bb91426da0a33..7c1cd8182a81b9e8892960707cff8a0f7ff174cb 100644 (file)
--- a/path.c
+++ b/path.c
@@ -1,18 +1,24 @@
 /*
  * Utilities for paths and pathnames
  */
-#include "cache.h"
+#include "git-compat-util.h"
+#include "abspath.h"
+#include "environment.h"
+#include "gettext.h"
+#include "hex.h"
 #include "repository.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "dir.h"
 #include "worktree.h"
+#include "setup.h"
 #include "submodule-config.h"
 #include "path.h"
 #include "packfile.h"
 #include "object-store.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
+#include "wrapper.h"
 
 static int get_st_mode_bits(const char *path, int *mode)
 {
@@ -347,7 +353,8 @@ static void init_common_trie(void)
  * Helper function for update_common_dir: returns 1 if the dir
  * prefix is common.
  */
-static int check_common(const char *unmatched, void *value, void *baton)
+static int check_common(const char *unmatched, void *value,
+                       void *baton UNUSED)
 {
        struct common_dir *dir = value;
 
@@ -733,7 +740,7 @@ char *interpolate_path(const char *path, int real_home)
        struct strbuf user_path = STRBUF_INIT;
        const char *to_copy = path;
 
-       if (path == NULL)
+       if (!path)
                goto return_null;
 
        if (skip_prefix(path, "%(prefix)/", &path))
@@ -901,7 +908,13 @@ int adjust_shared_perm(const char *path)
        if (S_ISDIR(old_mode)) {
                /* Copy read bits to execute bits */
                new_mode |= (new_mode & 0444) >> 2;
-               new_mode |= FORCE_DIR_SET_GID;
+
+               /*
+                * g+s matters only if any extra access is granted
+                * based on group membership.
+                */
+               if (FORCE_DIR_SET_GID && (new_mode & 060))
+                       new_mode |= FORCE_DIR_SET_GID;
        }
 
        if (((old_mode ^ new_mode) & ~S_IFMT) &&
@@ -1413,7 +1426,7 @@ int is_ntfs_dotgit(const char *name)
 
        for (;;) {
                c = *(name++);
-               if (!c || c == '\\' || c == '/' || c == ':')
+               if (!c || is_xplatform_dir_sep(c) || c == ':')
                        return 1;
                if (c != '.' && c != ' ')
                        return 0;