# [PATCH] Use --abbrev in git-whatchanged

9 messages from 2005-12-21 to 2005-12-24. Participants: Johannes Schindelin, Junio C Hamano, Linus Torvalds, Alex Riesen.
Thread: https://gitlist.dev/t/2901

## Johannes Schindelin, 2005-12-21 22:37

Subject: [PATCH] Use --abbrev in git-whatchanged
Message-ID: <Pine.LNX.4.63.0512212336230.18908@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0512212336230.18908%40wbgn013.biozentrum.uni-wuerzburg.de

```

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>

---

 git-whatchanged.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

5d0a4d9aedc8af48666744ab240cdc30b9c6cae3
diff --git a/git-whatchanged.sh b/git-whatchanged.sh
index b170f74..a30f64d 100755
--- a/git-whatchanged.sh
+++ b/git-whatchanged.sh
@@ -8,5 +8,5 @@ rev_list_args=$(git-rev-parse --sq --def
 diff_tree_args=$(git-rev-parse --sq --no-revs "$@") &&
 
 eval "git-rev-list $rev_list_args" |
-eval "git-diff-tree --stdin --pretty -r $diff_tree_args" |
+eval "git-diff-tree --stdin --pretty -r --abbrev $diff_tree_args" |
 LESS="$LESS -S" ${PAGER:-less}
-- 
0.99.9.GIT

```

## Junio C Hamano, 2005-12-22 06:21

Subject: [PATCH] whatchanged: customize diff-tree output
Message-ID: <7vvexhr6rc.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vvexhr6rc.fsf%40assigned-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:

> 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}

```

## Linus Torvalds, 2005-12-22 06:48

Subject: Re: [PATCH] whatchanged: customize diff-tree output
Message-ID: <Pine.LNX.4.64.0512212245440.4827@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0512212245440.4827%40g5.osdl.org
In-Reply-To: <7vvexhr6rc.fsf@assigned-by-dhcp.cox.net>

```


On Wed, 21 Dec 2005, Junio C Hamano wrote:
> 
> 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.

I'm certainly ok with the short format by default. And making it 
configurable per repo sounds fine, although at the same time I wonder if 
that perhaps confuses people more (something that works in one project one 
way works subtly differently in another project..)

		Linus

```

## Johannes Schindelin, 2005-12-22 11:16

Subject: Re: [PATCH] whatchanged: customize diff-tree output
Message-ID: <Pine.LNX.4.63.0512221200190.7112@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0512221200190.7112%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <Pine.LNX.4.64.0512212245440.4827@g5.osdl.org>

```
Hi,

On Wed, 21 Dec 2005, Linus Torvalds wrote:

> On Wed, 21 Dec 2005, Junio C Hamano wrote:
> > 
> > How about doing something like this patch first, and then decide
> > what the default should be?

I see you already applied it, with a sane default. That's great!

> I'm certainly ok with the short format by default. And making it 
> configurable per repo sounds fine, although at the same time I wonder if 
> that perhaps confuses people more (something that works in one project one 
> way works subtly differently in another project..)

I cannot think of a saner way to have an overridable policy. Just provide 
a template config, and you're done. Everyone gets those flags per default, 
and if someone does not like it: go ahead, change it yourself!

Besides, you are usually calling git-whatchanged in your private working 
tree, where not many people can change the config.

Ciao,
Dscho

```

## Alex Riesen, 2005-12-22 21:06

Subject: Re: [PATCH] whatchanged: customize diff-tree output
Message-ID: <20051222210620.GA4679@steel.home>
URL: https://gitlist.dev/e/20051222210620.GA4679%40steel.home
In-Reply-To: <Pine.LNX.4.63.0512221200190.7112@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin, Thu, Dec 22, 2005 12:16:00 +0100:
> > I'm certainly ok with the short format by default. And making it 
> > configurable per repo sounds fine, although at the same time I wonder if 
> > that perhaps confuses people more (something that works in one project one 
> > way works subtly differently in another project..)
> 
> I cannot think of a saner way to have an overridable policy. Just provide 
> a template config, and you're done. Everyone gets those flags per default, 
> and if someone does not like it: go ahead, change it yourself!
> 
> Besides, you are usually calling git-whatchanged in your private working 
> tree, where not many people can change the config.
> 

That's the point, isn't it? A script from ~user1/bin, which calls
git-whatchanged suddenly stops working in ~user2/repo.
Besides, how can user1 know what he has to specify to git-whatchanged
(I assume the command line overrides .git/config) so that his script
works everywhere?

Maybe such configuration better left to environment variables?

```

## Johannes Schindelin, 2005-12-22 22:24

Subject: Re: [PATCH] whatchanged: customize diff-tree output
Message-ID: <Pine.LNX.4.63.0512222323110.12241@wbgn013.biozentrum.uni-wuerzburg.de>
URL: https://gitlist.dev/e/Pine.LNX.4.63.0512222323110.12241%40wbgn013.biozentrum.uni-wuerzburg.de
In-Reply-To: <20051222210620.GA4679@steel.home>

```
Hi,

On Thu, 22 Dec 2005, Alex Riesen wrote:

> A script from ~user1/bin, which calls git-whatchanged suddenly stops 
> working in ~user2/repo.
> [...]
> 
> Maybe such configuration better left to environment variables?

And that makes the script not stop how?

Ciao,
Dscho

```

## Junio C Hamano, 2005-12-23 04:19

Subject: Re: [PATCH] whatchanged: customize diff-tree output
Message-ID: <7vvexgfns4.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vvexgfns4.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20051222210620.GA4679@steel.home>

```
Alex Riesen <raa.lkml@gmail.com> writes:

> That's the point, isn't it? A script from ~user1/bin, which calls
> git-whatchanged suddenly stops working in ~user2/repo.

For scripted use you can give command line arguments yourself to
whatchanged and you can bypass the repoconfig.  I do not think
whatchanged is meant for scripted use, though --- it is such a
simple script, and if you want to build on it to do something
more elaborate, I think you would be better off writing those
rev-list and diff-tree in your script.

```

## Alex Riesen, 2005-12-23 18:12

Subject: Re: [PATCH] whatchanged: customize diff-tree output
Message-ID: <20051223181249.GA3165@steel.home>
URL: https://gitlist.dev/e/20051223181249.GA3165%40steel.home
In-Reply-To: <Pine.LNX.4.63.0512222323110.12241@wbgn013.biozentrum.uni-wuerzburg.de>

```
Johannes Schindelin, Thu, Dec 22, 2005 23:24:48 +0100:
> > A script from ~user1/bin, which calls git-whatchanged suddenly stops 
> > working in ~user2/repo.
> > [...]
> > 
> > Maybe such configuration better left to environment variables?
> 
> And that makes the script not stop how?
> 

It is another user, who does not have the variable set, or just unsets
the variable in his scripts (now he _can_ rely upon git-whatchanged
always doing the same)

```

## Junio C Hamano, 2005-12-24 09:44

Subject: Re: [PATCH] whatchanged: customize diff-tree output
Message-ID: <7vzmmqu8w4.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vzmmqu8w4.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20051223182047.GB3165@steel.home>

```
> But you cannot know which ones you have to give, unless you parsed
> output of git-repo-config!

Why?

I was suggesting that you would literally write something like
this in your script:

	git-whatchanged --name-status "$1".."$2"

Then whatchanged uses the '--name-status', and ignores whatever
is in the repository configuration, so you do not need to care
what repo-config says.  Neither used are its built-in defaults.

```
