Reputation: 118
I am trying to get the list of files that are changed between two git tags. These tags has some other tags as well.
git diff tags/v1.0.0 tags/v1.5.0 --name-only
The above command displays the diff between those tags (changes in v1.5.0 only) and don't include the intermediate tag changes. I have also tried
git rev-list tags/v1.5.0 ^tags/v1.0.0 --count
This will give me the count of commits between these two tags. And then
git diff tags/v1.5.0~count tags/v1.5.0 --name-only
But this is giving me incorrect data.
Any help is appreciated. Thanks in advance
Upvotes: 2
Views: 6746
Reputation: 488163
git rev-list tags/v1.5.0 ^tags/v1.0.0 --count
This will give me the count of commits between these two tags.
No, it will give you the count of commits reachable from tags/v1.5.0
that are not reachable from tags/v1.0.0
.
To illustrate the difference, suppose we have a graph fragment like this:
*--*--* * <-- tags/v1.5.0
/ \ /
...--o--o---------*--*--o--o--o <-- master
\
o--o <-- tags/v1.0.0
Here, release v1.0.0
was created at about the same time as the feature bubble along the top, but then there were a few fixes needed. Later, the feature was merged into master and since then release v1.5.0
was created and needed one commit to fix it up as well. (Meanwhile master
has continued to accumulate work.)
The commits that are marked with a star *
are reachable from the label tags/v1.5.0
, by starting at the commit to which the label points and working backwards, following all paths (including the feature bubble).
In this case, there are six such commits.
git diff tags/v1.5.0~count tags/v1.5.0 --name-only
The ~
operator is a graph-following operator. It moves back some number of first parent steps. The first parent of the 1.5.0
commit is on master
, the second parent is a merge commit on master
, and the third parent is the main-line-row *
. The fourth parent is the o
that has the fork that leads to tags/v1.0.0
, the fifth is a commit that is reachable from all names, and the sixth commit back along that first-parent axis comes before the part of the graph shown here.
Because your actual issue is not well-defined, it is hard to say what the correct approach might be. You might look for the merge base(s) between the two tags, then use --ancestry-path
to select commits that are descendants of this merge base but ancestors of the second tag, and check to see whether any of those commits are reachable from other tags and if so what merge base(s) fall along the ancestry-path line. Note that the direct ancestry path from tags/v1.0.0
to tags/v1.5.0
is empty since tags/v1.0.0
is not an ancestor of any of the starred commits.
Upvotes: 1