git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* diff settings
@ 2009-01-24 17:38 Keith Cascio
  2009-01-24 19:22 ` Jeff King
  2009-01-24 19:33 ` Teemu Likonen
  0 siblings, 2 replies; 13+ messages in thread
From: Keith Cascio @ 2009-01-24 17:38 UTC (permalink / raw)
  To: git

How do I configure my local git so that diff always obeys a particular option, 
e.g. "-w", without needing to type it on the command line each time?

Thanks,
Keith

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-24 17:38 diff settings Keith Cascio
@ 2009-01-24 19:22 ` Jeff King
  2009-01-24 19:33 ` Teemu Likonen
  1 sibling, 0 replies; 13+ messages in thread
From: Jeff King @ 2009-01-24 19:22 UTC (permalink / raw)
  To: Keith Cascio; +Cc: git

On Sat, Jan 24, 2009 at 09:38:18AM -0800, Keith Cascio wrote:

> How do I configure my local git so that diff always obeys a particular
> option, e.g. "-w", without needing to type it on the command line each
> time?

AFAIK, there is not a way to do it in the general case (though there are
specific config options for things like rename support). When I
refactored the gitattributes diff=$foo code a few months back, I tried
to keep in mind the possibility of a "diff options" field. But I never
actually implemented anything, as I don't personally ever use diff
options in such a way.

If you're interested, it would probably not be too hard to implement
(see userdiff.[ch], and the external and textconv code in diff.c for a
start).

-Peff

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-24 17:38 diff settings Keith Cascio
  2009-01-24 19:22 ` Jeff King
@ 2009-01-24 19:33 ` Teemu Likonen
  2009-01-24 20:01   ` Keith Cascio
  1 sibling, 1 reply; 13+ messages in thread
From: Teemu Likonen @ 2009-01-24 19:33 UTC (permalink / raw)
  To: Keith Cascio; +Cc: git

Keith Cascio (2009-01-24 09:38 -0800) wrote:

> How do I configure my local git so that diff always obeys a particular
> option, e.g. "-w", without needing to type it on the command line each
> time?

It seems that the answer is "no", but aliases are a work-around:

    git config --global alias.dff "diff -w"

Then "git dff" is your new "git diff -w". :-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-24 19:33 ` Teemu Likonen
@ 2009-01-24 20:01   ` Keith Cascio
  2009-01-25 21:02     ` Ted Pavlic
  0 siblings, 1 reply; 13+ messages in thread
From: Keith Cascio @ 2009-01-24 20:01 UTC (permalink / raw)
  To: Teemu Likonen; +Cc: git

> It seems that the answer is "no", but aliases are a work-around:
> 
>     git config --global alias.dff "diff -w"
> 
> Then "git dff" is your new "git diff -w". :-)

That feature is gonna come in handy.  It doesn't 100% fulfill my needs here but 
I like it!  Thanks, I did not know about alias.*

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-24 20:01   ` Keith Cascio
@ 2009-01-25 21:02     ` Ted Pavlic
  2009-01-25 21:11       ` Keith Cascio
  0 siblings, 1 reply; 13+ messages in thread
From: Ted Pavlic @ 2009-01-25 21:02 UTC (permalink / raw)
  To: Keith Cascio; +Cc: Teemu Likonen, git

>>      git config --global alias.dff "diff -w"
>>
>> Then "git dff" is your new "git diff -w". :-)
>
> That feature is gonna come in handy.  It doesn't 100% fulfill my needs here but
> I like it!  Thanks, I did not know about alias.*

Mercurial has a "defaults.*" that does exactly what you want. That is, 
you can say

[defaults]
diff = -w

and "hg diff" will automatically do "hg diff -w". Such a feature might 
be a nice addition to git.

--Ted


-- 
Ted Pavlic <ted@tedpavlic.com>

   Please visit my ALS association page:
         http://web.alsa.org/goto/tedpavlic
   My family appreciates your support in the fight to defeat ALS.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-25 21:02     ` Ted Pavlic
@ 2009-01-25 21:11       ` Keith Cascio
  2009-01-26  2:06         ` Ted Pavlic
  0 siblings, 1 reply; 13+ messages in thread
From: Keith Cascio @ 2009-01-25 21:11 UTC (permalink / raw)
  To: Ted Pavlic; +Cc: Teemu Likonen, git, Junio C Hamano, Johannes Schindelin

On Sun, 25 Jan 2009, Ted Pavlic wrote:

> Mercurial has a "defaults.*" that does exactly what you want. That is, you can
> say
> 
> [defaults]
> diff = -w
> 
> and "hg diff" will automatically do "hg diff -w". Such a feature might be a 
> nice addition to git.

