about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--cgit.c10
-rw-r--r--ui-shared.c3
2 files changed, 9 insertions, 4 deletions
diff --git a/cgit.c b/cgit.c
index 8795085..cefeddf 100644
--- a/cgit.c
+++ b/cgit.c
@@ -207,15 +207,19 @@ int find_current_ref(const char *refname, const unsigned char *sha1,
 char *find_default_branch(struct cgit_repo *repo)
 {
 	struct refmatch info;
+	char *ref;
 
 	info.req_ref = repo->defbranch;
 	info.first_ref = NULL;
 	info.match = 0;
 	for_each_branch_ref(find_current_ref, &info);
 	if (info.match)
-		return info.req_ref;
+		ref = info.req_ref;
 	else
-		return info.first_ref;
+		ref = info.first_ref;
+	if (ref)
+		ref = xstrdup(ref);
+	return ref;
 }
 
 static int prepare_repo_cmd(struct cgit_context *ctx)
@@ -241,7 +245,7 @@ static int prepare_repo_cmd(struct cgit_context *ctx)
 	ctx->page.title = fmt("%s - %s", ctx->repo->name, ctx->repo->desc);
 
 	if (!ctx->qry.head) {
-		ctx->qry.head = xstrdup(find_default_branch(ctx->repo));
+		ctx->qry.head = find_default_branch(ctx->repo);
 		ctx->repo->defbranch = ctx->qry.head;
 	}
 
diff --git a/ui-shared.c b/ui-shared.c
index 209af6e..4280a70 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -518,7 +518,8 @@ void add_hidden_formfields(int incl_head, int incl_search, char *page)
 		html_hidden("url", url);
 	}
 
-	if (incl_head && strcmp(ctx.qry.head, ctx.repo->defbranch))
+	if (incl_head && ctx.qry.head && ctx.repo->defbranch &&
+	    strcmp(ctx.qry.head, ctx.repo->defbranch))
 		html_hidden("h", ctx.qry.head);
 
 	if (ctx.qry.sha1)
to be more clever about capacities, but I don't think it's worth it. 2022-02-20Clear edit buffer before running commandJune McEnroe Otherwise a command that switches windows will update the status line while the edit buffer still has input "pending", showing an indicator. 2022-02-20Show indicator in status when window has pending inputJune McEnroe 2022-02-20Use separate edit buffers for each IDJune McEnroe 2022-02-20Make sure new cap is actually larger than new lengthJune McEnroe 2022-02-20Remove unused mbs.len field from struct EditJune McEnroe 2022-02-19Remove unneeded includes in ui.cJune McEnroe 2022-02-19Reimplement tab completeJune McEnroe 2022-02-19Handle errors from editFn, etc.June McEnroe 2022-02-19Reimplement text macrosJune McEnroe 2022-02-19Factor out input handling to input.cJune McEnroe 2022-02-19Factor out window management to window.cJune McEnroe 2022-02-19Enable -Wmissing-prototypesJune McEnroe In other words, warn when a function is missing static. I don't see why this isn't in -Wextra. 2022-02-19Fix edit.[ch] license notice additional permissionsJune McEnroe 2022-02-19Run line editing testsJune McEnroe I know, it feels wrong. 2022-02-18Implement new line editing "library"June McEnroe Losing tab complete and text macros, for now. This new implementation works on an instance of a struct and does not interact with the rest of catgirl, making it possible to copy into another project. Unlike existing line editing libraries, this one is entirely abstract and can be rendered externally. My goal with this library is to be able to implement vi mode. Since it operates on struct instances rather than globals, it might also be possible to give catgirl separate line editing buffers for each window, which would be a nice UX improvement. 2022-02-18Simplify cursor positioning in inputJune McEnroe Do some extra work by adding the portion before the cursor to the input window twice, but simplify the interaction with the split point. This fixes the awkward behaviour when moving the cursor across colour codes where the code would be partially interpreted up to the cursor. 2022-02-18Fix M-f orderingJune McEnroe 2022-02-12Move sandman build to scripts/MakefileJune McEnroe 2022-02-12Use compat_readpassphrase.c on LinuxJune McEnroe 2022-02-12Copy RPP defines from oconfigureJune McEnroe