can I get only the list of merges?
Hi, git-log and git-rev-list and friends have a --no-merges option. However, I need the contrary functionality: a sort of "--only-merges" way of getting the log? (that is, without parsing manually the git-log output)
Quoted 3 lines · Diego Calleja
Hi, git-log and git-rev-list and friends have a --no-merges option. However, I need the contrary functionality: a sort of "--only-merges" way of getting the log? (that is, without parsing manually the git-log output)
Perhaps something like this? It finds all commits with more than one parent (I dunno if there are any other commits that have more than one parent)
git-rev-list --parents HEAD | \
grep -E '^([a-z0-9]{40} ){2}[a-z0-9]{40}' | \
cut -d ' ' -f 1
Hi,
Quoted 2 lines · Matthias Lederhofer
git-rev-list --parents HEAD | \
grep -E '^([a-z0-9]{40} ){2}[a-z0-9]{40}' | \
Since the output of git-rev-list is well-defined, you could say
grep '.{121}'instead. (Instead of 121, you could take any number between 83 and 122.)
Ciao,
Dscho
Quoted 11 lines · Matthias Lederhofer
Quoted 3 lines · Diego Calleja
Hi, git-log and git-rev-list and friends have a --no-merges option. However, I need the contrary functionality: a sort of "--only-merges" way of getting the log? (that is, without parsing manually the git-log output)
Perhaps something like this? It finds all commits with more than one parent (I dunno if there are any other commits that have more than one parent)
git-rev-list --parents HEAD | \
grep -E '^([a-z0-9]{40} ){2}[a-z0-9]{40}' | \
cut -d ' ' -f 1
Well, the above is the "proper" way of doing things, and is efficient and gives the right answer. However, if you want a _sneaky_ way of doing it, and want a graphical result, and have a recent version of git, you can also just do something like
gitk --full-history -- %%nonexistant-file%%
which will give you each commit that changes that nonexistant file (there should be none ;), and the full commit history for those (ie all the merges).
(If you use "git log", you also need to add "--parents" while gitk will do it for you).
Linus
Quoted 10 lines · Linus Torvalds
However, if you want a _sneaky_ way of doing it, and want a graphical result, and have a recent version of git, you can also just do something like
gitk --full-history -- %%nonexistant-file%%which will give you each commit that changes that nonexistant file (there should be none ;), and the full commit history for those (ie all the merges).
Btw, a better way to do the same is probably
gitk --full-history -- a//b
which is guaranteed to not match any files and doesn't depend on just an _unlikely_ filename. Instead, it depends on the fact that a name with a double slash should not exist in a git archive.
(There are other possibilities too - instead of "a//a", you can just use the filename ".git", for the same reasons - it definitely won't be tracked by git).
Linus
PATCH 1/1 git-rev-list: add documentation for --parents, --no-merges
In reply to Diego Calleja---
Btw: grep -E ' .* ' should work too.
Documentation/git-rev-list.txt | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
Documentation/git-rev-list.txt +6 -0
@@ -56,6 +56,9 @@ OPTIONS Print the contents of the commit in raw-format; each record is separated with a NUL character. +--parents:: + Print the parents of the commit. + --objects:: Print the object IDs of any object referenced by the listed commits. 'git-rev-list --objects foo ^bar' thus means "send me all object IDs
@@ -102,6 +105,9 @@ OPTIONS --remove-empty:: Stop when a given path disappears from the tree. +--no-merges:: + Do not print commits with more than one parent. + --not:: Reverses the meaning of the '{caret}' prefix (or lack thereof) for all following revision specifiers, up to
Signature · 1 line
1.4.1.gf157-dirty