mirror of
https://git.zx2c4.com/cgit
synced 2024-11-23 17:08:41 +00:00
Display notes from namespace
We must not leave it at its default behaviour, as that results in notes from the root namespace being used and ignoring notes from the current namespace, since it is not namespace aware. We can handle this by instructing it to not load the default refs, and providing a set of extra refs to use. The provided extra refs are globs rather than ref names, so we should escape them to be sure. We get an annoying warning if the provided ref does not exist, so we check whether the ref exists before attempting to provide it. Signed-off-by: Richard Maw <richard.maw@gmail.com>
This commit is contained in:
parent
c8d5732367
commit
5c6966b0c8
32
cgit.c
32
cgit.c
@ -587,7 +587,39 @@ static int prepare_repo_cmd(void)
|
|||||||
* load local configuration from the git repository, so we do them both while
|
* load local configuration from the git repository, so we do them both while
|
||||||
* the HOME variables are unset. */
|
* the HOME variables are unset. */
|
||||||
setup_git_directory_gently(&nongit);
|
setup_git_directory_gently(&nongit);
|
||||||
|
if (get_git_namespace()) {
|
||||||
|
struct display_notes_opt opt = {
|
||||||
|
.use_default_notes = 0,
|
||||||
|
.extra_notes_refs = STRING_LIST_INIT_NODUP,
|
||||||
|
};
|
||||||
|
struct strbuf namespaced_note_ref = STRBUF_INIT;
|
||||||
|
struct strbuf glob_escaped = STRBUF_INIT;
|
||||||
|
|
||||||
|
strbuf_add(&namespaced_note_ref, get_git_namespace(),
|
||||||
|
strlen(get_git_namespace()));
|
||||||
|
strbuf_add(&namespaced_note_ref, "refs/notes/commits",
|
||||||
|
strlen("refs/notes/commits"));
|
||||||
|
|
||||||
|
if (ref_exists(namespaced_note_ref.buf)) {
|
||||||
|
if (has_glob_specials(namespaced_note_ref.buf)) {
|
||||||
|
for (const char *c = namespaced_note_ref.buf; *c; c++) {
|
||||||
|
if (is_glob_special(*c))
|
||||||
|
strbuf_addchars(&glob_escaped, '\\', 1);
|
||||||
|
strbuf_addchars(&glob_escaped, *c, 1);
|
||||||
|
}
|
||||||
|
string_list_append(&opt.extra_notes_refs, glob_escaped.buf);
|
||||||
|
} else {
|
||||||
|
string_list_append(&opt.extra_notes_refs, namespaced_note_ref.buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init_display_notes(&opt);
|
||||||
|
string_list_clear(&opt.extra_notes_refs, 1);
|
||||||
|
strbuf_release(&glob_escaped);
|
||||||
|
strbuf_release(&namespaced_note_ref);
|
||||||
|
} else {
|
||||||
init_display_notes(NULL);
|
init_display_notes(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (nongit) {
|
if (nongit) {
|
||||||
const char *name = ctx.repo->name;
|
const char *name = ctx.repo->name;
|
||||||
|
Loading…
Reference in New Issue
Block a user