git: af445e1dd95d - main - mfc-candidates.lua: add -F fmt option

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sun, 19 Oct 2025 23:25:52 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=af445e1dd95d43c011f377ea6e6618637fecc61c

commit af445e1dd95d43c011f377ea6e6618637fecc61c
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2025-10-17 16:57:41 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2025-10-19 23:24:25 +0000

    mfc-candidates.lua: add -F fmt option
    
    Add -F fmt option to give a free format string to git show --pretty=.
    It can be used, for example, as:
      ./tools/tools/git/mfc-candidates.lua -F "%h %cD %s"
    to see which commits have passed the minimum 3 days of waiting before
    MFCing, or to see which group of commits belong together.
    
    MFC after:      3 days
    Reviewed by:    emaste
    Differential Revision: https://reviews.freebsd.org/D53172
---
 tools/tools/git/mfc-candidates.lua | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/tools/git/mfc-candidates.lua b/tools/tools/git/mfc-candidates.lua
index a1420dc726da..cbf7dcb3a257 100755
--- a/tools/tools/git/mfc-candidates.lua
+++ b/tools/tools/git/mfc-candidates.lua
@@ -117,7 +117,7 @@ end
 
 local function usage(from_branch, to_branch, author)
 	local script_name = arg[0]:match("([^/]+)$")
-	print(script_name .. " [-ah] [-f from_branch] [-t to_branch] [-u user] [-X exclude_file] [path ...]")
+	print(script_name .. " [-ah] [-F git-show-fmt] [-f from_branch] [-t to_branch] [-u user] [-X exclude_file] [path ...]")
 	print()
 	params(from_branch, to_branch, author)
 end
@@ -162,6 +162,7 @@ local function main()
 
 	local do_help = false
 	local exclude_file = nil
+	local gitshowfmt = '%h %s'
 	local i = 1
 	while i <= #arg and arg[i] do
 		local opt = arg[i]
@@ -181,6 +182,9 @@ local function main()
 			i = i + 1
 		elseif opt == "-v" then
 			verbose = verbose + 1
+		elseif opt == "-F" then
+			gitshowfmt = arg[i + 1]
+			i = i + 1
 		elseif opt == "-X" then
 			exclude_file = arg[i + 1]
 			i = i + 1
@@ -217,7 +221,7 @@ local function main()
 
 	-- Print the result
 	for _, hash in ipairs(result_hashes) do
-		print(exec_command("git show --pretty='%h %s' --no-patch " .. hash))
+		print(exec_command("git show --pretty='" .. gitshowfmt .. "' --no-patch " .. hash))
 	end
 end