cgit

commit a2ddc10479ec463708e422ca5ce7ec02c22a7d02

Author: Lars Hjemli <hjemli@gmail.com>

Change commit-view to expect h parameter, not id

The change makes the commit-page benefit from repo.defbranch.

Signed-off-by: Lars Hjemli <hjemli@gmail.com>

 cgit.c | 2 +-
 ui-commit.c | 2 +-
 ui-log.c | 3 +--
 ui-summary.c | 16 ++++++++++------


diff --git a/cgit.c b/cgit.c
index b282a67d17bd24e7bf16610e5c7ce48b775c7e70..9b4815d9acdf155a44d2b0c5bb4e9de7dabf098f 100644
--- a/cgit.c
+++ b/cgit.c
@@ -116,7 +116,7 @@ 			       cgit_query_path);
 	} else if (!strcmp(cgit_query_page, "tree")) {
 		cgit_print_tree(cgit_query_head, cgit_query_sha1, cgit_query_path);
 	} else if (!strcmp(cgit_query_page, "commit")) {
-		cgit_print_commit(cgit_query_sha1);
+		cgit_print_commit(cgit_query_head);
 	} else if (!strcmp(cgit_query_page, "view")) {
 		cgit_print_view(cgit_query_sha1, cgit_query_path);
 	} else if (!strcmp(cgit_query_page, "diff")) {




diff --git a/ui-commit.c b/ui-commit.c
index 8011dfcc14ffaf953d5abb32f9cf7728cf04933a..93eb8fd156690d585f63f6ad936e2cf4b42832c9 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -197,7 +197,7 @@ 		}
 		html("<tr><th>parent</th>"
 		     "<td colspan='2' class='sha1'>"
 		     "<a href='");
-		query = fmt("id=%s", sha1_to_hex(p->item->object.sha1));
+		query = fmt("h=%s", sha1_to_hex(p->item->object.sha1));
 		html_attr(cgit_pageurl(cgit_query_repo, "commit", query));
 		htmlf("'>%s</a> (<a href='",
 		      sha1_to_hex(p->item->object.sha1));




diff --git a/ui-log.c b/ui-log.c
index 6d5509bd3bce42e795a2c640c47a916e0085a277..9d0ec025ddc50e54bb4017978166da73f8d2881e 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -34,7 +34,7 @@ 	html("");
 	strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", time);
 	html_txt(buf);
 	html("</td><td>");
-	char *qry = fmt("id=%s", sha1_to_hex(commit->object.sha1));
+	char *qry = fmt("h=%s", sha1_to_hex(commit->object.sha1));
 	char *url = cgit_pageurl(cgit_query_repo, "commit", qry);
 	html_link_open(url, NULL, NULL);
 	html_ntxt(cgit_max_msg_len, info->subject);
@@ -121,4 +121,3 @@ 		html("'>[next] ");
 	}
 	html("</div>");
 }
-




diff --git a/ui-summary.c b/ui-summary.c
index b99ea9840e6c2cece046a336f0f077d073fb9122..e7158cc954d9bb9b1f0edef58cca5894586f3051 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -33,7 +33,7 @@ 		html("");
 		html_txt(info->author);
 		html("</td><td>");
 		url = cgit_pageurl(cgit_query_repo, "commit",
-				   fmt("id=%s", sha1_to_hex(sha1)));
+				   fmt("h=%s", sha1_to_hex(sha1)));
 		html_link_open(url, NULL, NULL);
 		html_ntxt(cgit_max_msg_len, info->subject);
 		html_link_close();
@@ -52,17 +52,21 @@
 
 static void cgit_print_object_ref(struct object *obj)
 {
-	char *page, *url;
+	char *page, *arg, *url;
 
-	if (obj->type == OBJ_COMMIT)
+	if (obj->type == OBJ_COMMIT) {
 		page = "commit";
-	else if (obj->type == OBJ_TREE)
+		arg = "h";
+	} else if (obj->type == OBJ_TREE) {
 		page = "tree";
-	else
+		arg = "id";
+	} else {
 		page = "view";
+		arg = "id";
+	}
 
 	url = cgit_pageurl(cgit_query_repo, page,
-			   fmt("id=%s", sha1_to_hex(obj->sha1)));
+			   fmt("%s=%s", arg, sha1_to_hex(obj->sha1)));
 	html_link_open(url, NULL, NULL);
 	htmlf("%s %s", typename(obj->type),
 	      sha1_to_hex(obj->sha1));