* [PATCH v2] tools: add a new script to generate fixes tags
@ 2026-10-19 15:56 Darrick J. Wong
2026-10-20 9:22 ` Andrey Albershteyn
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2026-10-19 15:56 UTC (permalink / raw)
To: aalbersh; +Cc: linux-xfs
From: Darrick J. Wong <djwong@kernel.org>
Add a program that can generate Fixes: tags for a new bugfix commit to
cite an older buggy commit.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
v2: add a description of the program to the --help output
---
tools/git-fixes | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
create mode 100755 tools/git-fixes
diff --git a/tools/git-fixes b/tools/git-fixes
new file mode 100755
index 00000000000000..03f566df2b415e
--- /dev/null
+++ b/tools/git-fixes
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# Copyright (c) 2026 Oracle. All Rights Reserved.
+# Author: Darrick J. Wong <djwong@kernel.org>
+
+# Cite a list of git hashes in Fixes: tag format.
+
+if [ -z "$1" ] || [ "$1" = "--help" ]; then
+ echo "Usage: $0 commit [commits...]"
+ echo "Generate Fixes: tags for each commit passed in, along with a Cc:"
+ echo "line for the author. If 'user.stableSubmissionTarget' is set in"
+ echo "the git configuration, a Cc: header will be generated with a"
+ echo "comment identifying the first tag created after the commit."
+ exit 1
+fi
+
+stable_email="$(git config user.stableSubmissionTarget)"
+
+# Find the most recent version tag for this commit. Assumes that version tags
+# start with v and a digit.
+tag_for_commit() {
+ local arg="$1"
+ local tag
+ local release_tag
+ local rc_suffix
+
+ # Find the first tag created after this commit.
+ tag="$(git tag -l --contains "${arg}" --sort version:refname | \
+ grep "^v[0-9]" | \
+ head -n 1)"
+ test -z "${tag}" && return 1
+
+ # Strip off any version suffix (presumably "-rcX") to construct what
+ # ought to be the tag name for the final release.
+ rc_suffix="$(git config versionsort.suffix)"
+ # shellcheck disable=SC2001
+ release_tag="$(echo "${tag}" | sed -e "s/${rc_suffix}.*//g")"
+
+ # If the release tag actually exists, print that instead of the first
+ # tag. Otherwise, print that first tag. We'd rather print "v5.4" than
+ # the more accurate "v5.4-rc1" because stable backports target
+ # releases, not -rcX.
+ if [ -n "$(git tag -l "${release_tag}" 2>/dev/null)" ]; then
+ echo "${release_tag}"
+ else
+ echo "${tag}"
+ fi
+ return 0
+}
+
+gitcc=(git log --format='Cc: <%aE>')
+gitfixes=(git log --format='Fixes: %h ("%s")')
+for arg in "$@"; do
+ "${gitcc[@]}" "${arg}^1..${arg}"
+ if [ -n "${stable_email}" ]; then
+ fixed_in="$(tag_for_commit "${arg}")" && \
+ echo "Cc: <${stable_email}> # ${fixed_in}"
+ fi
+ "${gitfixes[@]}" "${arg}^1..${arg}"
+done
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] tools: add a new script to generate fixes tags
2026-10-19 15:56 [PATCH v2] tools: add a new script to generate fixes tags Darrick J. Wong
@ 2026-10-20 9:22 ` Andrey Albershteyn
0 siblings, 0 replies; 2+ messages in thread
From: Andrey Albershteyn @ 2026-10-20 9:22 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On 2026-10-19 08:56:55, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> Add a program that can generate Fixes: tags for a new bugfix commit to
> cite an older buggy commit.
>
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> ---
> v2: add a description of the program to the --help output
> ---
Looks good to me
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
--
- Andrey
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-20 9:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-19 15:56 [PATCH v2] tools: add a new script to generate fixes tags Darrick J. Wong
2026-10-20 9:22 ` Andrey Albershteyn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox