Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 74 lines (61 sloc) 2.56 KB
# SPDX-License-Identifier: GPL-2.0
# Copyright 2018, Greg Kroah-Hartman <>
# Find what release(s) a specific git commit is in.
# Yes, we can just use 'git describe --contains' but that ends up being slower
# than just grepping the commit logs. We also want to catch the releases where
# we have backported fixes to different stable releases. So this script tries
# to poke around in the log files to figure it all out.
# kernel git commit e586b3b0baee is a fun one to use for testing this out.
# Location of all of the kernel log files
# git repo is at:
# Location of all of the patches that have ever been added to the stable trees
# git repo is at
# Location of the "latest" git tree for when patches are not found in the
# stable tree at the moment. This is the "fall-back" that we can use the
# slower 'git decribe --contains' on.
if [ "${id}" == "" ] ; then
echo "$0 ID"
exit 1
# Array of places we find
# Look in the kernel log text files first
cd ${LOG_LOCATION} || exit
releases=$(git grep -l -i "${id}")
# We do not want to catch the places where this commit has been "fixed" by other commits, so filter out those files
#releases=`git grep ${id} | grep -v -i "Fixes:" | cut -f 1 -d ':'`
for release in ${releases}; do
release=${release#log-} # delete "log-" off of the front of any match
# echo -n "${release} "
# Then look in the stable queue patches themselves
cd ${STABLE_QUEUE} || exit
releases=$(git grep -l -i "${id}")
for release in ${releases}; do
release=${release#releases\/} # delete "releases/" off of the front of any match
release=${release%\/*} # only keep the front kernel release directory of a match, not the patch itself
# echo -n "${release} "
# if we have found nothing, let's try the fallback and do the old and
# slow 'git describe --contains' to try to find at least some hint of
# where this commit might be at.
if [ "${output[0]}" == "" ] ; then
cd "${LATEST_TREE}" || exit
output=$(git describe --contains "${id}")
# sort the list of releases and put them in a new array called "sorted"
readarray -t sorted < <(for release in "${output[@]}"; do echo "${release}"; done | sort -V | uniq)
# print them out all on one line, with ' ' inbetween them
(IFS=' ' ; printf '%s\n' "${sorted[*]}")
You can’t perform that action at this time.