Skip to content

Commit 6361226

Browse files
pks-tgitster
authored andcommitted
reftable/stack: drop only use of get_locked_file_path()
We've got a single callsite where we call `get_locked_file_path()`. As we're about to convert our usage of the lockfile subsystem to instead be used via a compatibility shim we'd have to implement more logic for this single callsite. While that would be okay if Git was the only supposed user of the reftable library, it's a bit more awkward when considering that we have to reimplement this functionality for every user of the library eventually. Refactor the code such that we don't call `get_locked_file_path()` anymore. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 01e4994 commit 6361226

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

reftable/stack.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,9 +1493,15 @@ static int stack_compact_range(struct reftable_stack *st,
14931493
*/
14941494
for (i = 0; i < nlocks; i++) {
14951495
struct lock_file *table_lock = &table_locks[i];
1496-
char *table_path = get_locked_file_path(table_lock);
1497-
unlink(table_path);
1498-
reftable_free(table_path);
1496+
const char *lock_path = get_lock_file_path(table_lock);
1497+
1498+
reftable_buf_reset(&table_name);
1499+
err = reftable_buf_add(&table_name, lock_path,
1500+
strlen(lock_path) - strlen(".lock"));
1501+
if (err)
1502+
continue;
1503+
1504+
unlink(table_name.buf);
14991505
}
15001506

15011507
done:

0 commit comments

Comments
 (0)