From: "Darrick J. Wong" <djwong@kernel.org>
To: aalbersh@kernel.org
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH v2] tools: add a new script to generate fixes tags
Date: Mon, 19 Oct 2026 08:56:55 -0700 [thread overview]
Message-ID: <20261019155655.GD1612213@frogsfrogsfrogs> (raw)
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
next reply other threads:[~2026-10-19 15:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 15:56 Darrick J. Wong [this message]
2026-10-20 9:22 ` [PATCH v2] tools: add a new script to generate fixes tags Andrey Albershteyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261019155655.GD1612213@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=aalbersh@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox