git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Simon Fraser <smfr@mac.com>, git@vger.kernel.org
Subject: Re: Parsing diff --git lines
Date: Sun, 09 Mar 2008 00:25:06 -0800 (PST)	[thread overview]
Message-ID: <m3r6ekfgnw.fsf@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.1.00.0803081955110.5896@woody.linux-foundation.org>

Linus Torvalds <torvalds@linux-foundation.org> writes:

> On Sat, 8 Mar 2008, Simon Fraser wrote:
> > 
> > However, I don't see a reliable way to identify the two files
> > from a "diff --git" line. Here's a (deliberately pathological)
> > example:
> 
> See how "git-apply" does it.
> 
> The rule is:
> 
>  - if the filenames are different, you should ignore the filenames on the 
>    "diff --git" line, and trust the ones on the "renamed from/to" ones 
>    (which are unambiguous because they only have one filename per line)
> 
>  - if the filenames aren't different, then you can unambiguously know how 
>    to parse it by simply making sure they are the same.

By the way, the default pre-commit hook behaves a bit strangely on
files which contain spaces[*1*] in filename (due to GNU-diff-uism):

*
* You have some suspicious patch lines:
*
* In  b
* trailing whitespace (line 1)
 b:1:++ b/ b	

Foootnote:
==========
[*1*] If file has '"', '\' or control character in filename,
      it is quoted. 
-- 
Jakub Narebski
Poland
ShadeHawk on #git

  reply	other threads:[~2008-03-09  8:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-09  1:48 Parsing diff --git lines Simon Fraser
2008-03-09  4:04 ` Linus Torvalds
2008-03-09  8:25   ` Jakub Narebski [this message]
2008-03-09 20:45     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m3r6ekfgnw.fsf@localhost.localdomain \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=smfr@mac.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).