Skip to content

Commit 9bb78de

Browse files
committed
Merge branch 'mm/war-on-whatchanged'
* mm/war-on-whatchanged: whatchanged: document its historical nature core-tutorial: trim the section on Inspecting Changes
2 parents 482bd22 + 52f425e commit 9bb78de

File tree

5 files changed

+54
-70
lines changed

5 files changed

+54
-70
lines changed

Documentation/git-whatchanged.txt

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,17 @@ SYNOPSIS
1313

1414
DESCRIPTION
1515
-----------
16-
Shows commit logs and diff output each commit introduces. The
17-
command internally invokes 'git rev-list' piped to
18-
'git diff-tree', and takes command line options for both of
19-
these commands.
2016

21-
This manual page describes only the most frequently used options.
17+
Shows commit logs and diff output each commit introduces.
2218

19+
New users are encouraged to use linkgit:git-log[1] instead. The
20+
`whatchanged` command is essentially the same as linkgit:git-log[1]
21+
but defaults to show the raw format diff output and to skip merges.
2322

24-
OPTIONS
25-
-------
26-
-p::
27-
Show textual diffs, instead of the Git internal diff
28-
output format that is useful only to tell the changed
29-
paths and their nature of changes.
23+
The command is kept primarily for historical reasons; fingers of
24+
many people who learned Git long before `git log` was invented by
25+
reading Linux kernel mailing list are trained to type it.
3026

31-
-<n>::
32-
Limit output to <n> commits.
33-
34-
<since>..<until>::
35-
Limit output to between the two named commits (bottom
36-
exclusive, top inclusive).
37-
38-
-r::
39-
Show Git internal diff output, but for the whole tree,
40-
not just the top level.
41-
42-
-m::
43-
By default, differences for merge commits are not shown.
44-
With this flag, show differences to that commit from all
45-
of its parents.
46-
+
47-
However, it is not very useful in general, although it
48-
*is* useful on a file-by-file basis.
49-
50-
include::pretty-options.txt[]
51-
52-
include::pretty-formats.txt[]
5327

5428
Examples
5529
--------

Documentation/git.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ for further details.
823823
'GIT_FLUSH'::
824824
If this environment variable is set to "1", then commands such
825825
as 'git blame' (in incremental mode), 'git rev-list', 'git log',
826-
'git check-attr', 'git check-ignore', and 'git whatchanged' will
826+
'git check-attr' and 'git check-ignore' will
827827
force a flush of the output stream after each record have been
828828
flushed. If this
829829
variable is set to "0", the output of these commands will be done

Documentation/gitcore-tutorial.txt

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -534,42 +534,9 @@ all, but just show the actual commit message.
534534

535535
In fact, together with the 'git rev-list' program (which generates a
536536
list of revisions), 'git diff-tree' ends up being a veritable fount of
537-
changes. A trivial (but very useful) script called 'git whatchanged' is
538-
included with Git which does exactly this, and shows a log of recent
539-
activities.
540-
541-
To see the whole history of our pitiful little git-tutorial project, you
542-
can do
543-
544-
----------------
545-
$ git log
546-
----------------
547-
548-
which shows just the log messages, or if we want to see the log together
549-
with the associated patches use the more complex (and much more
550-
powerful)
551-
552-
----------------
553-
$ git whatchanged -p
554-
----------------
555-
556-
and you will see exactly what has changed in the repository over its
557-
short history.
558-
559-
[NOTE]
560-
When using the above two commands, the initial commit will be shown.
561-
If this is a problem because it is huge, you can hide it by setting
562-
the log.showroot configuration variable to false. Having this, you
563-
can still show it for each command just adding the `--root` option,
564-
which is a flag for 'git diff-tree' accepted by both commands.
565-
566-
With that, you should now be having some inkling of what Git does, and
567-
can explore on your own.
568-
569-
[NOTE]
570-
Most likely, you are not directly using the core
571-
Git Plumbing commands, but using Porcelain such as 'git add', `git-rm'
572-
and `git-commit'.
537+
changes. You can emulate `git log`, `git log -p`, etc. with a trivial
538+
script that pipes the output of `git rev-list` to `git diff-tree --stdin`,
539+
which was exactly how early versions of `git log` were implemented.
573540

574541

575542
Tagging a version

contrib/examples/git-log.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2005 Linus Torvalds
4+
#
5+
6+
USAGE='[--max-count=<n>] [<since>..<limit>] [--pretty=<format>] [git-rev-list options]'
7+
SUBDIRECTORY_OK='Yes'
8+
. git-sh-setup
9+
10+
revs=$(git-rev-parse --revs-only --no-flags --default HEAD "$@") || exit
11+
[ "$revs" ] || {
12+
die "No HEAD ref"
13+
}
14+
git-rev-list --pretty $(git-rev-parse --default HEAD "$@") |
15+
LESS=-S ${PAGER:-less}

contrib/examples/git-whatchanged.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/sh
2+
3+
USAGE='[-p] [--max-count=<n>] [<since>..<limit>] [--pretty=<format>] [-m] [git-diff-tree options] [git-rev-list options]'
4+
SUBDIRECTORY_OK='Yes'
5+
. git-sh-setup
6+
7+
diff_tree_flags=$(git-rev-parse --sq --no-revs --flags "$@") || exit
8+
case "$0" in
9+
*whatchanged)
10+
count=
11+
test -z "$diff_tree_flags" &&
12+
diff_tree_flags=$(git-repo-config --get whatchanged.difftree)
13+
diff_tree_default_flags='-c -M --abbrev' ;;
14+
*show)
15+
count=-n1
16+
test -z "$diff_tree_flags" &&
17+
diff_tree_flags=$(git-repo-config --get show.difftree)
18+
diff_tree_default_flags='--cc --always' ;;
19+
esac
20+
test -z "$diff_tree_flags" &&
21+
diff_tree_flags="$diff_tree_default_flags"
22+
23+
rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
24+
diff_tree_args=$(git-rev-parse --sq --no-revs --no-flags "$@") &&
25+
26+
eval "git-rev-list $count $rev_list_args" |
27+
eval "git-diff-tree --stdin --pretty -r $diff_tree_flags $diff_tree_args" |
28+
LESS="$LESS -S" ${PAGER:-less}

0 commit comments

Comments
 (0)