aboutsummaryrefslogtreecommitdiffstats
path: root/git-compat-util.h
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2022-03-17 10:57:59 +0100
committerJohannes Schindelin <johannes.schindelin@gmx.de>2022-03-24 00:31:42 +0100
commit1f480d5127b746c2345701b86f7e15ecbd3377a3 (patch)
tree7061ed3b122a5b45cfe11e2dc18d20f129da6601 /git-compat-util.h
parent4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a (diff)
parent4d0b43aa765a0056c88381eea862364c95e358ca (diff)
downloadgit-1f480d5127b746c2345701b86f7e15ecbd3377a3.tar.gz
Sync with 2.34.2
* maint-2.34: Git 2.34.2 Git 2.33.2 Git 2.32.1 Git 2.31.2 GIT-VERSION-GEN: bump to v2.33.1 Git 2.30.3 setup_git_directory(): add an owner check for the top-level directory Add a function to determine whether a path is owned by the current user
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 1229c8296b..e30a374a84 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -430,6 +430,18 @@ static inline int git_offset_1st_component(const char *path)
#define is_valid_path(path) 1
#endif
+#ifndef is_path_owned_by_current_user
+static inline int is_path_owned_by_current_uid(const char *path)
+{
+ struct stat st;
+ if (lstat(path, &st))
+ return 0;
+ return st.st_uid == geteuid();
+}
+
+#define is_path_owned_by_current_user is_path_owned_by_current_uid
+#endif
+
#ifndef find_last_dir_sep
static inline char *git_find_last_dir_sep(const char *path)
{