Michal Privoznik | 16 Jan 08:51 2013
Picon

[PATCH v3 0/3] Rework git-diff algorithm selection

It's been a while I was trying to get this in. Recently, I realized how
important this is.

Please keep me CC'ed as I am not subscribed to the list.

diff to v1:
-Junio's suggestions worked in

diff to v2:
-yet more Junio's suggestions included

Michal Privoznik (3):
  git-completion.bash: Autocomplete --minimal and --histogram for
    git-diff
  config: Introduce diff.algorithm variable
  diff: Introduce --diff-algorithm command line option

 Documentation/diff-config.txt          | 18 ++++++++++++++++++
 Documentation/diff-options.txt         | 21 +++++++++++++++++++++
 contrib/completion/git-completion.bash | 14 +++++++++++++-
 diff.c                                 | 34 ++++++++++++++++++++++++++++++++++
 diff.h                                 |  2 ++
 merge-recursive.c                      |  9 +++++++++
 6 files changed, 97 insertions(+), 1 deletion(-)

--

-- 
1.8.0.2

Michal Privoznik | 16 Jan 08:51 2013
Picon

[PATCH v3 3/3] diff: Introduce --diff-algorithm command line option

Since command line options have higher priority than config file
variables and taking previous commit into account, we need a way
how to specify myers algorithm on command line. However,
inventing `--myers` is not the right answer. We need far more
general option, and that is `--diff-algorithm`.

Signed-off-by: Michal Privoznik <mprivozn <at> redhat.com>
---
 Documentation/diff-options.txt         | 21 +++++++++++++++++++++
 contrib/completion/git-completion.bash | 11 +++++++++++
 diff.c                                 | 12 +++++++++++-
 diff.h                                 |  2 ++
 merge-recursive.c                      |  9 +++++++++
 5 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 39f2c50..6f11c34 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
 <at>  <at>  -55,6 +55,27  <at>  <at>  endif::git-format-patch[]
 --histogram::
 	Generate a diff using the "histogram diff" algorithm.

+--diff-algorithm={patience|minimal|histogram|myers}::
+	Choose a diff algorithm. The variants are as follows:
++
+--
+`default`, `myers`;;
+	The basic greedy diff algorithm. Currently, this happens to be
+	the default algorithm as well.
(Continue reading)

Michal Privoznik | 16 Jan 08:51 2013
Picon

[PATCH v3 1/3] git-completion.bash: Autocomplete --minimal and --histogram for git-diff

Even though --patience was already there, we missed --minimal and
--histogram for some reason.

Signed-off-by: Michal Privoznik <mprivozn <at> redhat.com>
---
 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a4c48e1..383518c 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
 <at>  <at>  -1031,7 +1031,7  <at>  <at>  __git_diff_common_options="--stat --numstat --shortstat --summary
 			--no-ext-diff
 			--no-prefix --src-prefix= --dst-prefix=
 			--inter-hunk-context=
-			--patience
+			--patience --histogram --minimal
 			--raw
 			--dirstat --dirstat= --dirstat-by-file
 			--dirstat-by-file= --cumulative
--

-- 
1.8.0.2

Michal Privoznik | 16 Jan 08:51 2013
Picon

[PATCH v3 2/3] config: Introduce diff.algorithm variable

Some users or projects prefer different algorithms over others, e.g.
patience over myers or similar. However, specifying appropriate
argument every time diff is to be used is impractical. Moreover,
creating an alias doesn't play nicely with other tools based on diff
(git-show for instance). Hence, a configuration variable which is able
to set specific algorithm is needed. For now, these four values are
accepted: 'myers' (which has the same effect as not setting the config
variable at all), 'minimal', 'patience' and 'histogram'.

Signed-off-by: Michal Privoznik <mprivozn <at> redhat.com>
---
 Documentation/diff-config.txt          | 18 ++++++++++++++++++
 contrib/completion/git-completion.bash |  1 +
 diff.c                                 | 24 ++++++++++++++++++++++++
 3 files changed, 43 insertions(+)

diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt
index 4314ad0..3a62ace 100644
--- a/Documentation/diff-config.txt
+++ b/Documentation/diff-config.txt
 <at>  <at>  -155,3 +155,21  <at>  <at>  diff.tool::
 	"kompare".  Any other value is treated as a custom diff tool,
 	and there must be a corresponding `difftool.<tool>.cmd`
 	option.
+
+diff.algorithm::
+	Choose a diff algorithm.  The variants are as follows:
++
+--
+`default`, `myers`;;
(Continue reading)

Junio C Hamano | 16 Jan 18:42 2013
Picon
Picon

Re: [PATCH v3 2/3] config: Introduce diff.algorithm variable

Will replace the one in 'pu' with this round.  Looking good.

Thanks.
Junio C Hamano | 16 Jan 22:59 2013
Picon
Picon

Re: [PATCH v3 2/3] config: Introduce diff.algorithm variable

Junio C Hamano <gitster <at> pobox.com> writes:

> Will replace the one in 'pu' with this round.  Looking good.
>
> Thanks.

By the way, wouldn't we want some tests to protect this feature from
future breakages?

Gmane