Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the git equivalent of Mercurial revsets?

Mercurial has a domain-specific language called revsets that allows users to specify sets of revisions.

For example, you might want to list patches that haven't yet been merged into the branch default:

hg log -r "all() - ancestors('default')"

As a more complex example, the link above gives the example of listing changesets between the revision tagged 1.3 and the revision tagged 1.5 which mention "bug" and affect a file in the directory hgext:

hg log -r "1.3::1.5 and keyword(bug) and file('hgext/*')"

The revset language is quite rich, allowing selection of changesets based on dates, username, commit message, whether the commit exists at a particular remote location, and so on.

Does git have an equivalent mechanism for querying changesets, either in the core program or available as an extension?

like image 584
davidg Avatar asked Mar 20 '14 00:03

davidg


2 Answers

To list all commits except from the default master branch, like I assume the first example does:

git log --all --not master

To get a result somewhat equal to the second example:

git log 1.3...1.5 --grep="bug" -- hgext
like image 120
peroyhav Avatar answered Sep 24 '22 14:09

peroyhav


Does git have an equivalent mechanism for querying changesets, either in the core program or available as an extension?

The closest equivalent in git is gitrevisions(7), but it's completely ad-hoc, and significantly less regular, and less composable. And not all commands use it (famously git diff has identical constructs which behave completely differently, because gitrevisions works on ranges but git diff works on pairs of commits).

like image 45
Masklinn Avatar answered Sep 23 '22 14:09

Masklinn