threads / discuss / 2616

Re: Diffs "from" working directory

Subject: Re: Diffs "from" working directory

## tl;dr

12 messages between Nov 20, 2005 and Nov 22, 2005.

replies: 11people: 5as markdown or json

J. Bruce Fields· Nov 20, 2005, 17:43 UTC · lore
On Sun, Nov 20, 2005 at 06:17:15PM +0100, Blaisorblade wrote:
> I've given a look at commit fcc1ad70be5ff89996358b6d770cd229fec2a3ba, and 
> while it may or may not be the right thing to do, there's a misunderstanding 
> at the base.
What misunderstanding?  Could you quote it?
Show 14 quoted lines
> For instance, in the stg tree, before that patch, I can do:
> 
> $ echo ciao >> README
> $ stg diff -r HEAD:
> $ stg diff -r HEAD
> diff --git a/README b/README
> index 184ded8..adb3970 100644
> --- a/README
> +++ b/README
> @@ -12,3 +12,4 @@ StGIT commands.
> 
>  For the latest version see http://www.procode.org/stgit/
>  For a tutorial see http://wiki.procode.org/cgi-bin/wiki.cgi/StGIT_Tutorial
> +ciao

That's a diff *to* the working directory. My complaint was that there wasn't a convenient way to get a diff *from* the working directory.

It's nice to have a convenient shorthand for the current working directory, and since there's already a shorthand for the HEAD ("HEAD") it seemed more sensible to make "" the current working directory.

It's a minor point, but it seems convenient.
--b.
Linus Torvalds· Nov 20, 2005, 18:13 UTC · re: J. Bruce Fields · lore
On Sun, 20 Nov 2005, J. Bruce Fields wrote:
> 
> That's a diff *to* the working directory.  My complaint was that there
> wasn't a convenient way to get a diff *from* the working directory.
Something like
	git diff -R -M -p
should do it, no?

("git diff" has the strange property that if you give it any diff flags at all, it forgets all the default ones. So it defaults to "-M -p", but if you just say "-R", it will drop its own defaults, and use _just_ "-R").

[ Which is almost certainly not what most users want, but it's practical 
  when you want to get the internal git format. Whether that is important 
  enough to confuse users or not, I dunno ]
		Linus
J. Bruce Fields· Nov 20, 2005, 20:58 UTC · re: Linus Torvalds · lore
On Sun, Nov 20, 2005 at 10:13:32AM -0800, Linus Torvalds wrote:
Show 10 quoted lines
> On Sun, 20 Nov 2005, J. Bruce Fields wrote:
> > 
> > That's a diff *to* the working directory.  My complaint was that there
> > wasn't a convenient way to get a diff *from* the working directory.
> 
> Something like
> 
> 	git diff -R -M -p
>
> should do it, no?
A "-R" option to "stg diff" would be convenient, sure.--b.
Chuck Lever· Nov 21, 2005, 01:53 UTC · re: J. Bruce Fields · lore
J. Bruce Fields wrote:
Show 15 quoted lines
> On Sun, Nov 20, 2005 at 10:13:32AM -0800, Linus Torvalds wrote:
> 
>>On Sun, 20 Nov 2005, J. Bruce Fields wrote:
>>
>>>That's a diff *to* the working directory.  My complaint was that there
>>>wasn't a convenient way to get a diff *from* the working directory.
>>
>>Something like
>>
>>	git diff -R -M -p
>>
>>should do it, no?
> 
> 
> A "-R" option to "stg diff" would be convenient, sure.--b.
that might be an even more intuitive way to dig out what is wanted.

btw, catalin, this was bruce's patch. i'm not sure why i was listed as the author (probably a mistake of mine when i imported his patch into my repository). ah well.

begin:vcard fn:Chuck Lever n:Lever;Charles org:Network Appliance, Incorporated;Linux NFS Client Development adr:535 West William Street, Suite 3100;;Center for Information Technology Integration;Ann Arbor;MI;48103-4943;USA email;internet:cel@citi.umich.edu title:Member of Technical Staff tel;work:+1 734 763-4415 tel;fax:+1 734 763 4434 tel;home:+1 734 668-1089 x-mozilla-html:FALSE url:http://www.monkey.org/~cel/ version:2.1 end:vcard

Catalin Marinas· Nov 21, 2005, 21:28 UTC · re: Chuck Lever · lore
On 21/11/05, Chuck Lever <cel@citi.umich.edu> wrote:
> J. Bruce Fields wrote:
> > A "-R" option to "stg diff" would be convenient, sure.--b.
>
> that might be an even more intuitive way to dig out what is wanted.