Thank you, that is very interesting.  I just submitted a patch this morning that 
does exactly what you describe, but I called it "primer" instead of "defaults" 
because it seemed more explicit.  Check it out.

                            -- Keith

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-25 21:11       ` Keith Cascio
@ 2009-01-26  2:06         ` Ted Pavlic
  2009-01-29 16:26           ` Ted Pavlic
       [not found]           ` <alpine.GSO.2.00.0901310750470.5437@kiwi.cs.ucla.edu>
  0 siblings, 2 replies; 13+ messages in thread
From: Ted Pavlic @ 2009-01-26  2:06 UTC (permalink / raw)
  To: Keith Cascio; +Cc: Teemu Likonen, git, Junio C Hamano, Johannes Schindelin

>> Mercurial has a "defaults.*" that does exactly what you want. That is, you can
>> [defaults]
>> diff = -w
>> and "hg diff" will automatically do "hg diff -w". Such a feature might be a
>> nice addition to git.
> Thank you, that is very interesting.  I just submitted a patch this morning that
> does exactly what you describe, but I called it "primer" instead of "defaults"
> because it seemed more explicit.  Check it out.

I saw that. However, in Mercurial's case, the [defaults] section applies 
to all commands (including new ones introduced by extensions). That is, 
it looks like your patch adds a diff.primer, but Mercurial would add a 
primer.* that allows you to have a primer.diff, primer.commit, etc.

For example, wouldn't it be nice to have something like...

[defaults]
diff = -w
commit = -a

etc.? Right now the only way you can do that is with aliases (e.g., I 
have an alias from "ci" to "commit -a").

This task is pretty easy in Mercurial because Mercurial porcelains are 
implemented as modules that are all executed through the central "hg" 
command. This isn't the case with git.

(on a somewhat unrelated note, Mercurial does have a [diff] section that 
allows for, say, forcing the use of git diff and other things)

--Ted



-- 
Ted Pavlic <ted@tedpavlic.com>

   Please visit my ALS association page:
         http://web.alsa.org/goto/tedpavlic
   My family appreciates your support in the fight to defeat ALS.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-26  2:06         ` Ted Pavlic
@ 2009-01-29 16:26           ` Ted Pavlic
  2009-01-29 16:33             ` Johannes Schindelin
       [not found]           ` <alpine.GSO.2.00.0901310750470.5437@kiwi.cs.ucla.edu>
  1 sibling, 1 reply; 13+ messages in thread
From: Ted Pavlic @ 2009-01-29 16:26 UTC (permalink / raw)
  To: Keith Cascio; +Cc: Teemu Likonen, git, Junio C Hamano, Johannes Schindelin

> This task is pretty easy in Mercurial because Mercurial porcelains are
> implemented as modules that are all executed through the central "hg"
> command. This isn't the case with git.

(on the other hand, having a "[defaults]" section that only applies when 
commands are called via "git" might be nice. That way you can use the 
"git-CMD" when you want to use CMD without the "[defaults]"... perhaps?)

-- 
Ted Pavlic <ted@tedpavlic.com>

   Please visit my ALS association page:
         http://web.alsa.org/goto/tedpavlic
   My family appreciates your support in the fight to defeat ALS.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-29 16:26           ` Ted Pavlic
@ 2009-01-29 16:33             ` Johannes Schindelin
  2009-01-29 18:46               ` Keith Cascio
  0 siblings, 1 reply; 13+ messages in thread
From: Johannes Schindelin @ 2009-01-29 16:33 UTC (permalink / raw)
  To: Ted Pavlic; +Cc: Keith Cascio, Teemu Likonen, git, Junio C Hamano

Hi,

On Thu, 29 Jan 2009, Ted Pavlic wrote:

> > This task is pretty easy in Mercurial because Mercurial porcelains are
> > implemented as modules that are all executed through the central "hg"
> > command. This isn't the case with git.
> 
> (on the other hand, having a "[defaults]" section that only applies when
> commands are called via "git" might be nice. That way you can use the
> "git-CMD" when you want to use CMD without the "[defaults]"... perhaps?)

Nope, the dash form is deprecated, and once y'all out there finally do not 
write it any more, we can start thinking about _not_ hardlinking the 
builtins to their dashed form anymore.

Believe it or not, we already have a distinction between what is called 
from scripts vs from humans: plumbing vs porcelain.  So you can set the 
defaults for porcelain as much as you want, but please leave plumbing 
alone.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-29 16:33             ` Johannes Schindelin
@ 2009-01-29 18:46               ` Keith Cascio
  2009-01-29 21:07                 ` Nanako Shiraishi
  0 siblings, 1 reply; 13+ messages in thread
From: Keith Cascio @ 2009-01-29 18:46 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Ted Pavlic, git, Junio C Hamano

On Thu, 29 Jan 2009, Johannes Schindelin wrote:

> we already have a distinction between what is called from scripts vs from 
> humans: plumbing vs porcelain.  So you can set the defaults for porcelain as 
> much as you want, but please leave plumbing alone.

May we consider "git diff" Porcelain and "git diff-{files,index,tree}" plumbing?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-29 18:46               ` Keith Cascio
@ 2009-01-29 21:07                 ` Nanako Shiraishi
  0 siblings, 0 replies; 13+ messages in thread
