git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] t9502: test gitweb index hash formatting with modes

From
Travor Liu <travor_lzh@outlook.com>
Date
Jul 15, 2026, 09:11 UTC
Message-ID
<SA1PR10MB9977159B51766C2D9FFE98FD37F1F82@SA1PR10MB997715.namprd10.prod.outlook.com>
In-Reply-To
<SA1PR10MB997715AD62D7F2AF64EB1A9887F1F82@SA1PR10MB997715.namprd10.prod.outlook.com>
From: Travor Liu <travor_lzh@outlook.com>

gitweb should shorten and link the object IDs in commitdiff index lines even when Git includes the trailing file mode:

    index <old>..<new> 100644

Add coverage for that common form by rendering a commitdiff for a regular file modification. Check that the visible index line contains linked short blob IDs followed by the mode and file-type annotation, and that the full unlinked form is not emitted.

Signed-off-by: Travor Liu <travor_lzh@outlook.com>
---
 t/t9502-gitweb-standalone-parse-output.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff --git a/t/t9502-gitweb-standalone-parse-output.sh b/t/t9502-gitweb-standalone-parse-output.sh
index 81d5625..7f37e26 100755
--- a/t/t9502-gitweb-standalone-parse-output.sh
+++ b/t/t9502-gitweb-standalone-parse-output.sh
@@ -115,6 +115,20 @@ test_expect_success 'snapshot: hierarchical branch name (xx/test)' '
 '
 test_debug 'cat gitweb.headers'
 
+test_expect_success 'commitdiff: index line shortens hashes with mode' '
+	old_blob=$(git rev-parse HEAD:foo) &&
+	old_short=$(git rev-parse --short=7 HEAD:foo) &&
+	echo changed >foo &&
+	git commit -am "change foo" &&
+	new_blob=$(git rev-parse HEAD:foo) &&
+	new_short=$(git rev-parse --short=7 HEAD:foo) &&
+	gitweb_run "p=.git;a=commitdiff;h=HEAD" &&
+	grep ">${old_short}</a>\\.\\.<a [^>]*>${new_short}</a> 100644" \
+		gitweb.body >index_line &&
+	grep "<span class=\"info\"> (file)</span>" index_line &&
+	! grep "index ${old_blob}\\.\\.${new_blob} 100644" gitweb.body
+'
+
 # ----------------------------------------------------------------------
 # forks of projects
 
-- 
2.52.0
Previous: Travor LiuNext: Junio C Hamano
Message 3 of 6 in “gitweb: shorten commitdiff index hashes with file modes”
  1. 0/2 gitweb: shorten commitdiff index hashes with file modesTravor Liu, Jul 15, 2026
  2. 1/2 gitweb: shorten index hashes with trailing file modesTravor Liu, Jul 15, 2026
  3. 2/2 t9502: test gitweb index hash formatting with modesTravor Liu, Jul 15, 2026
  4. Junio C HamanoJul 17, 2026
  5. Travor LiuJul 17, 2026
  6. gitweb: shorten index hashes with trailing file modesTravor Liu, Jul 17, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.