summaryrefslogtreecommitdiff
path: root/src/refdb_fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/refdb_fs.c')
-rw-r--r--src/refdb_fs.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 49b567c08..49fc292a9 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -1090,7 +1090,6 @@ fail:
static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, const git_oid *old, const git_oid *new, const git_signature *author, const char *message);
static int has_reflog(git_repository *repo, const char *name);
-/* We only write if it's under heads/, remotes/ or notes/ or if it already has a log */
static int should_write_reflog(int *write, git_repository *repo, const char *name)
{
int error, logall;
@@ -1103,17 +1102,26 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam
if (logall == GIT_LOGALLREFUPDATES_UNSET)
logall = !git_repository_is_bare(repo);
- if (!logall) {
+ *write = 0;
+ switch (logall) {
+ case GIT_LOGALLREFUPDATES_FALSE:
*write = 0;
- } else if (has_reflog(repo, name)) {
- *write = 1;
- } else if (!git__prefixcmp(name, GIT_REFS_HEADS_DIR) ||
- !git__strcmp(name, GIT_HEAD_FILE) ||
- !git__prefixcmp(name, GIT_REFS_REMOTES_DIR) ||
- !git__prefixcmp(name, GIT_REFS_NOTES_DIR)) {
+ break;
+
+ case GIT_LOGALLREFUPDATES_TRUE:
+ /* Only write if it already has a log,
+ * or if it's under heads/, remotes/ or notes/
+ */
+ *write = has_reflog(repo, name) ||
+ !git__prefixcmp(name, GIT_REFS_HEADS_DIR) ||
+ !git__strcmp(name, GIT_HEAD_FILE) ||
+ !git__prefixcmp(name, GIT_REFS_REMOTES_DIR) ||
+ !git__prefixcmp(name, GIT_REFS_NOTES_DIR);
+ break;
+
+ case GIT_LOGALLREFUPDATES_ALWAYS:
*write = 1;
- } else {
- *write = 0;
+ break;
}
return 0;
@@ -1713,7 +1721,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
if ((error == GIT_ENOTFOUND) &&
((error = create_new_reflog_file(git_buf_cstr(&log_path))) < 0))
goto cleanup;
-
+
if ((error = reflog_parse(log,
git_buf_cstr(&log_file), git_buf_len(&log_file))) < 0)
goto cleanup;
@@ -1973,7 +1981,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
goto cleanup;
}
- if (git_path_isdir(git_buf_cstr(&new_path)) &&
+ if (git_path_isdir(git_buf_cstr(&new_path)) &&
(git_futils_rmdir_r(git_buf_cstr(&new_path), NULL, GIT_RMDIR_SKIP_NONEMPTY) < 0)) {
error = -1;
goto cleanup;