@@ -1090,7 +1090,6 @@ static int packed_write(refdb_fs_backend *backend)
10901090static 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 );
10911091static int has_reflog (git_repository * repo , const char * name );
10921092
1093- /* We only write if it's under heads/, remotes/ or notes/ or if it already has a log */
10941093static int should_write_reflog (int * write , git_repository * repo , const char * name )
10951094{
10961095 int error , logall ;
@@ -1103,17 +1102,26 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam
11031102 if (logall == GIT_LOGALLREFUPDATES_UNSET )
11041103 logall = !git_repository_is_bare (repo );
11051104
1106- if (!logall ) {
1105+ * write = 0 ;
1106+ switch (logall ) {
1107+ case GIT_LOGALLREFUPDATES_FALSE :
11071108 * write = 0 ;
1108- } else if (has_reflog (repo , name )) {
1109- * write = 1 ;
1110- } else if (!git__prefixcmp (name , GIT_REFS_HEADS_DIR ) ||
1111- !git__strcmp (name , GIT_HEAD_FILE ) ||
1112- !git__prefixcmp (name , GIT_REFS_REMOTES_DIR ) ||
1113- !git__prefixcmp (name , GIT_REFS_NOTES_DIR )) {
1109+ break ;
1110+
1111+ case GIT_LOGALLREFUPDATES_TRUE :
1112+ /* Only write if it already has a log,
1113+ * or if it's under heads/, remotes/ or notes/
1114+ */
1115+ * write = has_reflog (repo , name ) ||
1116+ !git__prefixcmp (name , GIT_REFS_HEADS_DIR ) ||
1117+ !git__strcmp (name , GIT_HEAD_FILE ) ||
1118+ !git__prefixcmp (name , GIT_REFS_REMOTES_DIR ) ||
1119+ !git__prefixcmp (name , GIT_REFS_NOTES_DIR );
1120+ break ;
1121+
1122+ case GIT_LOGALLREFUPDATES_ALWAYS :
11141123 * write = 1 ;
1115- } else {
1116- * write = 0 ;
1124+ break ;
11171125 }
11181126
11191127 return 0 ;
@@ -1713,7 +1721,7 @@ static int refdb_reflog_fs__read(git_reflog **out, git_refdb_backend *_backend,
17131721 if ((error == GIT_ENOTFOUND ) &&
17141722 ((error = create_new_reflog_file (git_buf_cstr (& log_path ))) < 0 ))
17151723 goto cleanup ;
1716-
1724+
17171725 if ((error = reflog_parse (log ,
17181726 git_buf_cstr (& log_file ), git_buf_len (& log_file ))) < 0 )
17191727 goto cleanup ;
@@ -1973,7 +1981,7 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
19731981 goto cleanup ;
19741982 }
19751983
1976- if (git_path_isdir (git_buf_cstr (& new_path )) &&
1984+ if (git_path_isdir (git_buf_cstr (& new_path )) &&
19771985 (git_futils_rmdir_r (git_buf_cstr (& new_path ), NULL , GIT_RMDIR_SKIP_NONEMPTY ) < 0 )) {
19781986 error = -1 ;
19791987 goto cleanup ;
0 commit comments