Skip to content

Commit f104277

Browse files
committed
refdb: make should_write_reflog use git_references instead of char *
1 parent d3387ce commit f104277

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

‎src/refdb_fs.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,9 +1147,10 @@ static int packed_delete(refdb_fs_backend *backend, const char *ref_name)
11471147
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);
11481148
static int has_reflog(git_repository *repo, const char *name);
11491149

1150-
static int should_write_reflog(int *write, git_repository *repo, const char *name)
1150+
static int should_write_reflog(int *write, refdb_fs_backend *backend, const git_reference *ref)
11511151
{
11521152
int error, logall;
1153+
git_repository *repo = backend->repo;
11531154

11541155
error = git_repository__cvar(&logall, repo, GIT_CVAR_LOGALLREFUPDATES);
11551156
if (error < 0)
@@ -1169,11 +1170,11 @@ static int should_write_reflog(int *write, git_repository *repo, const char *nam
11691170
/* Only write if it already has a log,
11701171
* or if it's under heads/, remotes/ or notes/
11711172
*/
1172-
*write = has_reflog(repo, name) ||
1173-
!git__prefixcmp(name, GIT_REFS_HEADS_DIR) ||
1174-
!git__strcmp(name, GIT_HEAD_FILE) ||
1175-
!git__prefixcmp(name, GIT_REFS_REMOTES_DIR) ||
1176-
!git__prefixcmp(name, GIT_REFS_NOTES_DIR);
1173+
*write = has_reflog(repo, ref->name) ||
1174+
!git__prefixcmp(ref->name, GIT_REFS_HEADS_DIR) ||
1175+
!git__strcmp(ref->name, GIT_HEAD_FILE) ||
1176+
!git__prefixcmp(ref->name, GIT_REFS_REMOTES_DIR) ||
1177+
!git__prefixcmp(ref->name, GIT_REFS_NOTES_DIR);
11771178
break;
11781179

11791180
case GIT_LOGALLREFUPDATES_ALWAYS:
@@ -1369,7 +1370,7 @@ static int refdb_fs_backend__write_tail(
13691370
}
13701371

13711372
if ((flags & GIT_REFDB__SKIP_REFLOG) == 0) {
1372-
if ((error = should_write_reflog(&should_write, backend->repo, ref->name)) < 0)
1373+
if ((error = should_write_reflog(&should_write, backend, ref)) < 0)
13731374
goto on_error;
13741375

13751376
if (should_write) {
@@ -1526,7 +1527,7 @@ static int refdb_fs_backend__delete_tail(
15261527
}
15271528

15281529
if ((flags & GIT_REFDB__SKIP_REFLOG) == 0) {
1529-
if ((error = should_write_reflog(&should_write, backend->repo, ref->name)) < 0)
1530+
if ((error = should_write_reflog(&should_write, backend, ref)) < 0)
15301531
goto cleanup;
15311532

15321533
if (should_write) {

0 commit comments

Comments
 (0)