2

I'm doing the following test case:

I've created "MY-BRANCH" branch

Added a TAG:

git tag TAG1 MY-BRANCH
git push --follow-tags

If I do:

git describe --tags

I can see the TAG with a long name TAG1-5-g2fa83fb

I have some merges from different branches into "MY-BRANCH" using --squash.

Now I'm trying to get all merges done from TAG1 till HEAD but I'm not getting anything. I was expecting to see at least 3 merges. Nothing is coming.

git --no-pager log TAG1..HEAD --parents --oneline --merges --abbrev=0 MY-BRANCH

I can't see what I'm doing wrong.


UPDATE:

As comments below, my initial problem seems to be the branch that the TAG was assigned to. Filter --merge seems not work with --squash too.

I'll try to clarify what I'm trying to achieve maybe it's more helpful.

What I'm basically trying to do is to get all merges IN (merges into my current branch) from the last TAG to the HEAD. One of the problems is that the merges are being done with --squash. I didn't find any type of filter for --squash merges.

Sosian
  • 622
  • 11
  • 28
Thiago C. S Ventura
  • 2,448
  • 1
  • 29
  • 43
  • 2
    If you run `git log --decorate`, you should be able to see tags attached to the history (stretching backwards from HEAD). Can you see your tag? – Useless Feb 09 '17 at 16:04
  • you have just opened my eyes to one thing. when I do git log --decorate I can see the TAG1 but it seems to be assigned to another branch "development" branch the original one. – Thiago C. S Ventura Feb 09 '17 at 16:22
  • Now if I do: git --no-pager log TAG1..HEAD --parents --oneline development I can see my commits and merges – Thiago C. S Ventura Feb 09 '17 at 16:23
  • but if I use --merges it's not filtering by merges. Why is that? – Thiago C. S Ventura Feb 09 '17 at 16:24
  • 1
    Well, maybe the merge (2-parented) commits are the parents of commits on your direct line, but are not themselves on the direct line. You should be able to tell this by just omitting both `--parents` _and_ `--merges`. Look at the simple history and see if any of the commits are merges. – Useless Feb 09 '17 at 16:28
  • they show as "Merged in" in the begining of the description. Do you think this could be related to --squash option ? – Thiago C. S Ventura Feb 09 '17 at 16:45
  • I've just done a test. I can confirm. Filter --merges does not work with --squash – Thiago C. S Ventura Feb 09 '17 at 16:56
  • `--squash` is not a `git log` filter, it's a directive to `git merge` that tells it not to make a merge. See any of my postings about `git merge --squash` that describe the difference between the verb *to merge* and the noun *a merge*. – torek Feb 09 '17 at 18:44
  • Hi @torek, I'm aware of that. I'm not trying to use - - squash as a filter. I'm trying to filter the merges done using - - squash. That a merge done with - - squash isn't a merge I wasn't aware. I'm just using these terms to explain my case because on bitbucket there's an option - - squash when you are merging :) – Thiago C. S Ventura Feb 09 '17 at 18:51
  • 1
    @Ventura: Bitbucket are just using the same word in the same way; GitHub do the same as Bitbucket. Both just run `git merge --squash` "under the covers", and hence both have the same issue: the resulting commit is not a merge. Since `git log --merges` filters away non-merges (takes only commits that *are* merges), and these commits are *not* merges, you filter away the very commit you wanted. There is no way to work around this: a squash merge is simply not a merge. It invokes the merging *action* but leaves behind an ordinary, non-merge commit. – torek Feb 09 '17 at 19:14

1 Answers1

0

So your problem is that

git log --merges

does not consider squashed merge commits to be merges because they aren't really merges. Specifically, although git merge creates them, they don't have two parents, which is exactly the criterion used, per the documentation:

--merges

Print only merge commits. This is exactly the same as --min-parents=2.

Community
  • 1
  • 1
Useless
  • 64,155
  • 6
  • 88
  • 132
  • I ended up trying another approach. Now I'm doing the opposite getting all commits apart from merges and always using --squash to merge and avoiding straight commits to the main branch, only --squash merges are accepted, this way I have a much cleaner log. – Thiago C. S Ventura Feb 11 '17 at 11:08