All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org, sbeller@google.com
Subject: Re: [PATCH v2] diff: support anchoring line(s)
Date: Tue, 28 Nov 2017 10:38:48 +0900	[thread overview]
Message-ID: <xmqq1skj9o7r.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20171127194747.118254-1-jonathantanmy@google.com> (Jonathan Tan's message of "Mon, 27 Nov 2017 11:47:47 -0800")

Jonathan Tan <jonathantanmy@google.com> writes:

> -	else if (!strcmp(arg, "--patience"))
> +	else if (!strcmp(arg, "--patience")) {
> +		int i;
>  		options->xdl_opts = DIFF_WITH_ALG(options, PATIENCE_DIFF);
> -	else if (!strcmp(arg, "--histogram"))
> +		/*
> +		 * Both --patience and --anchored use PATIENCE_DIFF
> +		 * internally, so remove any anchors previously
> +		 * specified.
> +		 */
> +		for (i = 0; i < options->anchors_nr; i++)
> +			free(options->anchors[i]);
> +		options->anchors_nr = 0;

This makes sense, but "--diff-algorithm=patience" would want to do
the same, I suspect, so the loop would want to become a little
helper function "clear_patience_anchors(options)" or something like
that.

> diff --git a/t/t4064-diff-anchored.sh b/t/t4064-diff-anchored.sh
> new file mode 100755
> index 000000000..b3f510f04
> --- /dev/null
> +++ b/t/t4064-diff-anchored.sh
> @@ -0,0 +1,94 @@
> +#!/bin/sh
> +
> +test_description='anchored diff algorithm'
> +
> +. ./test-lib.sh
> +
> +test_expect_success '--anchored' '
> +	printf "a\nb\nc\n" >pre &&
> +	printf "c\na\nb\n" >post &&

This may be too little to matter, but I'd find

	printf "%s\n" a b c >pre

vastly easier to read.  Or perhaps just use

	test_write_lines a b c >pre


  reply	other threads:[~2017-11-28  1:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-21 22:17 [RFC PATCH] xdiff/xpatience: support anchoring a line Jonathan Tan
2017-11-21 23:28 ` Stefan Beller
2017-11-22  2:27 ` Junio C Hamano
2017-11-22 23:41 ` [PATCH] xdiff/xpatience: support anchoring line(s) Jonathan Tan
2017-11-23  0:15   ` Stefan Beller
2017-11-23  2:05   ` Junio C Hamano
2017-11-23  2:16     ` Junio C Hamano
2017-11-23  2:47       ` Junio C Hamano
2017-11-27 18:30         ` Jonathan Tan
2017-11-27 19:47   ` [PATCH v2] diff: " Jonathan Tan
2017-11-28  1:38     ` Junio C Hamano [this message]
2017-11-28 18:47       ` [PATCH v3] " Jonathan Tan
2017-11-30  0:36         ` Johannes Schindelin
2017-11-30 23:26           ` Jonathan Tan
2017-12-04 19:45             ` Stefan Beller

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=xmqq1skj9o7r.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.com \
    --cc=sbeller@google.com \
    /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.