Finding marked changes with a given merge in their history

I want to find tagged changes that include a given merge. I found this question about detecting commits in a tagged revision that I cannot put into practice.

Concrete case: looking for tagged changes to matplotlib that contains this merge .

I go to the commits list included in the merge, I take the first one with id cf11aea

and type

git tag --contains cf11aea

      

This does not return any result.

When trying to view a commit with the same patch ID with the script parameter mentioned in the question above, it returns one response - the original commit.

So how to find tagged changes with a given merge, this is different from finding tagged revisions with a given commit?

(This question is not about matplotlib itself.)

EDIT

One explanation might be that the merge is not part of any tagged revision. However, the changes caused by this merge can be seen in the source of the flagged changes. For example. this modified line from cf11aea

can be seen in the v2.0.0 source .

+3


source to share


2 answers


To answer your main question, how do you find all the tags that contain a given commit?

Exactly as you tried:

git tag --contains COMMIT-ID

      

If the output of this command is empty, then untagged contains the specified commit.


So, I would say that you got the correct command, but the example or repository is wrong.

Let's analyze.

You are looking for all tags that contain a specific commit, in your example, you are looking for commit cf11aea

in all tags in matplotlib .

However, there are no tags in this repository that contain commit.

That's why.

You cite a pull request, pull request # 5718, and there are actually two committing transactions in that repository that reference this 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 at the top 2-3 lines of each of these 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 is merge, the other is not. The other is most likely the cherry pick of the first.

See what tags these commits contain:



λ 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 pull request merge is not part of any tags, whereas the selected cherry is a commit (upon re-reading, I assume it is actually squash or something similar).

This is why the commit you are looking for, cf11aea, is not part of any tag.

In conclusion, your premise was wrong. You drew an empty output git tag --contains cf11aea

as an indication that you did something wrong, but you used the correct command, it was just an assumption that cf11aea

was part of the tag that was wrong.


To answer your question in the comments, how did I find this other commit? Well, two ways, but let’s deal with the one that first put me on the right path:

I checked the tag v2.0.0

and then ran:

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 selected line 493 to highlight)

The first part is the ID of the commit that made the change.

Then I looked at this commit, and you can see the above output, and found it was not a merge. Obviously it was not a merge for this pull request.

At this point, I did this:

git log --graph >c:\log.txt

      

Opened it in Notepad ++ and used the Find function to find 5718 and found two commits and the rest is history.

+3


source


In addition to what Lasse wrote in her answer , she offers a GitHub solution just to achieve the same result:

What you should look for in a pull request is pull request permission information. In this case, it looks like this:

Resolving a capture request: Merge commit

So, tacaswell merged this in master

with a merge commit 5b74696

. Clicking on the commit hash will take you to the commit detail page , which will show you this information:

Commit details with branch listing

In commit blocks, GitHub will display the branches and tags that commit is a part of. In this case, you can see master

there, which means that this commit is part of a branch master

. There are no tags here, so this merge is not part of the tag.

Looking back at the pull request, tacaswell also commented the following:



Return notice

So he decided to back up the content of this pull request to the development line 2.x

with a commit 6595139

. Clicking on that hash will take you back to the commit details page again , which looks like this:

Commit details with branch / tag listings

Again, at the bottom we see the branches and tags of which the commit is a part. In this case, it is again contained in the branch master

, but also on some branches, with bold v2.0.2

being the most recent and v2.0.0b1

being the earliest. If you click on the ellipsis, you will get a list of all the tags where the commit is committed:

List of all branches and tags

If you cross the information you get from the GitHub web interface here with what Lasse found in his native Git way, you can see that it fits perfectly. So if you are dealing with a GitHub project and are pulling the request anyway, you can also try looking for information on GitHub first.

+1


source







All Articles