commit b5939e792834bd521922ec7fd218b15ba590eb57
parent 3ed1be17c156a40a5b25cda0afe98c951f5117b4
Author: Chris Bracken <chris@bracken.jp>
Date: Fri, 20 Feb 2026 21:14:48 +0900
repo: simplify special file lookups
Diffstat:
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/git/repo.c b/src/git/repo.c
@@ -150,21 +150,20 @@ void gitrepo_load_filesystem_metadata(GitRepo* repo,
}
free(git_path_maybe);
- char* owner_path = path_concat(git_path, "owner");
- char* desc_path = path_concat(git_path, "description");
- char* url_path = path_concat(git_path, "url");
-
repo->name = gitrepo_name_from_path(repo_path);
repo->short_name = gitrepo_shortname_from_name(repo->name);
- repo->owner = first_line_of_file(fs, owner_path);
- repo->description = first_line_of_file(fs, desc_path);
- repo->clone_url = first_line_of_file(fs, url_path);
+
+ static const char* metadata_files[] = {"owner", "description", "url"};
+ char** target_fields[] = {&repo->owner, &repo->description, &repo->clone_url};
+
+ for (size_t i = 0; i < 3; i++) {
+ char* full_path = path_concat(git_path, metadata_files[i]);
+ *target_fields[i] = first_line_of_file(fs, full_path);
+ free(full_path);
+ }
free(repo_path);
free(git_path);
- free(owner_path);
- free(desc_path);
- free(url_path);
}
static void gitrepo_add_special_file(GitRepo* repo,