git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] whatchanged: customize diff-tree output

From
Junio C Hamano <junkio@cox.net>
Date
Dec 22, 2005, 06:21 UTC
Message-ID
<7vvexhr6rc.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0512212336230.18908@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 6 quoted lines
> The output is much nicer on standard 80 columns. If you want the old
> behaviour, you can still do
>
> 	git-whatchanged --abbrev=40
>
> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>

You already know I am in favor of this; it was the motivation behind --abbrev. With an 80-column terminal, especially with the hardcoded LESS=-S switch, the default diff-raw output was unusable.

How about doing something like this patch first, and then decide what the default should be?

I would recommend "--pretty -r --name-status -M" as the default. But I am not particularly interested in imposing my preference over that of Linus to the end users.

-- >8 -- This allows the configuration item whatchanged.difftree to control the output from git-whatchanged command. For example:

	[whatchanged]
        	difftree = --pretty=fuller --name-status -M

does rename detection, shows the commit header in "fuller" format and lists modified pathnames with the kind of change instead of the default hash pairs.

Not having the configuration item is the same as the original output format (--pretty -r).

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/git-whatchanged.sh b/git-whatchanged.sh
index b170f74..b651b3f 100755
--- a/git-whatchanged.sh
+++ b/git-whatchanged.sh
@@ -4,9 +4,15 @@ USAGE='[-p] [--max-count=<n>] [<since>..
 SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
+diff_tree_flags=$(git-rev-parse --sq --no-revs --flags "$@")
+test -z "$diff_tree_flags" &&
+	diff_tree_flags=$(git-repo-config --get whatchanged.difftree)
+test -z "$diff_tree_flags" &&
+	diff_tree_flags='' # NEW DEFAULT HERE
+
 rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
-diff_tree_args=$(git-rev-parse --sq --no-revs "$@") &&
+diff_tree_args=$(git-rev-parse --sq --no-revs --no-flags "$@") &&
 
 eval "git-rev-list $rev_list_args" |
-eval "git-diff-tree --stdin --pretty -r $diff_tree_args" |
+eval "git-diff-tree --stdin --pretty -r $diff_tree_flags $diff_tree_args" |
 LESS="$LESS -S" ${PAGER:-less}
Previous: Johannes SchindelinNext: Linus Torvalds
Message 2 of 9 in “Use --abbrev in git-whatchanged”
  1. Use --abbrev in git-whatchangedJohannes Schindelin, Dec 21, 2005
  2. whatchanged: customize diff-tree outputJunio C Hamano, Dec 22, 2005
  3. Linus TorvaldsDec 22, 2005
  4. Johannes SchindelinDec 22, 2005
  5. Alex RiesenDec 22, 2005
  6. Johannes SchindelinDec 22, 2005
  7. Alex RiesenDec 23, 2005
  8. Junio C HamanoDec 23, 2005
  9. Junio C HamanoDec 24, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.