Skip to content

Commit 27e98cf

Browse files
committed
refdb_fs: prepare arbitration of the root used for ref iteration
Instead of a hardcoded "refs", we may choose a different directory within the git directory as the root from which we look for references.
1 parent d906a87 commit 27e98cf

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/refdb_fs.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,26 +505,29 @@ static int iter_load_loose_paths(refdb_fs_backend *backend, refdb_fs_iter *iter)
505505
git_iterator *fsit = NULL;
506506
git_iterator_options fsit_opts = GIT_ITERATOR_OPTIONS_INIT;
507507
const git_index_entry *entry = NULL;
508+
const char *ref_prefix = GIT_REFS_DIR;
509+
size_t ref_prefix_len = strlen(ref_prefix);
508510

509511
if (!backend->commonpath) /* do nothing if no commonpath for loose refs */
510512
return 0;
511513

512514
fsit_opts.flags = backend->iterator_flags;
513515

514-
if ((error = git_buf_printf(&path, "%s/refs", backend->commonpath)) < 0 ||
516+
if ((error = git_buf_printf(&path, "%s/", backend->commonpath)) < 0 ||
517+
(error = git_buf_put(&path, ref_prefix, ref_prefix_len)) < 0 ||
515518
(error = git_iterator_for_filesystem(&fsit, path.ptr, &fsit_opts)) < 0) {
516519
git_buf_free(&path);
517520
return error;
518521
}
519522

520-
error = git_buf_sets(&path, GIT_REFS_DIR);
523+
error = git_buf_sets(&path, ref_prefix);
521524

522525
while (!error && !git_iterator_advance(&entry, fsit)) {
523526
const char *ref_name;
524527
struct packref *ref;
525528
char *ref_dup;
526529

527-
git_buf_truncate(&path, strlen(GIT_REFS_DIR));
530+
git_buf_truncate(&path, ref_prefix_len);
528531
git_buf_puts(&path, entry->path);
529532
ref_name = git_buf_cstr(&path);
530533

0 commit comments

Comments
 (0)