core-tutorial: trim the section on Inspecting Changes

Back when the core tutorial was written, `log` and `whatchanged` were scripted Porcelains. In the "Inspecting Changes" section that talks about the plumbing commands in the diff family, it made sense to use `log` and `whatchanged` as good examples of the use of these plumbing commands, and because even these scripted Porcelains were novelty (there wasn't the new end-user tutorial written), it made some sense to illustrate uses of the `git log` (and `git whatchanged`) scripted Porcelain commands. But we no longer have scripted `log` and `whatchanged` to serve as examples, and this document is not where the end users learn what `git log` command is about. Stop at briefly mentioning the possibility of combining rev-list with diff-tree to build your own log, and leave the end-user documentation of `log` to the new tutorial and the user manual. Also resurrect the last version of `git-log`, `git-whatchanged`, and `git-show` to serve as examples to contrib/examples/ directory. While at it, remove 'whatchanged' from a list of sample commands that are affected by GIT_FLUSH environment variable. This is not meant to be an exhaustive list but as a list of typical ones, and an old command that is kept primarily for backward compatibility does not belong to it. Helped-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Aug 9, 2013 at 10:28 UTC 627a8b8dcda6b6fd3946b2b5964c9154c410f518
4 files changed +47 -37
Documentation/git.txt
+1 -1
@@ -818,7 +818,7 @@ for further details.
818 'GIT_FLUSH'::
819 If this environment variable is set to "1", then commands such
820 as 'git blame' (in incremental mode), 'git rev-list', 'git log',
821 - 'git check-attr', 'git check-ignore', and 'git whatchanged' will
821 + 'git check-attr' and 'git check-ignore' will
822 force a flush of the output stream after each record have been
823 flushed. If this
824 variable is set to "0", the output of these commands will be done
Documentation/gitcore-tutorial.txt
+3 -36
@@ -534,42 +534,9 @@ all, but just show the actual commit message.
534
535 In fact, together with the 'git rev-list' program (which generates a
536 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.
540
541
542 Tagging a version
contrib/examples/git-log.sh new
+15
@@ -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 new
+28
@@ -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}