From: Bo Yang <struggleyb.nku@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, trast@student.ethz.ch
Subject: [PATCH 2/3 v4] Make diffcore_std only can run once before a diff_flush
Date: Thu, 6 May 2010 21:52:28 -0700 [thread overview]
Message-ID: <1273207949-18500-3-git-send-email-struggleyb.nku@gmail.com> (raw)
In-Reply-To: <1273207949-18500-2-git-send-email-struggleyb.nku@gmail.com>
When file renames/copies detection is turned on, the
second diffcore_std will degrade a 'C' pair to a 'R' pair.
And this may happen when we run 'git log --follow' with
hard copies finding. That is, the try_to_follow_renames()
will run diffcore_std to find the copies, and then
'git log' will issue another diffcore_std, which will reduce
'src->rename_used' and recognize this copy as a rename.
This is not what we want.
So, I think we really don't need to run diffcore_std more
than one time.
Signed-off-by: Bo Yang <struggleyb.nku@gmail.com>
---
diff.c | 8 ++++++++
diffcore.h | 2 ++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index 4a350e3..f0985bc 100644
--- a/diff.c
+++ b/diff.c
@@ -3737,6 +3737,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;
+
if (options->skip_stat_unmatch)
diffcore_skip_stat_unmatch(options);
if (options->break_opt != -1)
@@ -3756,6 +3762,8 @@ void diffcore_std(struct diff_options *options)
DIFF_OPT_SET(options, HAS_CHANGES);
else
DIFF_OPT_CLR(options, HAS_CHANGES);
+
+ diff_queued_diff.run = 1;
}
int diff_result_code(struct diff_options *opt, int status)
diff --git a/diffcore.h b/diffcore.h
index 5d05dea..491bea0 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -91,11 +91,13 @@ struct diff_queue_struct {
struct diff_filepair **queue;
int alloc;
int nr;
+ int run;
};
#define DIFF_QUEUE_CLEAR(q) \
do { \
(q)->queue = NULL; \
(q)->nr = (q)->alloc = 0; \
+ (q)->run = 0; \
} while(0);
extern struct diff_queue_struct diff_queued_diff;
--
1.6.0.4
next prev parent reply other threads:[~2010-05-07 4:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-07 4:52 [PATCH 0/3 v4] Make git log --follow find copies among unmodified files Bo Yang
2010-05-07 4:52 ` [PATCH 1/3 v4] Add a macro DIFF_QUEUE_CLEAR Bo Yang
2010-05-07 4:52 ` Bo Yang [this message]
2010-05-07 4:52 ` [PATCH 3/3 v4] Make git log --follow find copies among unmodified files Bo Yang
2010-08-02 12:47 ` [PATCH 1/3 v4] Add a macro DIFF_QUEUE_CLEAR Sven Verdoolaege
2010-08-02 15:26 ` Junio C Hamano
2010-08-02 15:40 ` 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=1273207949-18500-3-git-send-email-struggleyb.nku@gmail.com \
--to=struggleyb.nku@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).