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

Re: PostScript files: textconv and "git add -p"

From
Jeff King <peff@peff.net>
Date
Jan 5, 2011, 05:18 UTC
Message-ID
<20110105051807.GB5884@sigill.intra.peff.net>
In-Reply-To
<vpqy670brcb.fsf@bauges.imag.fr>
On Tue, Jan 04, 2011 at 04:50:44PM +0100, Matthieu Moy wrote:
Show 17 quoted lines
> If I do this:
> 
> ,----[ .gitattributes ]
> | *.ps diff=ps
> `----
> 
> ,----[ .gitconfig ]
> | [diff "ps"]
> |       textconv=ps2ascii
> `----
> 
> then I get the textconv niceness when running "git diff", which is
> cool, but "git add -p" still proposes me to stage hunks one by one,
> which isn't.
> 
> If I set "*.ps binary" in .gitattributes, "git add -p" becomes quiet,
> but textconv is disabled.

Yeah the "binary" attribute (which is a synonym for !diff along with some crlf stuff) and "diff" are mutually exclusive. One says "don't diff this" and the other says "diff this according to some special rules". But fortunately, those special rules can contain "this is binary". So you can get what you want with:

  echo '*.ps diff=ps' >.gitattributes
  git config diff.ps.textconv ps2ascii
  git config diff.ps.binary true

which will textconv the file in the usual places, but consider it binary in all other circumstances (like "add -p").

-Peff
PS Your question made me very happy. I implemented "diff.*.binary" the
   way I did out of a vague sense of orthogonality, but I never quite
   came up with a concrete example where it was useful to set both.
   Thanks for providing one. :)
Previous: Matthieu MoyNext: Matthieu Moy
Message 2 of 7 in “PostScript files: textconv and "git add -p"”
  1. Matthieu MoyJan 4, 2011
  2. Jeff KingJan 5, 2011
  3. Matthieu MoyJan 9, 2011
  4. docs: explain diff.*.binary optionJeff King, Jan 9, 2011
  5. Matthieu MoyJan 9, 2011
  6. Junio C HamanoJan 10, 2011
  7. Jeff KingJan 11, 2011

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.