Merge branch 'mm/war-on-whatchanged'

* mm/war-on-whatchanged:
  whatchanged: document its historical nature
  core-tutorial: trim the section on Inspecting Changes
This commit is contained in:
Junio C Hamano 2013-08-30 10:08:26 -07:00
Родитель 482bd22d49 52f425e1a9
Коммит 9bb78de519
5 изменённых файлов: 54 добавлений и 70 удалений

Просмотреть файл

@ -13,43 +13,17 @@ SYNOPSIS
DESCRIPTION
-----------
Shows commit logs and diff output each commit introduces. The
command internally invokes 'git rev-list' piped to
'git diff-tree', and takes command line options for both of
these commands.
This manual page describes only the most frequently used options.
Shows commit logs and diff output each commit introduces.
New users are encouraged to use linkgit:git-log[1] instead. The
`whatchanged` command is essentially the same as linkgit:git-log[1]
but defaults to show the raw format diff output and to skip merges.
OPTIONS
-------
-p::
Show textual diffs, instead of the Git internal diff
output format that is useful only to tell the changed
paths and their nature of changes.
The command is kept primarily for historical reasons; fingers of
many people who learned Git long before `git log` was invented by
reading Linux kernel mailing list are trained to type it.
-<n>::
Limit output to <n> commits.
<since>..<until>::
Limit output to between the two named commits (bottom
exclusive, top inclusive).
-r::
Show Git internal diff output, but for the whole tree,
not just the top level.
-m::
By default, differences for merge commits are not shown.
With this flag, show differences to that commit from all
of its parents.
+
However, it is not very useful in general, although it
*is* useful on a file-by-file basis.
include::pretty-options.txt[]
include::pretty-formats.txt[]
Examples
--------

Просмотреть файл

@ -823,7 +823,7 @@ for further details.
'GIT_FLUSH'::
If this environment variable is set to "1", then commands such
as 'git blame' (in incremental mode), 'git rev-list', 'git log',
'git check-attr', 'git check-ignore', and 'git whatchanged' will
'git check-attr' and 'git check-ignore' will
force a flush of the output stream after each record have been
flushed. If this
variable is set to "0", the output of these commands will be done

Просмотреть файл

@ -534,42 +534,9 @@ all, but just show the actual commit message.
In fact, together with the 'git rev-list' program (which generates a
list of revisions), 'git diff-tree' ends up being a veritable fount of
changes. A trivial (but very useful) script called 'git whatchanged' is
included with Git which does exactly this, and shows a log of recent
activities.
To see the whole history of our pitiful little git-tutorial project, you
can do
----------------
$ git log
----------------
which shows just the log messages, or if we want to see the log together
with the associated patches use the more complex (and much more
powerful)
----------------
$ git whatchanged -p
----------------
and you will see exactly what has changed in the repository over its
short history.
[NOTE]
When using the above two commands, the initial commit will be shown.
If this is a problem because it is huge, you can hide it by setting
the log.showroot configuration variable to false. Having this, you
can still show it for each command just adding the `--root` option,
which is a flag for 'git diff-tree' accepted by both commands.
With that, you should now be having some inkling of what Git does, and
can explore on your own.
[NOTE]
Most likely, you are not directly using the core
Git Plumbing commands, but using Porcelain such as 'git add', `git-rm'
and `git-commit'.
changes. You can emulate `git log`, `git log -p`, etc. with a trivial
script that pipes the output of `git rev-list` to `git diff-tree --stdin`,
which was exactly how early versions of `git log` were implemented.
Tagging a version

15
contrib/examples/git-log.sh Executable file
Просмотреть файл

@ -0,0 +1,15 @@
#!/bin/sh
#
# Copyright (c) 2005 Linus Torvalds
#
USAGE='[--max-count=<n>] [<since>..<limit>] [--pretty=<format>] [git-rev-list options]'
SUBDIRECTORY_OK='Yes'
. git-sh-setup
revs=$(git-rev-parse --revs-only --no-flags --default HEAD "$@") || exit
[ "$revs" ] || {
die "No HEAD ref"
}
git-rev-list --pretty $(git-rev-parse --default HEAD "$@") |
LESS=-S ${PAGER:-less}

Просмотреть файл

@ -0,0 +1,28 @@
#!/bin/sh
USAGE='[-p] [--max-count=<n>] [<since>..<limit>] [--pretty=<format>] [-m] [git-diff-tree options] [git-rev-list options]'
SUBDIRECTORY_OK='Yes'
. git-sh-setup
diff_tree_flags=$(git-rev-parse --sq --no-revs --flags "$@") || exit
case "$0" in
*whatchanged)
count=
test -z "$diff_tree_flags" &&
diff_tree_flags=$(git-repo-config --get whatchanged.difftree)
diff_tree_default_flags='-c -M --abbrev' ;;
*show)
count=-n1
test -z "$diff_tree_flags" &&
diff_tree_flags=$(git-repo-config --get show.difftree)
diff_tree_default_flags='--cc --always' ;;
esac
test -z "$diff_tree_flags" &&
diff_tree_flags="$diff_tree_default_flags"
rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
diff_tree_args=$(git-rev-parse --sq --no-revs --no-flags "$@") &&
eval "git-rev-list $count $rev_list_args" |
eval "git-diff-tree --stdin --pretty -r $diff_tree_flags $diff_tree_args" |
LESS="$LESS -S" ${PAGER:-less}