cgit

commit 7421857b4da9b8523032f08824bca9f3e3ebec4e

Author: Lars Hjemli <hjemli@gmail.com>

ui-plain.c: add support for path-selected submodule links

In ui-plain.c, the links generated for submodule entry ignored the fact
that the entry was in fact a submodule. This patch adds proper submodule
links to the plain directory listings.

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

 ui-plain.c | 9 ++++++---


diff --git a/ui-plain.c b/ui-plain.c
index 733db4de6758b1b00533a9e2581c2895cc4331c0..2abd210c0f5afd1871b00e6d53eaddb929b39ff0 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -97,11 +97,14 @@ {
 	char *fullpath;
 
 	fullpath = buildpath(base, baselen, path);
-	if (!S_ISDIR(mode))
+	if (!S_ISDIR(mode) && !S_ISGITLINK(mode))
 		fullpath[strlen(fullpath) - 1] = 0;
 	html("  <li>");
-	cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
-			fullpath);
+	if (S_ISGITLINK(mode)) {
+		cgit_submodule_link(NULL, fullpath, sha1_to_hex(sha1));
+	} else
+		cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.sha1,
+				fullpath);
 	html("</li>\n");
 	match = 2;
 }