diff --follow: do call diffcore_std() as necessary · wolfpython/git@44c48a9 · GitHub
Skip to content

Commit 44c48a9

Browse files
committed
diff --follow: do call diffcore_std() as necessary
Usually, diff frontends populate the output queue with filepairs without any rename information and call diffcore_std() to sort the renames out. When --follow is in effect, however, diff-tree family of frontend has a hack that looks like this: diff-tree frontend -> diff_tree_sha1() . populate diff_queued_diff . if --follow is in effect and there is only one change that creates the target path, then -> try_to_follow_renames() -> diff_tree_sha1() with no pathspec but with -C -> diffcore_std() to find renames . if rename is found, tweak diff_queued_diff and put a single filepair that records the found rename there -> diffcore_std() . tweak elements on diff_queued_diff by - rename detection - path ordering - pickaxe filtering We need to skip parts of the second call to diffcore_std() that is related to rename detection, and do so only when try_to_follow_renames() did find a rename. Earlier 1da6175 (Make diffcore_std only can run once before a diff_flush, 2010-05-06) tried to deal with this issue incorrectly; it unconditionally disabled any second call to diffcore_std(). This hopefully fixes the breakage. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 39f75d2 commit 44c48a9

4 files changed

Lines changed: 27 additions & 16 deletions

File tree

diff.c

Lines changed: 13 additions & 14 deletions

diff.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ struct diff_options {
126126
/* this is set by diffcore for DIFF_FORMAT_PATCH */
127127
int found_changes;
128128

129+
/* to support internal diff recursion by --follow hack*/
130+
int found_follow;
131+
129132
FILE *file;
130133
int close_file;
131134

diffcore.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,11 @@ struct diff_queue_struct {
9191
struct diff_filepair **queue;
9292
int alloc;
9393
int nr;
94-
int run;
9594
};
9695
#define DIFF_QUEUE_CLEAR(q) \
9796
do { \
9897
(q)->queue = NULL; \
9998
(q)->nr = (q)->alloc = 0; \
100-
(q)->run = 0; \
10199
} while (0)
102100

103101
extern struct diff_queue_struct diff_queued_diff;

tree-diff.c

Lines changed: 11 additions & 0 deletions

0 commit comments

Comments
 (0)