Given a git commit hash, how to find out which kernel release contains it?

Assume I have some issue that was fixed by a recent patch to the official Linux git repository. I have a work around, but I’d like to undo it when a release happens that contains my the fix. I know the exact git commit hash, e.g. f3a1ef9cee4812e2d08c855eb373f0d83433e34c.

What is the easiest way to answer the question: What kernel releases so far contain this patch? Bonus points if no local Linux git repository is needed.

(LWM discusses some ideas, but these do require a local repository.)

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

As mentioned on LWN, the easiest is:

git describe --contains f3a1ef9cee4812e2d08c855eb373f0d83433e34c

If you don’t want a local clone, gitweb’s “plain” formatted commit contains the same info in the X-Git-Tag header. Unfortunately kernel.org switched over to cgit which apparently does not disclose this information. Previously it was possible to find it out like this:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff_plain;h=f3a1ef9cee4812e2d08c855eb373f0d83433e34c

Here, X-Git-Tag is actually missing at the moment because that commit isn’t in a tagged release in that repository. But you can look at an earlier commit, like:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commitdiff_plain;h=dc0827c128c0ee5a58b822b99d662b59f4b8e970

Here, you see:

X-Git-Tag: v3.4-rc1~184^2~10

which tells me that the tag “v3.4-rc1” was the first tag to follow my patch, so I’d expect to see it in v3.4.

Method 2

In GitHub kernel repository, you can check all tags/kernel versions.

Example for dc0827c128c0ee5a58b822b99d662b59f4b8e970 provided by Jim Paris:

Commit dc0827c@GitHub

If three-dots are clicked, full list of tags/kernel versions can be seen.

Method 3

You can use something like this

git-show f3a1ef9cee4812e2d08c855eb373f0d83433e34c:Makefile 
         | head -4 | awk -vORS='.' '{print $3}' | sed 's/.*$//'

This requires local git repo.

Method 4

Old question, but I was surprised no answer included:

git tag --contains <Commit ID>

From git tag help message:

Tag listing options
     --contains <commit>   print only tags that contain the commit

This requires a local GIT repository.

Since this question was the first result I got when looking for a solution, I think this would be helpful for others.

Method 5

You can see the commit on the github source mirror. I suppose you could correllate the release tags to the commit date (in this case, your commit is five days old, the most recent tagged RC on master is seven), but frankly this is easier to get at if you clone the source locally.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x