To answer your main question, how do you find all tags that contains a given commit?
Exactly as you tried:
git tag --contains COMMIT-ID
If the output of this command is empty, then no tag contains the specified commit.
So I would say you got the command right but the example or repository wrong.
Let's analyze.
You're looking for all tags that contain a specific commit, in your example you're looking for the commit cf11aea
in all tags in matplotlib.
However, no tags in that repository contains that commit.
Here's why.
You cite a pull request, pull request #5718, and there are in fact two commits in that repository that reference this pull request:
commit 5b74696f838a43bcedc4bc568f0564f87f2fc71a
Merge: 18169b295 c9b2425fa
Author: Thomas A Caswell <tcaswell@gmail.com>
Date: Wed Feb 17 21:35:50 2016 -0500
Merge pull request #5718 from mdboom/image-interpolation
Rewrite of image infrastructure
commit 659513951920d83fe6ef68ec40dd72f7bd6d6653
Author: Thomas A Caswell <tcaswell@gmail.com>
Date: Wed Feb 17 21:35:50 2016 -0500
Merge pull request #5718 from mdboom/image-interpolation
Rewrite of image infrastructure
Conflicts:
lib/matplotlib/tests/test_axes.py
- do not back-port appveyor spceific limits
lib/matplotlib/tests/test_image.py
- do not backport the jpeg_alpha test
setupext.py
- do not include windows/appveyor related changes
Take a look of the top 2-3 lines of each of those two:
commit 5b74696f838a43bcedc4bc568f0564f87f2fc71a
Merge: 18169b295 c9b2425fa
Author: Thomas A Caswell <tcaswell@gmail.com>
commit 659513951920d83fe6ef68ec40dd72f7bd6d6653
Author: Thomas A Caswell <tcaswell@gmail.com>
As you can see, the first one is a merge, the other one isn't. The other one is most likely a cherry-pick of the first one.
Let's see which tags contains these commits:
λ git tag --contains 5b74696f838a43bcedc4bc568f0564f87f2fc71a
λ git tag --contains 659513951920d83fe6ef68ec40dd72f7bd6d6653
v2.0.0
v2.0.0b1
v2.0.0b2
v2.0.0b3
v2.0.0b4
v2.0.0rc1
v2.0.0rc2
v2.0.1
v2.0.2
So the original merge, of the pull request, is not part of any tags whereas the cherry-picked commit is (on re-reading I'm assuming it is in fact a squash or something similar).
This is why the commit you're looking for, cf11aea, is not part of any tag.
In conclusion, your premise was wrong. You took the empty output of git tag --contains cf11aea
as an indication that you had done something wrong, but you've used the right command, it was just the assumption that cf11aea
was part of a tag that was wrong.
To answer your question in the comments, how did I find that other commit? Well, two ways but let's deal with the one that put me on the right track first:
I checked out the tag v2.0.0
and then executed:
git blame extern\agg24-svn\include\agg_span_image_filter_gray.h
Line 493 (+ surrounding lines) in this output looks like this:
121ee67b4d agg24/include/agg_span_image_filter_gray.h (Michael Droettboom 2007-11-16 15:53:57 +0000 490) fg_ptr = (const value_type*)base_type::source().next_y();
121ee67b4d agg24/include/agg_span_image_filter_gray.h (Michael Droettboom 2007-11-16 15:53:57 +0000 491) }
121ee67b4d agg24/include/agg_span_image_filter_gray.h (Michael Droettboom 2007-11-16 15:53:57 +0000 492)
6595139519 extern/agg24-svn/include/agg_span_image_filter_gray.h (Thomas A Caswell 2016-02-17 21:35:50 -0500 493) fg = color_type::downshift(fg, image_filter_shift);
121ee67b4d agg24/include/agg_span_image_filter_gray.h (Michael Droettboom 2007-11-16 15:53:57 +0000 494) if(fg < 0) fg = 0;
2a178393c0 extern/agg24/include/agg_span_image_filter_gray.h (Michael Droettboom 2014-10-15 10:35:38 -0400 495) if(fg > color_type::full_value()) fg = color_type::full_value();
121ee67b4d agg24/include/agg_span_image_filter_gray.h (Michael Droettboom 2007-11-16 15:53:57 +0000 496) span->v = (value_type)fg;
(I separated out line 493 from the rest for clarity)
The first part is the commit id that introduced the changes.
I then looked at that commit, and you can see the output above, and found that it wasn't a merge commit. Clearly this was not the merge for that pull request.
At this point I did this:
git log --graph >c:\log.txt
Opened it up in Notepad++ and used the "Find" function to find 5718, and found two commits, and the rest is history.