Diff options
| author | Bryce Kwon <bryce@brycekwon.com> | |
|---|---|---|
| committer | Bryce Kwon <bryce@brycekwon.com> | |
| commit | ||
| parent | ||
| tree | ||
| download | ||
Hand back the fallback branch rather than a copy
Diffstat (limited to 'source/cgit.c')
| -rw-r--r-- | source/cgit.c | 17 |
1 file changed, 4 insertions, 13 deletions
diff --git a/source/cgit.c b/source/cgit.c index c1c9fbc..d6fc0bc 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -926,22 +926,13 @@ static int find_current_ref(const struct reference *ref, void *data) static char *find_default_branch(struct cgit_repo *repo) { - struct refmatch match; - char *ref; + struct refmatch match = { .wanted = repo->defbranch }; - match.wanted = repo->defbranch; - match.first = NULL; - match.found = 0; refs_for_each_branch_ref(get_main_ref_store(the_repository), find_current_ref, &match); - if (match.found) - ref = match.wanted; - else - ref = match.first; - if (ref) - ref = xstrdup(ref); + if (!match.found) + return match.first; free(match.first); - - return ref; + return xstrdup(match.wanted); } static char *guess_defbranch(void) |
