Thread (79 messages) 79 messages, 10 authors, 2025-08-05

Re: [PATCH v5 2/6] t/perf: add last-modified perf script

From: Taylor Blau <hidden>
Date: 2025-07-18 00:08:42

On Wed, Jul 16, 2025 at 03:35:14PM +0200, Toon Claes wrote:
quoted hunk ↗ jump to hunk
diff --git a/t/perf/p8020-last-modified.sh b/t/perf/p8020-last-modified.sh
new file mode 100755
index 0000000000..a02ec907d4
--- /dev/null
+++ b/t/perf/p8020-last-modified.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+test_description='last-modified perf tests'
+. ./perf-lib.sh
+
+test_perf_default_repo
+
+test_perf 'top-level last-modified' '
+	git last-modified HEAD
+'
+
+test_perf 'top-level recursive last-modified' '
+	git last-modified -r HEAD
+'
The only notable difference from GitHub's version here is that we do not
have a recursive option, so our test is just "git blame-tree
--max-depth=0", which is obviously not applicable here.

What you wrote (testing "last-modified" both with and without the "-r"
option) makes sense to me.
+test_perf 'subdir last-modified' '
+	path=$(git ls-tree HEAD | grep ^040000 | head -n 1 | cut -f2)
Hmm. This line comes directly from the patches that I originally shared,
but seeing "git" on the left-hand side of a pipe makes me a little
uneasy.

We could also use the "-d" flag here, which will only show us trees,
thus eliminating the need for the "grep ^040000" portion above.

I'd probably write this as:

    git ls-tree -d HEAD >subtrees &&
    path="$(head -n 1 subtrees | cut -f2)" &&
    git last-modified -- "$path"

Thanks,
Taylor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help