git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add diff.minimal configuration setting
@ 2012-03-29 20:26 Victor Engmark
  2012-03-30  8:09 ` Jeff King
  0 siblings, 1 reply; 2+ messages in thread
From: Victor Engmark @ 2012-03-29 20:26 UTC (permalink / raw)
  To: git, gitster; +Cc: Thomas Rast

Complements the --minimal and --no-minimal options.

Signed-off-by: Victor Engmark <victor.engmark@gmail.com>
---

Follow-up from 8762g7u60j.fsf@thomas.inf.ethz.ch, for those with small
projects or cycles to spare. Since I couldn't `find t -iname
'*minimal*'`, I'm a bit at a loss for how to test this - Does anyone
have a test diff that will for sure show up differently with
--minimal?

Cheers,
V

 Documentation/diff-config.txt          |    4 ++++
 Documentation/diff-options.txt         |    4 +++-
 contrib/completion/git-completion.bash |    1 +
 diff.c                                 |    6 ++++++
 diff.h                                 |    1 +
 5 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
index 6aa1be0..6fcc070 100644
--- a/Documentation/diff-config.txt
+++ b/Documentation/diff-config.txt
@@ -71,6 +71,10 @@ diff.ignoreSubmodules::
 	commands such as 'git diff-files'. 'git checkout' also honors
 	this setting when reporting uncommitted changes.
 
+diff.minimal::
+	If set, 'git diff' spends extra time to make sure the smallest
+	possible diff is produced.
+
 diff.mnemonicprefix::
 	If set, 'git diff' uses a prefix pair that is different from the
 	standard "a/" and "b/" depending on what is being compared.  When
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 378f19f..879e2fd 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -47,7 +47,9 @@ endif::git-format-patch[]
 
 --minimal::
 	Spend extra time to make sure the smallest possible
-	diff is produced.
+	diff is produced. The default is controlled by the
+	`diff.minimal` configuration variable (see
+	linkgit:git-config[1]).
 
 --patience::
 	Generate a diff using the "patience diff" algorithm.
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 31f714d..33ff2f4 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -2096,6 +2096,7 @@ _git_config ()
 		diff.statGraphWidth
 		diff.external
 		diff.ignoreSubmodules
+		diff.minimal
 		diff.mnemonicprefix
 		diff.noprefix
 		diff.renameLimit
diff --git a/diff.c b/diff.c
index 377ec1e..e3add82 100644
--- a/diff.c
+++ b/diff.c
@@ -29,6 +29,7 @@ int diff_use_color_default = -1;
 static const char *diff_word_regex_cfg;
 static const char *external_diff_cmd_cfg;
 int diff_auto_refresh_index = 1;
+static int diff_minimal;
 static int diff_mnemonic_prefix;
 static int diff_no_prefix;
 static int diff_stat_graph_width;
@@ -157,6 +158,10 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
 		diff_no_prefix = git_config_bool(var, value);
 		return 0;
 	}
+	if (!strcmp(var, "diff.minimal")) {
+		diff_minimal = git_config_bool(var, value);
+		return 0;
+	}
 	if (!strcmp(var, "diff.statgraphwidth")) {
 		diff_stat_graph_width = git_config_int(var, value);
 		return 0;
@@ -3141,6 +3146,7 @@ void diff_setup(struct diff_options *options)
 	options->add_remove = diff_addremove;
 	options->use_color = diff_use_color_default;
 	options->detect_rename = diff_detect_rename_default;
+	options->minimal = diff_minimal;
 
 	if (diff_no_prefix) {
 		options->a_prefix = options->b_prefix = "";
diff --git a/diff.h b/diff.h
index cb68743..9bc67a8 100644
--- a/diff.h
+++ b/diff.h
@@ -118,6 +118,7 @@ struct diff_options {
 	int rename_score;
 	int rename_limit;
 	int needed_rename_limit;
+	int minimal;
 	int degraded_cc_to_c;
 	int show_rename_progress;
 	int dirstat_permille;
-- 
1.7.5.4

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

* Re: [PATCH] Add diff.minimal configuration setting
  2012-03-29 20:26 [PATCH] Add diff.minimal configuration setting Victor Engmark
@ 2012-03-30  8:09 ` Jeff King
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff King @ 2012-03-30  8:09 UTC (permalink / raw)
  To: Victor Engmark; +Cc: git, gitster, Thomas Rast

On Thu, Mar 29, 2012 at 10:26:48PM +0200, Victor Engmark wrote:

> Complements the --minimal and --no-minimal options.

There was a recent discussion here:

  http://article.gmane.org/gmane.comp.version-control.git/192719

where two similar options were considered:

  1. diff.algorithm should be added, and consider "minimal" to be a
     variant algorithm

  2. we should have a generic "diff options" config variable, in which
     one could put "--minimal", "--patience", or whatever.

I don't think anything was decided, but either option would remove the
need for a separate diff.minimal variable. Maybe it would be worth
combining efforts.

-Peff

PS I like the generality of (2), but the idea of diff defaults came up a
   few years ago, and I remember it devolving into quite a complex
   patch. But that may also just have been the patch submitter, who
   seemed very interested in complexifying things. I can dig up the
   discussion if you want.

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

end of thread, other threads:[~2012-03-30  8:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-29 20:26 [PATCH] Add diff.minimal configuration setting Victor Engmark
2012-03-30  8:09 ` 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).