All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Boaz Harrosh <bharrosh@panasas.com>
Cc: git@vger.kernel.org
Subject: [RFC/PATCH] attr: map builtin userdiff drivers to well-known extensions
Date: Thu, 25 Aug 2011 16:40:47 -0400	[thread overview]
Message-ID: <20110825204047.GA9948@sigill.intra.peff.net> (raw)
In-Reply-To: <20110825200001.GA6165@sigill.intra.peff.net>

We already provide sane hunk-header patterns for specific
languages. However, the user has to manually map common
extensions to use them. It's not that hard to do, but it's
an extra step that the user might not even know is an
option. Let's be nice and do it automatically.

Signed-off-by: Jeff King <peff@peff.net>
---
I tried to think of negative side effects.

The userdiff drivers we have are pretty conservative; they just specify
hunk headers. So if you have a binary file named "foo.c", we still do
the regular binary detection.

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.

 attr.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/attr.c b/attr.c
index da29c8e..5118a14 100644
--- a/attr.c
+++ b/attr.c
@@ -294,6 +294,18 @@ static void free_attr_elem(struct attr_stack *e)
 
 static const char *builtin_attr[] = {
 	"[attr]binary -diff -text",
+	"*.html diff=html",
+	"*.java diff=java",
+	"*.perl diff=perl",
+	"*.pl diff=perl",
+	"*.php diff=php",
+	"*.py diff=python",
+	"*.rb diff=ruby",
+	"*.bib diff=bibtex",
+	"*.tex diff=tex",
+	"*.c diff=cpp",
+	"*.cc diff=cpp",
+	"*.cxx diff=cpp",
 	NULL,
 };
 
-- 
1.7.6.10.g62f04

  reply	other threads:[~2011-08-25 20:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 19:14 git diff annoyance / feature request Boaz Harrosh
2011-08-25 20:00 ` Jeff King
2011-08-25 20:40   ` Jeff King [this message]
2011-08-25 21:00     ` [RFC/PATCH] attr: map builtin userdiff drivers to well-known extensions Eric Sunshine
2011-08-25 21:06       ` Jeff King
2011-08-25 22:01         ` Boaz Harrosh
2011-08-25 23:44         ` Eric Sunshine
2011-08-26  2:39           ` Jeff King
2011-08-25 22:29     ` Brandon Casey
2011-08-26  2:45       ` Jeff King
2011-08-26  3:58         ` Eric Sunshine
2011-08-26 15:33         ` Brandon Casey
2011-08-25 22:57     ` Junio C Hamano
2011-08-26  2:59       ` Jeff King
2011-08-26  5:52         ` Junio C Hamano
2011-08-26  9:44     ` Thomas Rast
2011-08-27  5:14     ` Alexey Shumkin
2011-08-25 20:27 ` git diff annoyance / feature request Junio C Hamano
2011-08-25 21:58   ` Boaz Harrosh
2011-08-26  9:08     ` Miles Bader
2011-08-26 21:16 ` René Scharfe
2011-08-26 21:37   ` Boaz Harrosh
2011-08-26 21:52     ` Junio C Hamano

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=20110825204047.GA9948@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=bharrosh@panasas.com \
    --cc=git@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.