summaryrefslogtreecommitdiff
path: root/cache.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-01-27 18:45:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-01-27 18:45:33 (GMT)
commitd0956cfa8ef8b3668ea6adc94b27f5dcdc93bde0 (patch)
tree188ea26d10feaf884b59423fdf8c8bafeb73e718 /cache.h
parentc380cf85a79c78d9dceb9290c9d4017d30804521 (diff)
parent08f555cb82f92797ca0aa0d6ba32e6872f1331e5 (diff)
downloadgit-d0956cfa8ef8b3668ea6adc94b27f5dcdc93bde0.zip
git-d0956cfa8ef8b3668ea6adc94b27f5dcdc93bde0.tar.gz
git-d0956cfa8ef8b3668ea6adc94b27f5dcdc93bde0.tar.bz2
Merge branch 'mh/safe-create-leading-directories'
Code clean-up and protection against concurrent write access to the ref namespace. * mh/safe-create-leading-directories: rename_tmp_log(): on SCLD_VANISHED, retry rename_tmp_log(): limit the number of remote_empty_directories() attempts rename_tmp_log(): handle a possible mkdir/rmdir race rename_ref(): extract function rename_tmp_log() remove_dir_recurse(): handle disappearing files and directories remove_dir_recurse(): tighten condition for removing unreadable dir lock_ref_sha1_basic(): if locking fails with ENOENT, retry lock_ref_sha1_basic(): on SCLD_VANISHED, retry safe_create_leading_directories(): add new error value SCLD_VANISHED cmd_init_db(): when creating directories, handle errors conservatively safe_create_leading_directories(): introduce enum for return values safe_create_leading_directories(): always restore slash at end of loop safe_create_leading_directories(): split on first of multiple slashes safe_create_leading_directories(): rename local variable safe_create_leading_directories(): add explicit "slash" pointer safe_create_leading_directories(): reduce scope of local variable safe_create_leading_directories(): fix format of "if" chaining
Diffstat (limited to 'cache.h')
-rw-r--r--cache.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/cache.h b/cache.h
index 763c961..dc040fb 100644
--- a/cache.h
+++ b/cache.h
@@ -737,8 +737,29 @@ enum sharedrepo {
};
int git_config_perm(const char *var, const char *value);
int adjust_shared_perm(const char *path);
-int safe_create_leading_directories(char *path);
-int safe_create_leading_directories_const(const char *path);
+
+/*
+ * Create the directory containing the named path, using care to be
+ * somewhat safe against races. Return one of the scld_error values
+ * to indicate success/failure.
+ *
+ * SCLD_VANISHED indicates that one of the ancestor directories of the
+ * path existed at one point during the function call and then
+ * suddenly vanished, probably because another process pruned the
+ * directory while we were working. To be robust against this kind of
+ * race, callers might want to try invoking the function again when it
+ * returns SCLD_VANISHED.
+ */
+enum scld_error {
+ SCLD_OK = 0,
+ SCLD_FAILED = -1,
+ SCLD_PERMS = -2,
+ SCLD_EXISTS = -3,
+ SCLD_VANISHED = -4
+};
+enum scld_error safe_create_leading_directories(char *path);
+enum scld_error safe_create_leading_directories_const(const char *path);
+
int mkdir_in_gitdir(const char *path);
extern void home_config_paths(char **global, char **xdg, char *file);
extern char *expand_user_path(const char *path);