rev-list: documentation and test for --left/right-only
[git/dscho.git] / Documentation / rev-list-options.txt
blobcebba62239ad8861160e79255fdbdc4800be5e05
1 Commit Formatting
2 ~~~~~~~~~~~~~~~~~
4 ifdef::git-rev-list[]
5 Using these options, linkgit:git-rev-list[1] will act similar to the
6 more specialized family of commit log tools: linkgit:git-log[1],
7 linkgit:git-show[1], and linkgit:git-whatchanged[1]
8 endif::git-rev-list[]
10 include::pretty-options.txt[]
12 --relative-date::
14         Synonym for `--date=relative`.
16 --date=(relative|local|default|iso|rfc|short|raw)::
18         Only takes effect for dates shown in human-readable format, such
19         as when using "--pretty". `log.date` config variable sets a default
20         value for log command's --date option.
22 `--date=relative` shows dates relative to the current time,
23 e.g. "2 hours ago".
25 `--date=local` shows timestamps in user's local timezone.
27 `--date=iso` (or `--date=iso8601`) shows timestamps in ISO 8601 format.
29 `--date=rfc` (or `--date=rfc2822`) shows timestamps in RFC 2822
30 format, often found in E-mail messages.
32 `--date=short` shows only date but not time, in `YYYY-MM-DD` format.
34 `--date=raw` shows the date in the internal raw git format `%s %z` format.
36 `--date=default` shows timestamps in the original timezone
37 (either committer's or author's).
39 ifdef::git-rev-list[]
40 --header::
42         Print the contents of the commit in raw-format; each record is
43         separated with a NUL character.
44 endif::git-rev-list[]
46 --parents::
48         Print also the parents of the commit (in the form "commit parent...").
49         Also enables parent rewriting, see 'History Simplification' below.
51 --children::
53         Print also the children of the commit (in the form "commit child...").
54         Also enables parent rewriting, see 'History Simplification' below.
56 ifdef::git-rev-list[]
57 --timestamp::
58         Print the raw commit timestamp.
59 endif::git-rev-list[]
61 --left-right::
63         Mark which side of a symmetric diff a commit is reachable from.
64         Commits from the left side are prefixed with `<` and those from
65         the right with `>`.  If combined with `--boundary`, those
66         commits are prefixed with `-`.
68 For example, if you have this topology:
70 -----------------------------------------------------------------------
71              y---b---b  branch B
72             / \ /
73            /   .
74           /   / \
75          o---x---a---a  branch A
76 -----------------------------------------------------------------------
78 you would get an output like this:
80 -----------------------------------------------------------------------
81         $ git rev-list --left-right --boundary --pretty=oneline A...B
83         >bbbbbbb... 3rd on b
84         >bbbbbbb... 2nd on b
85         <aaaaaaa... 3rd on a
86         <aaaaaaa... 2nd on a
87         -yyyyyyy... 1st on b
88         -xxxxxxx... 1st on a
89 -----------------------------------------------------------------------
91 --graph::
93         Draw a text-based graphical representation of the commit history
94         on the left hand side of the output.  This may cause extra lines
95         to be printed in between commits, in order for the graph history
96         to be drawn properly.
98 This enables parent rewriting, see 'History Simplification' below.
100 This implies the '--topo-order' option by default, but the
101 '--date-order' option may also be specified.
103 ifdef::git-rev-list[]
104 --count::
105         Print a number stating how many commits would have been
106         listed, and suppress all other output.  When used together
107         with '--left-right', instead print the counts for left and
108         right commits, separated by a tab.
109 endif::git-rev-list[]
112 ifndef::git-rev-list[]
113 Diff Formatting
114 ~~~~~~~~~~~~~~~
116 Below are listed options that control the formatting of diff output.
117 Some of them are specific to linkgit:git-rev-list[1], however other diff
118 options may be given. See linkgit:git-diff-files[1] for more options.
120 -c::
122         With this option, diff output for a merge commit
123         shows the differences from each of the parents to the merge result
124         simultaneously instead of showing pairwise diff between a parent
125         and the result one at a time. Furthermore, it lists only files
126         which were modified from all parents.
128 --cc::
130         This flag implies the '-c' options and further compresses the
131         patch output by omitting uninteresting hunks whose contents in
132         the parents have only two variants and the merge result picks
133         one of them without modification.
135 -m::
137         This flag makes the merge commits show the full diff like
138         regular commits; for each merge parent, a separate log entry
139         and diff is generated. An exception is that only diff against
140         the first parent is shown when '--first-parent' option is given;
141         in that case, the output represents the changes the merge
142         brought _into_ the then-current branch.
144 -r::
146         Show recursive diffs.
148 -t::
150         Show the tree objects in the diff output. This implies '-r'.
152 -s::
153         Suppress diff output.
154 endif::git-rev-list[]
156 Commit Limiting
157 ~~~~~~~~~~~~~~~
159 Besides specifying a range of commits that should be listed using the
160 special notations explained in the description, additional commit
161 limiting may be applied.
165 -n 'number'::
166 --max-count=<number>::
168         Limit the number of commits output.
170 --skip=<number>::
172         Skip 'number' commits before starting to show the commit output.
174 --since=<date>::
175 --after=<date>::
177         Show commits more recent than a specific date.
179 --until=<date>::
180 --before=<date>::
182         Show commits older than a specific date.
184 ifdef::git-rev-list[]
185 --max-age=<timestamp>::
186 --min-age=<timestamp>::
188         Limit the commits output to specified time range.
189 endif::git-rev-list[]
191 --author=<pattern>::
192 --committer=<pattern>::
194         Limit the commits output to ones with author/committer
195         header lines that match the specified pattern (regular expression).
197 --grep=<pattern>::
199         Limit the commits output to ones with log message that
200         matches the specified pattern (regular expression).
202 --all-match::
203         Limit the commits output to ones that match all given --grep,
204         --author and --committer instead of ones that match at least one.
206 -i::
207 --regexp-ignore-case::
209         Match the regexp limiting patterns without regard to letters case.
211 -E::
212 --extended-regexp::
214         Consider the limiting patterns to be extended regular expressions
215         instead of the default basic regular expressions.
217 -F::
218 --fixed-strings::
220         Consider the limiting patterns to be fixed strings (don't interpret
221         pattern as a regular expression).
223 --remove-empty::
225         Stop when a given path disappears from the tree.
227 --merges::
229         Print only merge commits.
231 --no-merges::
233         Do not print commits with more than one parent.
235 --first-parent::
236         Follow only the first parent commit upon seeing a merge
237         commit.  This option can give a better overview when
238         viewing the evolution of a particular topic branch,
239         because merges into a topic branch tend to be only about
240         adjusting to updated upstream from time to time, and
241         this option allows you to ignore the individual commits
242         brought in to your history by such a merge.
244 --not::
246         Reverses the meaning of the '{caret}' prefix (or lack thereof)
247         for all following revision specifiers, up to the next '--not'.
249 --all::
251         Pretend as if all the refs in `refs/` are listed on the
252         command line as '<commit>'.
254 --branches[=<pattern>]::
256         Pretend as if all the refs in `refs/heads` are listed
257         on the command line as '<commit>'. If '<pattern>' is given, limit
258         branches to ones matching given shell glob. If pattern lacks '?',
259         '*', or '[', '/*' at the end is implied.
261 --tags[=<pattern>]::
263         Pretend as if all the refs in `refs/tags` are listed
264         on the command line as '<commit>'. If '<pattern>' is given, limit
265         tags to ones matching given shell glob. If pattern lacks '?', '*',
266         or '[', '/*' at the end is implied.
268 --remotes[=<pattern>]::
270         Pretend as if all the refs in `refs/remotes` are listed
271         on the command line as '<commit>'. If '<pattern>' is given, limit
272         remote-tracking branches to ones matching given shell glob.
273         If pattern lacks '?', '*', or '[', '/*' at the end is implied.
275 --glob=<glob-pattern>::
276         Pretend as if all the refs matching shell glob '<glob-pattern>'
277         are listed on the command line as '<commit>'. Leading 'refs/',
278         is automatically prepended if missing. If pattern lacks '?', '*',
279         or '[', '/*' at the end is implied.
282 ifndef::git-rev-list[]
283 --bisect::
285         Pretend as if the bad bisection ref `refs/bisect/bad`
286         was listed and as if it was followed by `--not` and the good
287         bisection refs `refs/bisect/good-*` on the command
288         line.
289 endif::git-rev-list[]
291 --stdin::
293         In addition to the '<commit>' listed on the command
294         line, read them from the standard input. If a '--' separator is
295         seen, stop reading commits and start reading paths to limit the
296         result.
298 ifdef::git-rev-list[]
299 --quiet::
301         Don't print anything to standard output.  This form
302         is primarily meant to allow the caller to
303         test the exit status to see if a range of objects is fully
304         connected (or not).  It is faster than redirecting stdout
305         to /dev/null as the output does not have to be formatted.
306 endif::git-rev-list[]
308 --cherry-pick::
310         Omit any commit that introduces the same change as
311         another commit on the "other side" when the set of
312         commits are limited with symmetric difference.
314 For example, if you have two branches, `A` and `B`, a usual way
315 to list all commits on only one side of them is with
316 `--left-right`, like the example above in the description of
317 that option.  It however shows the commits that were cherry-picked
318 from the other branch (for example, "3rd on b" may be cherry-picked
319 from branch A).  With this option, such pairs of commits are
320 excluded from the output.
322 --left-only::
323 --right-only::
325         List only commits on the respective side of a symmetric range,
326         i.e. only those which would be marked `<` resp. `>` by
327         `--left-right`.
329 For example, `--cherry-pick --right-only A...B` omits those
330 commits from `B` which are in `A` or are patch-equivalent to a commit in
331 `A`. In other words, this lists the `{plus}` commits from `git cherry A B`.
332 More precisely, `--cherry-pick --right-only --no-merges` gives the exact
333 list.
335 -g::
336 --walk-reflogs::
338         Instead of walking the commit ancestry chain, walk
339         reflog entries from the most recent one to older ones.
340         When this option is used you cannot specify commits to
341         exclude (that is, '{caret}commit', 'commit1..commit2',
342         nor 'commit1\...commit2' notations cannot be used).
344 With '\--pretty' format other than oneline (for obvious reasons),
345 this causes the output to have two extra lines of information
346 taken from the reflog.  By default, 'commit@\{Nth}' notation is
347 used in the output.  When the starting commit is specified as
348 'commit@\{now}', output also uses 'commit@\{timestamp}' notation
349 instead.  Under '\--pretty=oneline', the commit message is
350 prefixed with this information on the same line.
351 This option cannot be combined with '\--reverse'.
352 See also linkgit:git-reflog[1].
354 --merge::
356         After a failed merge, show refs that touch files having a
357         conflict and don't exist on all heads to merge.
359 --boundary::
361         Output uninteresting commits at the boundary, which are usually
362         not shown.
366 History Simplification
367 ~~~~~~~~~~~~~~~~~~~~~~
369 Sometimes you are only interested in parts of the history, for example the
370 commits modifying a particular <path>. But there are two parts of
371 'History Simplification', one part is selecting the commits and the other
372 is how to do it, as there are various strategies to simplify the history.
374 The following options select the commits to be shown:
376 <paths>::
378         Commits modifying the given <paths> are selected.
380 --simplify-by-decoration::
382         Commits that are referred by some branch or tag are selected.
384 Note that extra commits can be shown to give a meaningful history.
386 The following options affect the way the simplification is performed:
388 Default mode::
390         Simplifies the history to the simplest history explaining the
391         final state of the tree. Simplest because it prunes some side
392         branches if the end result is the same (i.e. merging branches
393         with the same content)
395 --full-history::
397         As the default mode but does not prune some history.
399 --dense::
401         Only the selected commits are shown, plus some to have a
402         meaningful history.
404 --sparse::
406         All commits in the simplified history are shown.
408 --simplify-merges::
410         Additional option to '--full-history' to remove some needless
411         merges from the resulting history, as there are no selected
412         commits contributing to this merge.
414 --ancestry-path::
416         When given a range of commits to display (e.g. 'commit1..commit2'
417         or 'commit2 {caret}commit1'), only display commits that exist
418         directly on the ancestry chain between the 'commit1' and
419         'commit2', i.e. commits that are both descendants of 'commit1',
420         and ancestors of 'commit2'.
422 A more detailed explanation follows.
424 Suppose you specified `foo` as the <paths>.  We shall call commits
425 that modify `foo` !TREESAME, and the rest TREESAME.  (In a diff
426 filtered for `foo`, they look different and equal, respectively.)
428 In the following, we will always refer to the same example history to
429 illustrate the differences between simplification settings.  We assume
430 that you are filtering for a file `foo` in this commit graph:
431 -----------------------------------------------------------------------
432           .-A---M---N---O---P
433          /     /   /   /   /
434         I     B   C   D   E
435          \   /   /   /   /
436           `-------------'
437 -----------------------------------------------------------------------
438 The horizontal line of history A--P is taken to be the first parent of
439 each merge.  The commits are:
441 * `I` is the initial commit, in which `foo` exists with contents
442   "asdf", and a file `quux` exists with contents "quux".  Initial
443   commits are compared to an empty tree, so `I` is !TREESAME.
445 * In `A`, `foo` contains just "foo".
447 * `B` contains the same change as `A`.  Its merge `M` is trivial and
448   hence TREESAME to all parents.
450 * `C` does not change `foo`, but its merge `N` changes it to "foobar",
451   so it is not TREESAME to any parent.
453 * `D` sets `foo` to "baz".  Its merge `O` combines the strings from
454   `N` and `D` to "foobarbaz"; i.e., it is not TREESAME to any parent.
456 * `E` changes `quux` to "xyzzy", and its merge `P` combines the
457   strings to "quux xyzzy".  Despite appearing interesting, `P` is
458   TREESAME to all parents.
460 'rev-list' walks backwards through history, including or excluding
461 commits based on whether '\--full-history' and/or parent rewriting
462 (via '\--parents' or '\--children') are used.  The following settings
463 are available.
465 Default mode::
467         Commits are included if they are not TREESAME to any parent
468         (though this can be changed, see '\--sparse' below).  If the
469         commit was a merge, and it was TREESAME to one parent, follow
470         only that parent.  (Even if there are several TREESAME
471         parents, follow only one of them.)  Otherwise, follow all
472         parents.
474 This results in:
476 -----------------------------------------------------------------------
477           .-A---N---O
478          /     /   /
479         I---------D
480 -----------------------------------------------------------------------
482 Note how the rule to only follow the TREESAME parent, if one is
483 available, removed `B` from consideration entirely.  `C` was
484 considered via `N`, but is TREESAME.  Root commits are compared to an
485 empty tree, so `I` is !TREESAME.
487 Parent/child relations are only visible with --parents, but that does
488 not affect the commits selected in default mode, so we have shown the
489 parent lines.
491 --full-history without parent rewriting::
493         This mode differs from the default in one point: always follow
494         all parents of a merge, even if it is TREESAME to one of them.
495         Even if more than one side of the merge has commits that are
496         included, this does not imply that the merge itself is!  In
497         the example, we get
499 -----------------------------------------------------------------------
500         I  A  B  N  D  O
501 -----------------------------------------------------------------------
503 `P` and `M` were excluded because they are TREESAME to a parent.  `E`,
504 `C` and `B` were all walked, but only `B` was !TREESAME, so the others
505 do not appear.
507 Note that without parent rewriting, it is not really possible to talk
508 about the parent/child relationships between the commits, so we show
509 them disconnected.
511 --full-history with parent rewriting::
513         Ordinary commits are only included if they are !TREESAME
514         (though this can be changed, see '\--sparse' below).
516 Merges are always included.  However, their parent list is rewritten:
517 Along each parent, prune away commits that are not included
518 themselves.  This results in
520 -----------------------------------------------------------------------
521           .-A---M---N---O---P
522          /     /   /   /   /
523         I     B   /   D   /
524          \   /   /   /   /
525           `-------------'
526 -----------------------------------------------------------------------
528 Compare to '\--full-history' without rewriting above.  Note that `E`
529 was pruned away because it is TREESAME, but the parent list of P was
530 rewritten to contain `E`'s parent `I`.  The same happened for `C` and
531 `N`.  Note also that `P` was included despite being TREESAME.
533 In addition to the above settings, you can change whether TREESAME
534 affects inclusion:
536 --dense::
538         Commits that are walked are included if they are not TREESAME
539         to any parent.
541 --sparse::
543         All commits that are walked are included.
545 Note that without '\--full-history', this still simplifies merges: if
546 one of the parents is TREESAME, we follow only that one, so the other
547 sides of the merge are never walked.
549 --simplify-merges::
551         First, build a history graph in the same way that
552         '\--full-history' with parent rewriting does (see above).
554 Then simplify each commit `C` to its replacement `C'` in the final
555 history according to the following rules:
558 * Set `C'` to `C`.
560 * Replace each parent `P` of `C'` with its simplification `P'`.  In
561   the process, drop parents that are ancestors of other parents, and
562   remove duplicates.
564 * If after this parent rewriting, `C'` is a root or merge commit (has
565   zero or >1 parents), a boundary commit, or !TREESAME, it remains.
566   Otherwise, it is replaced with its only parent.
569 The effect of this is best shown by way of comparing to
570 '\--full-history' with parent rewriting.  The example turns into:
572 -----------------------------------------------------------------------
573           .-A---M---N---O
574          /     /       /
575         I     B       D
576          \   /       /
577           `---------'
578 -----------------------------------------------------------------------
580 Note the major differences in `N` and `P` over '\--full-history':
583 * `N`'s parent list had `I` removed, because it is an ancestor of the
584   other parent `M`.  Still, `N` remained because it is !TREESAME.
586 * `P`'s parent list similarly had `I` removed.  `P` was then
587   removed completely, because it had one parent and is TREESAME.
590 Finally, there is a fifth simplification mode available:
592 --ancestry-path::
594         Limit the displayed commits to those directly on the ancestry
595         chain between the "from" and "to" commits in the given commit
596         range. I.e. only display commits that are ancestor of the "to"
597         commit, and descendants of the "from" commit.
599 As an example use case, consider the following commit history:
601 -----------------------------------------------------------------------
602             D---E-------F
603            /     \       \
604           B---C---G---H---I---J
605          /                     \
606         A-------K---------------L--M
607 -----------------------------------------------------------------------
609 A regular 'D..M' computes the set of commits that are ancestors of `M`,
610 but excludes the ones that are ancestors of `D`. This is useful to see
611 what happened to the history leading to `M` since `D`, in the sense
612 that "what does `M` have that did not exist in `D`". The result in this
613 example would be all the commits, except `A` and `B` (and `D` itself,
614 of course).
616 When we want to find out what commits in `M` are contaminated with the
617 bug introduced by `D` and need fixing, however, we might want to view
618 only the subset of 'D..M' that are actually descendants of `D`, i.e.
619 excluding `C` and `K`. This is exactly what the '\--ancestry-path'
620 option does. Applied to the 'D..M' range, it results in:
622 -----------------------------------------------------------------------
623                 E-------F
624                  \       \
625                   G---H---I---J
626                                \
627                                 L--M
628 -----------------------------------------------------------------------
630 The '\--simplify-by-decoration' option allows you to view only the
631 big picture of the topology of the history, by omitting commits
632 that are not referenced by tags.  Commits are marked as !TREESAME
633 (in other words, kept after history simplification rules described
634 above) if (1) they are referenced by tags, or (2) they change the
635 contents of the paths given on the command line.  All other
636 commits are marked as TREESAME (subject to be simplified away).
638 ifdef::git-rev-list[]
639 Bisection Helpers
640 ~~~~~~~~~~~~~~~~~
642 --bisect::
644 Limit output to the one commit object which is roughly halfway between
645 included and excluded commits. Note that the bad bisection ref
646 `refs/bisect/bad` is added to the included commits (if it
647 exists) and the good bisection refs `refs/bisect/good-*` are
648 added to the excluded commits (if they exist). Thus, supposing there
649 are no refs in `refs/bisect/`, if
651 -----------------------------------------------------------------------
652         $ git rev-list --bisect foo ^bar ^baz
653 -----------------------------------------------------------------------
655 outputs 'midpoint', the output of the two commands
657 -----------------------------------------------------------------------
658         $ git rev-list foo ^midpoint
659         $ git rev-list midpoint ^bar ^baz
660 -----------------------------------------------------------------------
662 would be of roughly the same length.  Finding the change which
663 introduces a regression is thus reduced to a binary search: repeatedly
664 generate and test new 'midpoint's until the commit chain is of length
665 one.
667 --bisect-vars::
669 This calculates the same as `--bisect`, except that refs in
670 `refs/bisect/` are not used, and except that this outputs
671 text ready to be eval'ed by the shell. These lines will assign the
672 name of the midpoint revision to the variable `bisect_rev`, and the
673 expected number of commits to be tested after `bisect_rev` is tested
674 to `bisect_nr`, the expected number of commits to be tested if
675 `bisect_rev` turns out to be good to `bisect_good`, the expected
676 number of commits to be tested if `bisect_rev` turns out to be bad to
677 `bisect_bad`, and the number of commits we are bisecting right now to
678 `bisect_all`.
680 --bisect-all::
682 This outputs all the commit objects between the included and excluded
683 commits, ordered by their distance to the included and excluded
684 commits. Refs in `refs/bisect/` are not used. The farthest
685 from them is displayed first. (This is the only one displayed by
686 `--bisect`.)
688 This is useful because it makes it easy to choose a good commit to
689 test when you want to avoid to test some of them for some reason (they
690 may not compile for example).
692 This option can be used along with `--bisect-vars`, in this case,
693 after all the sorted commit objects, there will be the same text as if
694 `--bisect-vars` had been used alone.
695 endif::git-rev-list[]
698 Commit Ordering
699 ~~~~~~~~~~~~~~~
701 By default, the commits are shown in reverse chronological order.
703 --topo-order::
705         This option makes them appear in topological order (i.e.
706         descendant commits are shown before their parents).
708 --date-order::
710         This option is similar to '--topo-order' in the sense that no
711         parent comes before all of its children, but otherwise things
712         are still ordered in the commit timestamp order.
714 --reverse::
716         Output the commits in reverse order.
717         Cannot be combined with '\--walk-reflogs'.
719 Object Traversal
720 ~~~~~~~~~~~~~~~~
722 These options are mostly targeted for packing of git repositories.
724 --objects::
726         Print the object IDs of any object referenced by the listed
727         commits.  '--objects foo ^bar' thus means "send me
728         all object IDs which I need to download if I have the commit
729         object 'bar', but not 'foo'".
731 --objects-edge::
733         Similar to '--objects', but also print the IDs of excluded
734         commits prefixed with a "-" character.  This is used by
735         linkgit:git-pack-objects[1] to build "thin" pack, which records
736         objects in deltified form based on objects contained in these
737         excluded commits to reduce network traffic.
739 --unpacked::
741         Only useful with '--objects'; print the object IDs that are not
742         in packs.
744 --no-walk::
746         Only show the given revs, but do not traverse their ancestors.
748 --do-walk::
750         Overrides a previous --no-walk.