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

Re: [RFC/PATCH] attr: map builtin userdiff drivers to well-known extensions

From
Jeff King <peff@peff.net>
Date
Aug 26, 2011, 02:59 UTC
Message-ID
<20110826025913.GC17625@sigill.intra.peff.net>
In-Reply-To
<7v8vqhhzgd.fsf@alter.siamese.dyndns.org>
On Thu, Aug 25, 2011 at 03:57:06PM -0700, Junio C Hamano wrote:
Show 22 quoted lines
> > If you have any matching attribute line in your own files, it should
> > override. So:
> >
> >   foo/* -diff
> >
> > will still mark foo/bar.c as binary, even with this change.
> >
> > Can anyone think of other possible side effects?
> >
> > Also, any other extensions that would go into such a list? I have no
> > idea what the common extension is for something like pascal or csharp.
> 
> As long as the builtin ones are the lowest priority fallback, we should be
> Ok.
> 
> Do we say anywhere that "Ah, this has 'diff' attribute defined, so it must
> be text"? If so, we should fix _that_. In other words, having this one
> extra entry
> 
> 	"* diff=default"
> 
> in the builtin_attr[] array should be a no-op, I think.

No, certainly not since 122aa6f (diff: introduce diff.<driver>.binary, 2008-10-05). That commit's message claims that we did before it, but looking at the patch, I am not so sure. But I'm not about to start testing a 3-year-old patch to see if it really was the source of the fix; the point is that it is correct now. :)

I think it could be a problem in the future if the builtin userdiff drivers started growing more invasive options, like automatically claiming to be non-binary (i.e., setting diff.cpp.binary = false by default). In other words, I think we have two options:

  1. Builtin drivers like "cpp" can stay minimal, only setting funcname
     and color-words headers that aren't going to produce terrible
     results if we are wrong about detecting by extension.
  2. We force the user to identify file types manually, so we can't be
     wrong. The "cpp" diff driver means "you are a text C file", and if
     a user mis-marks a binary file with that diff driver, they are the
     one who is wrong.

So if it's an either/or situation, we should decide not only that extension auto-detection is a good feature, but that it trumps adding more advanced features to the builtin drivers in the future.

Or we could decide that the extensions really are good enough, and if you really do have binary files named "foo.c", it's your problem to override the defaults with "*.c -diff".

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 14 of 23 in “git diff annoyance / feature request”
  1. Boaz HarroshAug 25, 2011
  2. Jeff KingAug 25, 2011
  3. attr: map builtin userdiff drivers to well-known extensionsJeff King, Aug 25, 2011
  4. Eric SunshineAug 25, 2011
  5. Jeff KingAug 25, 2011
  6. Boaz HarroshAug 25, 2011
  7. Eric SunshineAug 25, 2011
  8. Jeff KingAug 26, 2011
  9. Brandon CaseyAug 25, 2011
  10. Jeff KingAug 26, 2011
  11. Eric SunshineAug 26, 2011
  12. Brandon CaseyAug 26, 2011
  13. Junio C HamanoAug 25, 2011
  14. Jeff KingAug 26, 2011
  15. Junio C HamanoAug 26, 2011
  16. Thomas RastAug 26, 2011
  17. Alexey ShumkinAug 27, 2011
  18. Junio C HamanoAug 25, 2011
  19. Boaz HarroshAug 25, 2011
  20. Miles BaderAug 26, 2011
  21. René ScharfeAug 26, 2011
  22. Boaz HarroshAug 26, 2011
  23. Junio C HamanoAug 26, 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.