Skip to content

Commit 77f1460

Browse files
authored
Merge pull request libgit2#4915 from pks-t/pks/refdb-minor-refactorings
refdb_fs: refactor error handling in `refdb_reflog_fs__delete`
2 parents bc21965 + 8dde7e1 commit 77f1460

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/refdb_fs.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,28 +2046,27 @@ static int refdb_reflog_fs__rename(git_refdb_backend *_backend, const char *old_
20462046

20472047
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name)
20482048
{
2049-
int error;
2049+
refdb_fs_backend *backend = (refdb_fs_backend *) _backend;
20502050
git_buf path = GIT_BUF_INIT;
2051-
2052-
git_repository *repo;
2053-
refdb_fs_backend *backend;
2051+
int error;
20542052

20552053
assert(_backend && name);
20562054

2057-
backend = (refdb_fs_backend *) _backend;
2058-
repo = backend->repo;
2055+
if ((error = retrieve_reflog_path(&path, backend->repo, name)) < 0)
2056+
goto out;
20592057

2060-
error = retrieve_reflog_path(&path, repo, name);
2058+
if (!git_path_exists(path.ptr))
2059+
goto out;
20612060

2062-
if (!error && git_path_exists(path.ptr)) {
2063-
error = p_unlink(path.ptr);
2064-
refdb_fs_backend__try_delete_empty_ref_hierarchie(backend, name, true);
2065-
}
2061+
if ((error = p_unlink(path.ptr)) < 0)
2062+
goto out;
20662063

2064+
refdb_fs_backend__try_delete_empty_ref_hierarchie(backend, name, true);
2065+
2066+
out:
20672067
git_buf_dispose(&path);
20682068

20692069
return error;
2070-
20712070
}
20722071

20732072
int git_refdb_backend_fs(

0 commit comments

Comments
 (0)