git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] diff: allow turning on textconv explicitly for plumbing
@ 2008-12-08  2:57 Jeff King
  2008-12-08  3:55 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2008-12-08  2:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Some history viewers use the diff plumbing to generate diffs
rather than going through the "git diff" porcelain.
Currently, there is no way for them to specify that they
would like to see the text-converted version of the diff.

This patch adds a "--textconv" option to allow such a
plumbing user to allow text conversion.  The user can then
tell the viewer whether or not they would like text
conversion enabled.

While it may be tempting add a configuration option rather
than requiring each plumbing user to be configured to pass
--textconv, that is somewhat dangerous. Text-converted diffs
generally cannot be applied directly, so each plumbing user
should "opt in" to generating such a diff, either by
explicit request of the user or by confirming that their
output will not be fed to patch.

Signed-off-by: Jeff King <peff@peff.net>
---
My ultimate goal is to see these diffs in gitk, which is implemented in
3/3. As a bonus side effect, the --no-textconv option can be used with
"git diff" or "git log" if you really don't want to see them there
(e.g., because you are abusing "git log" to produce a binary patch you
mean to apply).

I know this is not strictly a bugfix and we are in -rc, but:

  1. It is an enhancement to a previously unreleased feature, and
     shouldn't affect anything outside of that.

  2. It affects the scripting interface to textconv, so I would like to
     get it in before textconv is ever released so that it is always the
     "right way" to turn text conversion off or on.

 diff.c |    4 ++++
 diff.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/diff.c b/diff.c
index f644947..e21af3b 100644
--- a/diff.c
+++ b/diff.c
@@ -2477,6 +2477,10 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
 		DIFF_OPT_SET(options, ALLOW_EXTERNAL);
 	else if (!strcmp(arg, "--no-ext-diff"))
 		DIFF_OPT_CLR(options, ALLOW_EXTERNAL);
+	else if (!strcmp(arg, "--textconv"))
+		DIFF_OPT_SET(options, ALLOW_TEXTCONV);
+	else if (!strcmp(arg, "--no-textconv"))
+		DIFF_OPT_CLR(options, ALLOW_TEXTCONV);
 	else if (!strcmp(arg, "--ignore-submodules"))
 		DIFF_OPT_SET(options, IGNORE_SUBMODULES);
 
-- 
1.6.1.rc2.285.gc1cf2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-12-09  5:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-08  2:57 [PATCH 2/3] diff: allow turning on textconv explicitly for plumbing Jeff King
2008-12-08  3:55 ` Junio C Hamano
2008-12-08  4:08   ` Junio C Hamano
2008-12-08  4:59   ` Jeff King
2008-12-08  6:52     ` Junio C Hamano
2008-12-08  7:14       ` Jeff King
2008-12-08  8:27       ` Junio C Hamano
2008-12-09  5:48         ` Jeff King

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).