I also like the idea of having a -R option (--reverse the long version). This would mean reversing the commit that changed the diff -r option.

> btw, catalin, this was bruce's patch.  i'm not sure why i was listed as
> the author (probably a mistake of mine when i imported his patch into my
> repository).  ah well.
My import command sets the author to the e-mail sender, which was you.
Maybe this should be changed but I don't know which option is better.
In the meantime, you can change the default e-mail template to set the
From: line with to the author of the patch and maybe add a Reply-to:
with your address.

-- Catalin

Junio C Hamano· Nov 21, 2005, 21:40 UTC · re: Catalin Marinas · lore
Catalin Marinas <catalin.marinas@gmail.com> writes:
Show 5 quoted lines
> My import command sets the author to the e-mail sender, which was you.
> Maybe this should be changed but I don't know which option is better.
> In the meantime, you can change the default e-mail template to set the
> From: line with to the author of the patch and maybe add a Reply-to:
> with your address.
... and Sender: perhaps?

The first lines in the commit log message sent over e-mail can have "Subject: " (or "[PATCH] "), "From: ", and "Date: " to override what is slurped from e-mail headers if you use mailinfo, so that might be a better alternative to suggest.

Catalin Marinas· Nov 21, 2005, 21:45 UTC · re: Junio C Hamano · lore
On 21/11/05, Junio C Hamano <junkio@cox.net> wrote:
Show 9 quoted lines
> Catalin Marinas <catalin.marinas@gmail.com> writes:
>
> > My import command sets the author to the e-mail sender, which was you.
> > Maybe this should be changed but I don't know which option is better.
> > In the meantime, you can change the default e-mail template to set the
> > From: line with to the author of the patch and maybe add a Reply-to:
> > with your address.
>
> ... and Sender: perhaps?
Yes.
> The first lines in the commit log message sent over e-mail can
> have "Subject: " (or "[PATCH] "), "From: ", and "Date: " to
> override what is slurped from e-mail headers if you use mailinfo,
> so that might be a better alternative to suggest.

Thanks for the suggestion. It is indeed a good idea to parse the commit log and override the information from the headers.

-- Catalin

Chuck Lever· Nov 22, 2005, 05:15 UTC · re: Catalin Marinas · lore
Catalin Marinas wrote:
Show 10 quoted lines
>>btw, catalin, this was bruce's patch.  i'm not sure why i was listed as
>>the author (probably a mistake of mine when i imported his patch into my
>>repository).  ah well.
> 
> 
> My import command sets the author to the e-mail sender, which was you.
> Maybe this should be changed but I don't know which option is better.
> In the meantime, you can change the default e-mail template to set the
> From: line with to the author of the patch and maybe add a Reply-to:
> with your address.
for some reason i was under the impression that it would parse the 
Signed-off-by: fields in the patch description, and take the first one 
as the patch author.

begin:vcard fn:Chuck Lever n:Lever;Charles org:Network Appliance, Incorporated;Linux NFS Client Development adr:535 West William Street, Suite 3100;;Center for Information Technology Integration;Ann Arbor;MI;48103-4943;USA email;internet:cel@citi.umich.edu title:Member of Technical Staff tel;work:+1 734 763-4415 tel;fax:+1 734 763 4434 tel;home:+1 734 668-1089 x-mozilla-html:FALSE url:http://www.monkey.org/~cel/ version:2.1 end:vcard

Linus Torvalds· Nov 22, 2005, 05:33 UTC · re: Chuck Lever · lore
On Tue, 22 Nov 2005, Chuck Lever wrote:
> 
> for some reason i was under the impression that it would parse the
> Signed-off-by: fields in the patch description, and take the first one as the
> patch author.
The first sign-off really isn't necessarily the author.

It might be a company sign-off (many companies don't want any random engineer to send out patches), but much more commonly it's a trivial patch that somebody else signs off on, even if the original patcher didn't (see case (b) in the sign-off-rules: you can sign of on somebody elses work if you know it's under the GPL).

So the fact that there was a sign-off procedure doesn't automatically mean that the author will be the first sign-off person, although in _practice_ that obviously would likely always be the most common case by far.

(Another reason is that some people actually add the sign-offs above previous ones. It happens, although if I notice, I try to point it out).

So authorship really is totally separate from sign-off, and all _my_ tools take the authorship from the first "From:" line at the top of the message body or from the email itself.

			Linus
