Make diffcore_std only can run once before a diff_flush
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Bo Yang committed
May 6, 2010 at 21:52 UTC
1da6175d438a9849db07a68326ee05f291510074
2 files changed
+10
diff.c
+8
@@ -3737,6 +3737,12 @@ void diffcore_fix_diff_index(struct diff_options *options)
3737
3738
void diffcore_std(struct diff_options *options)
3739
{
3740
+ /* We never run this function more than one time, because the
3741
+ * rename/copy detection logic can only run once.
3742
+ */
3743
+ if (diff_queued_diff.run)
3744
+ return;
3745
+
3746
if (options->skip_stat_unmatch)
3747
diffcore_skip_stat_unmatch(options);
3748
if (options->break_opt != -1)
@@ -3756,6 +3762,8 @@ void diffcore_std(struct diff_options *options)
3762
DIFF_OPT_SET(options, HAS_CHANGES);
3763
else
3764
DIFF_OPT_CLR(options, HAS_CHANGES);
3765
+
3766
+ diff_queued_diff.run = 1;
3767
}
3768
3769
int diff_result_code(struct diff_options *opt, int status)
diffcore.h
+2
@@ -91,11 +91,13 @@ struct diff_queue_struct {
91
struct diff_filepair **queue;
92
int alloc;
93
int nr;
94
+ int run;
95
};
96
#define DIFF_QUEUE_CLEAR(q) \
97
do { \
98
(q)->queue = NULL; \
99
(q)->nr = (q)->alloc = 0; \
100
+ (q)->run = 0; \
101
} while(0);
102
103
extern struct diff_queue_struct diff_queued_diff;