From: Tay Ray Chuan Date: Tue, 13 Mar 2012 14:42:50 GMT Subject: Re: [PATCH] diff: Introduce diff.algorithm variable Message-ID: In-Reply-To: <06652d553040ad6b25608dc69d632f1ee38eaeca.1331300343.git.mprivozn@redhat.com> On Fri, Mar 9, 2012 at 9:48 PM, Michal Privoznik wrote: > Some users have preference over various diff algorithms. However, > now they are forced to use appropriate argument every time they > run git-diff and tools using it. This is impractical. Therefore > create new variable which can set preferred algorithm. Of course, > this can be overridden on command line via --diff-algorithm=*. > Accepted values are myers (default), histogram, minimal, patience. > > Signed-off-by: Michal Privoznik > --- > This is basically v2 for: > >   http://www.spinics.net/lists/git/msg176100.html > > As we agreed on list, I've switched from diff.patience to > diff.algorithm and created new argument --diff-algorithm. > > Please keep me CC'ed as I am not signed into the list. > >  Documentation/diff-config.txt          |   21 +++++++++++++++++++ >  Documentation/diff-options.txt         |   23 +++++++++++++++++++++ >  contrib/completion/git-completion.bash |   13 +++++++++++ >  diff.c                                 |   35 ++++++++++++++++++++++++++++++++ >  4 files changed, 92 insertions(+), 0 deletions(-) > > diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt > index 6aa1be0..1047e81 100644 > --- a/Documentation/diff-config.txt > +++ b/Documentation/diff-config.txt > @@ -1,3 +1,24 @@ > +diff.algorithm:: > +    Choose a diff algorithm.  The variants are as follows: > ++ > +-- > +histogram:: > +    This is the fastest algorithm. > + > +myers:: > +    The classical Myers diff algorithm. This is the default. > + > +minimal:: > +    Like 'myers', but spend extra time making sure that the diff > +    is the shortest possible for the set of changes performed. > + > +patience:: > +    The patience diff algorithm, which first matches unique lines > +    with each other.  This sometimes results in more readable (if > +    longer) patches than the other algorithms. > +-- > ++ > + Considering that --minimal isn't really an algorithm, could this be instead made to a "default options to always pass to diff" config? I imagine this would make the codepath involved in this patch much simpler (just reuse the argc/argv opt parsing machinery). Additionally, it would be useful for users who want to, say, set the context to 5 lines always. -- Cheers, Ray Chuan