Commit bf4484a3a9b50a9bc85902b6fd72003f40c950c2

Tracey Emery 2020-02-18T21:24:33

work if someone sets got_max_commits_display to 1, and check prev_id

diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index d682a07..eb0a376 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -1065,7 +1065,7 @@ gw_commits(struct gw_trans *gw_trans)
 			goto done;
 	}
 
-	if (gw_trans->page > 0) {
+	if (gw_trans->page > 0 && gw_trans->prev_id) {
 		if (asprintf(&href_prev,
 		    "?path=%s&page=%d&action=commits&commit=%s&prev=%s",
 		    gw_trans->repo_name, gw_trans->page - 1,
@@ -1326,7 +1326,7 @@ gw_briefs(struct gw_trans *gw_trans)
 			goto done;
 	}
 
-	if (gw_trans->page > 0) {
+	if (gw_trans->page > 0 && gw_trans->prev_id) {
 		if (asprintf(&href_prev,
 		    "?path=%s&page=%d&action=briefs&commit=%s&prev=%s",
 		    gw_trans->repo_name, gw_trans->page - 1,
@@ -3224,7 +3224,8 @@ gw_get_commits(struct gw_trans * gw_trans, struct gw_header *header,
 		error = got_object_open_as_commit(&commit, gw_trans->repo, id);
 			if (error)
 				goto done;
-		if (limit == 1 && chk_multi == 0) {
+		if (limit == 1 && chk_multi == 0 &&
+		    gw_trans->gw_conf->got_max_commits_display != 1) {
 			error = gw_get_commit(gw_trans, header, commit, id);
 			if (error)
 				goto done;