From: Nanako Shiraishi @ 2009-01-29 21:07 UTC (permalink / raw)
  To: Keith Cascio; +Cc: Johannes Schindelin, Ted Pavlic, git, Junio C Hamano

Quoting Keith Cascio <keith@CS.UCLA.EDU>:

> On Thu, 29 Jan 2009, Johannes Schindelin wrote:
>
>> we already have a distinction between what is called from scripts vs from 
>> humans: plumbing vs porcelain.  So you can set the defaults for porcelain as 
>> much as you want, but please leave plumbing alone.
>
> May we consider "git diff" Porcelain and "git diff-{files,index,tree}" plumbing?

Sure we may. To see the list of commands with categories, you can consult

http://www.kernel.org/pub/software/scm/git/docs/

Junio, I think you could have stated this a bit more clearly in your message

http://thread.gmane.org/gmane.comp.version-control.git/107069/focus=107165

to avoid confusion, especially when you know you are talking to somebody new to git.

-- 
Nanako Shiraishi
http://ivory.ap.teacup.com/nanako3/

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
       [not found]           ` <alpine.GSO.2.00.0901310750470.5437@kiwi.cs.ucla.edu>
@ 2009-01-31 19:47             ` Ted Pavlic
  2009-01-31 23:10               ` Keith Cascio
  0 siblings, 1 reply; 13+ messages in thread
From: Ted Pavlic @ 2009-01-31 19:47 UTC (permalink / raw)
  To: Keith Cascio; +Cc: git, Junio C Hamano, Johannes Schindelin, Nanako Shiraishi

> Thank you for alerting us to the Hg design.  I can appreciate the elegance of
> it, and I'm always in favor of the most general possible implementation.  But
> there is a subtle difference between diff.primer and primer.diff.

As I already discussed, Mercurial has both "diff.primer" and 
"primer.diff" precisely because "diff" settings affects so many Hg commands.

In particular, in my .hgrc, I have:

[diff]
git = 1

which causes all Mercurial commands that need to generate a diff to use 
gitdiff rather than truediff. However, if I *wanted* to apply a set of 
flags to a particular command, I could (using the equivalent "git" 
commands)...

[defaults]
pull = --rebase
commit = -a
format-patch = -M

So I see a purpose for both *.defaults and defaults.*. Of course, 
aliases are also nice (IIRC, Mercurial doesn't have "aliases", but I 
could be wrong). Mercurial users are very happy with having both 
available. I imagine git people would be too.

--Ted


-- 
Ted Pavlic <ted@tedpavlic.com>

   Please visit my ALS association page:
         http://web.alsa.org/goto/tedpavlic
   My family appreciates your support in the fight to defeat ALS.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: diff settings
  2009-01-31 19:47             ` Ted Pavlic
@ 2009-01-31 23:10               ` Keith Cascio
  0 siblings, 0 replies; 13+ messages in thread
From: Keith Cascio @ 2009-01-31 23:10 UTC (permalink / raw)
  To: Ted Pavlic; +Cc: git

On Sat, 31 Jan 2009, Ted Pavlic wrote:

> As I already discussed, Mercurial has both "diff.primer" and "primer.diff" 
> precisely because "diff" settings affects so many Hg commands.

Yes I remember you did mention that.

> In particular, in my .hgrc, I have:
> [diff]
> git = 1
> which causes all Mercurial commands that need to generate a diff to use
> gitdiff rather than truediff. However, if I *wanted* to apply a set of flags
> to a particular command, I could (using the equivalent "git" commands)...
> [defaults]
> pull = --rebase
> commit = -a
> format-patch = -M
> So I see a purpose for both *.defaults and defaults.*. Of course, aliases are 
> also nice (IIRC, Mercurial doesn't have "aliases", but I could be wrong). 
> Mercurial users are very happy with having both available. I imagine git 
> people would be too.

I like it!  I'm all for it.  Perfect opportunity for future work.  In fact, I 
think I already glanced at the part of the code that's the right place to make 
that stuff happen.

                                      -- Keith

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-01-31 23:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-24 17:38 diff settings Keith Cascio
2009-01-24 19:22 ` Jeff King
2009-01-24 19:33 ` Teemu Likonen
2009-01-24 20:01   ` Keith Cascio
2009-01-25 21:02     ` Ted Pavlic
2009-01-25 21:11       ` Keith Cascio
2009-01-26  2:06         ` Ted Pavlic
2009-01-29 16:26           ` Ted Pavlic
2009-01-29 16:33             ` Johannes Schindelin
2009-01-29 18:46               ` Keith Cascio
2009-01-29 21:07                 ` Nanako Shiraishi
     [not found]           ` <alpine.GSO.2.00.0901310750470.5437@kiwi.cs.ucla.edu>
2009-01-31 19:47             ` Ted Pavlic
2009-01-31 23:10               ` Keith Cascio

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).