git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Bo Yang <struggleyb.nku@gmail.com>
Cc: git@vger.kernel.org, trast@student.ethz.ch
Subject: Re: [PATCH 1/2 v3] Make diffcore_std only can run once before a diff_flush.
Date: Thu, 22 Apr 2010 13:41:12 -0700	[thread overview]
Message-ID: <7v1ve743vb.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1271945142-27015-2-git-send-email-struggleyb.nku@gmail.com> (Bo Yang's message of "Thu\, 22 Apr 2010 22\:05\:41 +0800")

Bo Yang <struggleyb.nku@gmail.com> writes:

> So, I think we really don't need to run diffcore_std more
> than one time.

It actually is stronger than that; we should never run it more than once,
and it would be a bug if we did so.  Which codepath tries to call *_std()
twice?

The standard calling sequence is:

 - start from an empty queue.

 - use diff_change() and diff_addremove() to populate the queue.

 - call diffcore_std(). if you need to use a non-standard chain of
   diffcore transformations, you _could_ call the diffcore_* routines that
   diffcore_std() calls, if you choose to, but as you found out, some of
   them are not idempotent operations, and shouldn't be called twice.

 - and finally call diffcore_flush().

> @@ -3745,6 +3742,12 @@ void diffcore_fix_diff_index(struct diff_options *options)
>  
>  void diffcore_std(struct diff_options *options)
>  {
> +	/* We never run this function more than one time, because the
> +	 * rename/copy detection logic can only run once.
> +	 */
> +	if (diff_queued_diff.run)
> +		return;

Shouldn't this be a BUG() instead?

The trivial rewrite to use this macro is a good idea, but it probably
should be a separate patch.

> +#define DIFF_QUEUE_CLEAR(q) \
> +	do { \
> +		(q)->queue = NULL; \
> +		(q)->nr = (q)->alloc = (q)->run = 0; \
> +	} while(0);

  reply	other threads:[~2010-04-22 20:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-22 14:05 [PATCH 0/2 v3] Make git log --follow find copies among unmodified files Bo Yang
2010-04-22 14:05 ` [PATCH 1/2 v3] Make diffcore_std only can run once before a diff_flush Bo Yang
2010-04-22 20:41   ` Junio C Hamano [this message]
2010-04-23  3:55     ` Bo Yang
2010-04-28  3:37       ` Bo Yang
2010-04-22 14:05 ` [PATCH 2/2 v3] Make git log --follow find copies among unmodified files Bo Yang

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=7v1ve743vb.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=struggleyb.nku@gmail.com \
    --cc=trast@student.ethz.ch \
    /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 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).