Skip to content

Commit d947033

Browse files
mhaggergitster
authored andcommitted
refs: use same lock_file object for both ref-packing functions
Use a single struct lock_file for both pack_refs() and repack_without_ref(). Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3b4ae6d commit d947033

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

refs.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ static void prune_refs(struct ref_to_prune *r)
20922092
}
20932093
}
20942094

2095-
static struct lock_file packed;
2095+
static struct lock_file packlock;
20962096

20972097
int pack_refs(unsigned int flags)
20982098
{
@@ -2102,7 +2102,7 @@ int pack_refs(unsigned int flags)
21022102
memset(&cbdata, 0, sizeof(cbdata));
21032103
cbdata.flags = flags;
21042104

2105-
fd = hold_lock_file_for_update(&packed, git_path("packed-refs"),
2105+
fd = hold_lock_file_for_update(&packlock, git_path("packed-refs"),
21062106
LOCK_DIE_ON_ERROR);
21072107
cbdata.refs_file = fdopen(fd, "w");
21082108
if (!cbdata.refs_file)
@@ -2121,8 +2121,8 @@ int pack_refs(unsigned int flags)
21212121
* assign -1 to the lock file descriptor so that commit_lock_file()
21222122
* won't try to close() it.
21232123
*/
2124-
packed.fd = -1;
2125-
if (commit_lock_file(&packed) < 0)
2124+
packlock.fd = -1;
2125+
if (commit_lock_file(&packlock) < 0)
21262126
die_errno("unable to overwrite old ref-pack file");
21272127
prune_refs(cbdata.ref_to_prune);
21282128
return 0;
@@ -2176,8 +2176,6 @@ static int repack_ref_fn(struct ref_entry *entry, void *cb_data)
21762176
return 0;
21772177
}
21782178

2179-
static struct lock_file packlock;
2180-
21812179
static int repack_without_ref(const char *refname)
21822180
{
21832181
int fd;

0 commit comments

Comments
 (0)