Chuck Lever· Nov 22, 2005, 18:03 UTC · re: Linus Torvalds · lore
Linus Torvalds wrote:
Show 15 quoted lines
> 
> On Tue, 22 Nov 2005, Chuck Lever wrote:
> 
>>for some reason i was under the impression that it would parse the
>>Signed-off-by: fields in the patch description, and take the first one as the
>>patch author.
> 
> 
> The first sign-off really isn't necessarily the author.
> 
> It might be a company sign-off (many companies don't want any random 
> engineer to send out patches), but much more commonly it's a trivial patch 
> that somebody else signs off on, even if the original patcher didn't (see 
> case (b) in the sign-off-rules: you can sign of on somebody elses work if 
> you know it's under the GPL).
heh.  in fact that is what my company (NetApp) requires.
Show 10 quoted lines
> So the fact that there was a sign-off procedure doesn't automatically mean 
> that the author will be the first sign-off person, although in _practice_ 
> that obviously would likely always be the most common case by far.
> 
> (Another reason is that some people actually add the sign-offs above 
> previous ones. It happens, although if I notice, I try to point it out).
> 
> So authorship really is totally separate from sign-off, and all _my_ tools 
> take the authorship from the first "From:" line at the top of the message 
> body or from the email itself.

then perhaps the problem is that the "stg mail" tool should place the author in the From: field automatically? (ie change the tool, or permanently modify the default template that comes with StGIT to do this, as Catalin suggested earlier).

that seems a little twisty to me; you're overloading the SMTP header field instead of explicitly specifying patch authorship. seems like a layering violation.

begin:vcard fn:Chuck Lever n:Lever;Charles org:Network Appliance, Incorporated;Linux NFS Client Development adr:535 West William Street, Suite 3100;;Center for Information Technology Integration;Ann Arbor;MI;48103-4943;USA email;internet:cel@citi.umich.edu title:Member of Technical Staff tel;work:+1 734 763-4415 tel;fax:+1 734 763 4434 tel;home:+1 734 668-1089 x-mozilla-html:FALSE url:http://www.monkey.org/~cel/ version:2.1 end:vcard

Linus Torvalds· Nov 22, 2005, 18:32 UTC · re: Chuck Lever · lore
On Tue, 22 Nov 2005, Chuck Lever wrote:
Show 9 quoted lines
> 
> then perhaps the problem is that the "stg mail" tool should place the author
> in the From: field automatically?  (ie change the tool, or permanently modify
> the default template that comes with StGIT to do this, as Catalin suggested
> earlier).
> 
> that seems a little twisty to me; you're overloading the SMTP header field
> instead of explicitly specifying patch authorship.  seems like a layering
> violation.

No, I only use the actual SMTP header field if the _body_ of the email doesn't contain the "From:".

So there's really two different "From:" lines: there's the SMTP header one, which is just a default fallback one, and there's the first non-empty line of the email body itself, which is the preferred one. No layering violation, just two different layers that have the same format for the line.

See "The Perfect Patch" by Andrew, and bullet (4): Attribution:
	http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt
To quote:
   'If someone else wrote the patch, they should be credited (and blamed) 
    for it. To communicate this, add a line:
    From: John Doe <jdoe@wherever.com>
    as the very first line of the email.  Downstream tools will pick this 
    up and jdoe will get the git "Author" line.'

and I'd be even more anal about it: I would seriously suggest to people that they just _always_ add the "From:" line at the head of the email, even if it just is exactly the same as what will be in the SMTP header.

Why? Simple. It makes is less likely that somebody who just forwards the patch will forget to add that line for you. So you are really helping people out - and making sure the attribution stays correct - by adding that extra "From:" line at the top of your email body, even if it is "unnecessary" in the sense that it's also in your SMTP header.

		Linus
Catalin Marinas· Nov 22, 2005, 10:35 UTC · re: Chuck Lever · lore
On 22/11/05, Chuck Lever <cel@citi.umich.edu> wrote:
Show 6 quoted lines
> Catalin Marinas wrote:
> > My import command sets the author to the e-mail sender, which was you.
>
> for some reason i was under the impression that it would parse the
> Signed-off-by: fields in the patch description, and take the first one
> as the patch author.

If you import a patch file and don't specify an author (and the patch is not an e-mail), the first Signed-off-by: line is used. As Linus mentioned, we could get rid of this assumption entirely and just report an error if no author information is given.

-- Catalin

← back to recent threads