Detection of directory renames
PATCH v9 1/1 Detection of directory renames
This series requires:
- v6 of "generalizing sorted-array handling" series
- Jonathan Nieder's "compat: add memrchr()" patch, aka. mid:<20101015051750.GA21830@burratino>
Changes since v8:
* use of the new sorted-array.h, which gives the main patch a diet
* split of debug func into its own patch
Next iteration will be merging the bulk-rm detection into this series. Interested eyes can get a preview at t/* branches on
http://repo.or.cz/w/git/ydirson.git
PATCH 1/6 Introduce debug_bulkmove() in diffcore-rename.
This is an optional debug useful while developping new builk-* features.
--- diffcore-rename.c | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
diffcore-rename.c +16 -0
@@ -7,6 +7,22 @@#include "hash.h" #include "sorted-array.h" +#define DEBUG_BULKMOVE 0 + +#if DEBUG_BULKMOVE +#define debug_bulkmove (args) __debug_bulkmove args +void __debug_bulkmove (const char *fmt, ...) +{ +va_list ap; +va_start (ap, fmt); +fprintf (stderr,"[DBG] " ); +vfprintf (stderr, fmt, ap); +va_end (ap); +} +#else +#define debug_bulkmove(args) do { /*nothing */ } while (0) +#endif +/* Table of rename/copy destinations */ struct diff_rename_dst {
Signature · 1 line
1.7.2.3
PATCH 2/6 Introduce bulk-move detection in diffcore.
In reply to Yann DirsonThis feature tries to group together files moving from and to identical directories - a common case being directory renames.
This only adds the detection logic. The output of raw diff is displayed as "Rnnn a/ b/", and unified diff does not display them at all. Output formats will be refined later in the series.
It is implemented as a new pass in diffcore-rename, occuring after the file renames get detected, grouping those renames looking like a move of a full directory into some other place. It is activated by the new --detect-bulk-moves diffcore flag.
Possible optimisations to this code include:
* avoid use of i_am_not_single by using a separate list
* use a more informative prefixcmp to avoid strcmp calls eg. in discard_if_outside()
* optimize for bulk insertions (avoid useless successive memmove's)
Other future developements to be made on top of this include:
* detect bulk removals (well, that one is rather a subset than a layer above), and possibly bulk additions
* detect bulk copies
* detect inexact bulk-moves/copies (where some files were not moved, or were moved to a different place) - problem of computing a similarity score
* display as such the special case of directory move/rename
* application of such new diffs: issue a conflict, or just a warning ?
* teach git-svn (and others ?) to make use of that flag
* handle new conflict type "bulk-move/add"
* detect "directory splits" as well
* use inexact dir renames to bump score of below-threshold renames from/to same locations
* support other types of bluk-grouping, like prefixes (see eg. kernel 5d1e859c), and maybe config-specified patterns
* add yours here
This patch has been improved by the following contributions:
- Jonathan Nieder: better implementation of copy_dirname()
- Jonathan Nieder: portable implementation of memrchr() in another patch
- Junio C Hamano: split individual renames hiding under control of another flag
- Junio C Hamano: coding style issues
- Junio C Hamano: better examples
- Ævar Arnfjörð Bjarmason: Don't use C99 comments.
- Jonathan Nieder: just too many other helpful suggestions to list them all
Thanks-to: Jonathan Nieder <[email protected]>
Thanks-to: Junio C Hamano <[email protected]>
Thanks-to: Ævar Arnfjörð Bjarmason <[email protected]>
--- Documentation/diff-options.txt | 4 + Documentation/gitdiffcore.txt | 12 ++ diff-lib.c | 6 +- diff.c | 5 + diff.h | 3 + diffcore-rename.c | 322 ++++++++++++++++++++++++++++++++++++++-- diffcore.h | 1 + tree-diff.c | 4 +- 8 files changed, 340 insertions(+), 17 deletions(-)
Documentation/diff-options.txt +4 -0
@@ -245,6 +245,10 @@ endif::git-log[] delete/add pair to be a rename if more than 90% of the file hasn't changed. +--detect-bulk-moves:: + Detect bulk move of all files of a directory into a + different one. + -C[<n>]:: --detect-copies[=<n>]:: Detect copies as well as renames. See also `--find-copies-harder`.
Documentation/gitdiffcore.txt +12 -0
@@ -175,6 +175,18 @@ the expense of making it slower. Without `\--find-copies-harder`, 'git diff-{asterisk}' commands can detect copies only if the file that was copied happened to have been modified in the same changeset. +Bulk move of all files of a directory into a different one can get +detected using the `\--detect-bulk-moves` option. This adds an +additional pass on top of the results of per-file rename detection. +They are reported with NULL SHA1 id, in addition to the file renames: + +------------------------------------------------ +:040000 040000 0000000... 0000000... R100 foo/ bar/ +:100644 100644 0123456... 1234567... R090 foo/file0 bar/file3 +:100644 100644 2345678... 2345678... R100 foo/file1 bar/file1 +:100644 100644 3456789... 3456789... R100 foo/file2 bar/file2 +------------------------------------------------ + diffcore-merge-broken: For Putting "Complete Rewrites" Back Together --------------------------------------------------------------------
diff-lib.c +4 -2
@@ -208,7 +208,8 @@ int run_diff_files(struct rev_info *revs, unsigned int option) ce_option, &dirty_submodule);if (!changed && !dirty_submodule) {ce_mark_uptodate (ce); -if (!DIFF_OPT_TST (&revs->diffopt,FIND_COPIES_HARDER )) +if (!DIFF_OPT_TST (&revs->diffopt,FIND_COPIES_HARDER ) && + !DIFF_OPT_TST (&revs->diffopt,DETECT_BULK_MOVES ))continue ; } oldmode = ce->ce_mode;
@@ -338,7 +339,8 @@ static int show_modified(struct rev_info *revs, oldmode = old->ce_mode;if (mode == oldmode && !hashcmp (sha1, old->sha1) && !dirty_submodule && - !DIFF_OPT_TST (&revs->diffopt,FIND_COPIES_HARDER )) + !DIFF_OPT_TST (&revs->diffopt,FIND_COPIES_HARDER ) && + !DIFF_OPT_TST (&revs->diffopt,DETECT_BULK_MOVES ))return 0 ; diff_change(&revs->diffopt, oldmode, mode,
diff.c +5 -0
@@ -3200,6 +3200,11 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)DIFF_OPT_SET (options,REVERSE_DIFF ); else if (!strcmp(arg, "--find-copies-harder"))DIFF_OPT_SET (options,FIND_COPIES_HARDER ); + else if (!strcmp(arg, "--detect-bulk-moves")) { +DIFF_OPT_SET (options,DETECT_BULK_MOVES ); +if (!options->detect_rename) + options->detect_rename =DIFF_DETECT_RENAME ; + } else if (!strcmp(arg, "--follow"))DIFF_OPT_SET (options,FOLLOW_RENAMES ); else if (!strcmp(arg, "--color"))
diff.h +3 -0
@@ -78,6 +78,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)#define DIFF_OPT_IGNORE_UNTRACKED_IN_SUBMODULES (1 << 25)#define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)#define DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG (1 << 27) +#define DIFF_OPT_DETECT_BULK_MOVES (1 << 28)#define DIFF_OPT_TST (opts, flag) ((opts)->flags & DIFF_OPT_##flag)#define DIFF_OPT_SET (opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
@@ -265,6 +266,8 @@ extern void diffcore_fix_diff_index(struct diff_options *);" -C detect copies.\n" \" --find-copies-harder\n" \" try unchanged files as candidate for copy detection.\n" \ +" --detect-bulk-moves\n" \ +" detect moves of all files of a single directory.\n" \" -l<n> limit rename attempts up to <n> paths.\n" \" -O<file> reorder diffs according to the <file>.\n" \" -S<string> find filepair whose only one side contains the string.\n" \
diffcore-rename.c +308 -14
383 lines not on this page · raw message
diffcore.h +1 -0
@@ -69,6 +69,7 @@ struct diff_filepair { unsigned broken_pair : 1; unsigned renamed_pair : 1; unsigned is_unmerged : 1; + unsigned is_bulkmove : 1; };#define DIFF_PAIR_UNMERGED (p) ((p)->is_unmerged)
tree-diff.c +3 -1
@@ -49,7 +49,9 @@ static int compare_tree_entry(struct tree_desc *t1, struct tree_desc *t2, constshow_entry (opt,"+" , t2, base, baselen);return 1 ; } -if (!DIFF_OPT_TST (opt,FIND_COPIES_HARDER ) && !hashcmp (sha1, sha2) && mode1 == mode2) +if (!DIFF_OPT_TST (opt,FIND_COPIES_HARDER ) && + !DIFF_OPT_TST (opt,DETECT_BULK_MOVES ) && + !hashcmp (sha1, sha2) && mode1 == mode2)return 0 ;/*
Signature · 1 line
1.7.2.3
PATCH 3/6 Raw diff output format for bulk moves.
In reply to Yann DirsonTo distinguish the general bulk-move case (where the destination directory was pre-existing) from the directory-rename case (where it was not), the output of raw diff is displayed as "Rnnn a/* b/". Those cannot be confused with renames of files named "whatever/*" with a literal star character, from the full-zero SHA1's.
--- Documentation/gitdiffcore.txt | 2 +- diff.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-)
Documentation/gitdiffcore.txt +1 -1
@@ -181,7 +181,7 @@ additional pass on top of the results of per-file rename detection. They are reported with NULL SHA1 id, in addition to the file renames: ------------------------------------------------ -:040000 040000 0000000... 0000000... R100 foo/ bar/ +:040000 040000 0000000... 0000000... R100 foo/* bar/ :100644 100644 0123456... 1234567... R090 foo/file0 bar/file3 :100644 100644 2345678... 2345678... R100 foo/file1 bar/file1 :100644 100644 3456789... 3456789... R100 foo/file2 bar/file2
diff.c +8 -1
@@ -3499,7 +3499,14 @@ static void diff_flush_raw(struct diff_filepair *p, struct diff_options *opt)if (p->status ==DIFF_STATUS_COPIED || p->status ==DIFF_STATUS_RENAMED ) {const char *name_a, *name_b; - name_a = p->one->path; +if (p->is_bulkmove) { +/* append "*" to the first dirname */ +char buf[PATH_MAX ]; +char *next =memccpy (buf, p->one->path,'\0' ,PATH_MAX ); + next[-1 ] ='*' ; *next ='\0' ; + name_a = buf; + }else + name_a = p->one->path; name_b = p->two->path;strip_prefix (opt->prefix_length, &name_a, &name_b);write_name_quoted (name_a, opt->file, inter_name_termination);
Signature · 1 line
1.7.2.3
PATCH 4/6 Add testcases for the --detect-bulk-moves diffcore flag.
In reply to Yann DirsonThis notably includes a couple of tests for cases known not to be working correctly yet.
This patch has been improved by the following contributions:
- Jonathan Nieder: reworked style of test script
- Jonathan Nieder: use "git commit" in test instead of only plumbing, and use test_tick
- Sverre Rabbelier: anonymize hashes
Thanks-to: Jonathan Nieder <[email protected]>
Thanks-to: Sverre Rabbelier <[email protected]>
--- t/t4046-diff-bulk-move.sh | 296 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 296 insertions(+), 0 deletions(-) create mode 100755 t/t4046-diff-bulk-move.sh
t/t4046-diff-bulk-move.sh new file +296 -0
@@ -0,0 +1,296 @@ +#!/bin/sh +# +# Copyright (c) 2008,2010 Yann Dirson +# Copyright (c) 2005 Junio C Hamano +# + +# TODO for dir renames: +# * two dirs or more moving all their files to a single dir +# * simultaneous bulkmove and rename + +test_description='Test rename factorization in diff engine. + +' +. ./test-lib.sh +. "$TEST_DIRECTORY"/diff-lib.sh + +test_expect_success 'setup' ' + git commit --allow-empty -m "original empty commit" + + mkdir a && + printf "Line %s\n" 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 >a/path0 && + sed <a/path0 >a/path1 s/Line/Record/ && + sed <a/path0 >a/path2 s/Line/Stuff/ && + sed <a/path0 >a/path3 s/Line/Blurb/ && + + git update-index --add a/path* && + test_tick && + git commit -m "original set of files" && + + : rename the directory && + git mv a b +' +test_expect_success 'diff-index --detect-bulk-moves after directory move.' ' + cat >expected <<-EOF && + :040000 040000 X X R# a/* b/ + :100644 100644 X X R# a/path0 b/path0 + :100644 100644 X X R# a/path1 b/path1 + :100644 100644 X X R# a/path2 b/path2 + :100644 100644 X X R# a/path3 b/path3 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup non-100% rename' ' + echo "Line 16" >>b/path0 && + git mv b/path2 b/2path && + git rm -f b/path3 && + echo anything >b/path100 && + git add b/path100 +' +test_expect_success 'diff-index --detect-bulk-moves after content changes.' ' + cat >expected <<-EOF && + :040000 040000 X X R# a/* b/ + :100644 000000 X X D# a/path3 + :100644 100644 X X R# a/path2 b/2path + :100644 100644 X X R# a/path0 b/path0 + :100644 100644 X X R# a/path1 b/path1 + :000000 100644 X X A# b/path100 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup bulk move that is not directory move' ' + git reset -q --hard && + + mkdir c && + ( + for i in 0 1 2; do + cp a/path$i c/apath$i || exit + done + ) && + git update-index --add c/apath* && + test_tick && + git commit -m "first set of changes" && + + git mv c/* a/ +' +test_expect_success 'diff-index --detect-bulk-moves without full-dir rename.' ' + cat >expected <<-EOF && + :040000 040000 X X R# c/* a/ + :100644 100644 X X R# c/apath0 a/apath0 + :100644 100644 X X R# c/apath1 a/apath1 + :100644 100644 X X R# c/apath2 a/apath2 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup bulk move with new file in source dir' ' + echo > c/anotherpath "How much wood?" && + git update-index --add c/another* +' +test_expect_success 'diff-index --detect-bulk-moves with new file in source dir.' ' + cat >expected <<-EOF && + :040000 040000 X X R# c/* a/ + :100644 100644 X X R# c/apath0 a/apath0 + :100644 100644 X X R# c/apath1 a/apath1 + :100644 100644 X X R# c/apath2 a/apath2 + :000000 100644 X X A# c/anotherpath + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup bulk move with interfering copy' ' + rm c/anotherpath && + git update-index --remove c/anotherpath && + mkdir b && + cp a/apath0 b/apath9 && + echo >> a/apath0 "more" && + git update-index --add a/apath0 b/apath9 +' +# scores select the "wrong" one as "moved" (only a suboptimal detection) +test_expect_failure 'diff-index --detect-bulk-moves with interfering copy.' ' + cat >expected <<-EOF && + :040000 040000 X X R# c/* a/ + :100644 100644 X X R# c/apath0 a/apath0 + :100644 100644 X X R# c/apath1 a/apath1 + :100644 100644 X X R# c/apath2 a/apath2 + :100644 100644 X X C# c/apath0 b/apath9 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup bulk move to toplevel' ' + git reset -q --hard && + git mv c/* . +' +test_expect_success 'diff-index --detect-bulk-moves bulk move to toplevel.' ' + cat >expected <<-EOF && + :040000 040000 X X R# c/* ./ + :100644 100644 X X R# c/apath0 apath0 + :100644 100644 X X R# c/apath1 apath1 + :100644 100644 X X R# c/apath2 apath2 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup move including a subdir, with some content changes' ' + git reset -q --hard && + mv c a/ && + git update-index --add --remove a/c/* c/apath0 c/apath1 c/apath2 && + test_tick && + git commit -m "move as subdir" && + + git mv a b && + echo foo >>b/c/apath0 && + git update-index --add b/c/apath* +' +test_expect_success 'diff-index --detect-bulk-moves on a move including a subdir.' ' + cat >expected <<-EOF && + :040000 040000 X X R# a/* b/ + :040000 040000 X X R# a/c/* b/c/ + :100644 100644 X X R# a/c/apath0 b/c/apath0 + :100644 100644 X X R# a/c/apath1 b/c/apath1 + :100644 100644 X X R# a/c/apath2 b/c/apath2 + :100644 100644 X X R# a/path0 b/path0 + :100644 100644 X X R# a/path1 b/path1 + :100644 100644 X X R# a/path2 b/path2 + :100644 100644 X X R# a/path3 b/path3 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup move of only a subdir' ' + git reset -q --hard && + : rename a subdirectory of a/. && + git mv a/c a/d +' +test_expect_success 'moving a subdir only' ' + cat >expected <<-EOF && + :040000 040000 X X R# a/c/* a/d/ + :100644 100644 X X R# a/c/apath0 a/d/apath0 + :100644 100644 X X R# a/c/apath1 a/d/apath1 + :100644 100644 X X R# a/c/apath2 a/d/apath2 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup move without a subdir' ' + git reset -q --hard && + mkdir b && + : rename files in the directory but not subdir. && + git mv a/path* b/ +' +test_expect_success 'moving files but not subdirs is not mistaken for dir move' ' + cat >expected <<-EOF && + :100644 100644 X X R# a/path0 b/path0 + :100644 100644 X X R# a/path1 b/path1 + :100644 100644 X X R# a/path2 b/path2 + :100644 100644 X X R# a/path3 b/path3 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup move of files and subdirs to different places' ' + git reset -q --hard && + git mv a/c b && + git mv a d +' +test_expect_success 'moving subdirs into one dir and files into another is not mistaken for dir move' ' + cat >expected <<-EOF && + :040000 040000 X X R# a/c/* b/ + :100644 100644 X X R# a/c/apath0 b/apath0 + :100644 100644 X X R# a/c/apath1 b/apath1 + :100644 100644 X X R# a/c/apath2 b/apath2 + :100644 100644 X X R# a/path0 d/path0 + :100644 100644 X X R# a/path1 d/path1 + :100644 100644 X X R# a/path2 d/path2 + :100644 100644 X X R# a/path3 d/path3 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +# the same with different ordering +test_expect_success 'setup move of files and subdirs to different places' ' + git mv d 0 +' +test_expect_success 'moving subdirs into one dir and files into another is not mistaken for dir move' ' + cat >expected <<-EOF && + :040000 040000 X X R# a/c/* b/ + :100644 100644 X X R# a/path0 0/path0 + :100644 100644 X X R# a/path1 0/path1 + :100644 100644 X X R# a/path2 0/path2 + :100644 100644 X X R# a/path3 0/path3 + :100644 100644 X X R# a/c/apath0 b/apath0 + :100644 100644 X X R# a/c/apath1 b/apath1 + :100644 100644 X X R# a/c/apath2 b/apath2 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_expect_success 'setup move of dir with only subdirs' ' + git reset -q --hard && + mkdir a/b && + mv a/path* a/b/ && + git update-index --add --remove a/path0 a/path1 a/path2 a/path3 a/b/path* && + test_tick && + git commit -m "move all toplevel files down one level" && + + git mv a z +' +# TODO: only a suboptimal non-detection +test_expect_failure 'moving a dir with no direct children files' ' + cat >expected <<-EOF && + :040000 040000 X X R# a/* z/ + :040000 040000 X X R# a/b/* z/b/ + :040000 040000 X X R# a/c/* z/c/ + :100644 100644 X X R# a/b/path0 z/b/path0 + :100644 100644 X X R# a/b/path1 z/b/path1 + :100644 100644 X X R# a/b/path2 z/b/path2 + :100644 100644 X X R# a/b/path3 z/b/path3 + :100644 100644 X X R# a/c/apath0 z/c/apath0 + :100644 100644 X X R# a/c/apath1 z/c/apath1 + :100644 100644 X X R# a/c/apath2 z/c/apath2 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' +# now test moving all files from toplevel into subdir (does not hides file moves) (needs consensus on syntax) +# Note: this is a special case of move of a dir into one of its own subdirs, which in +# turn is a variant of new files/dirs being added into a dir after all its contents +# are moved away + +test_expect_success 'setup move from toplevel to subdir' ' + git reset -q --hard HEAD~3 && + mv a/* . && + git update-index --add --remove a/path0 a/path1 a/path2 a/path3 path* && + test_tick && + git commit -m "move all files to toplevel" && + + mkdir z && + git mv path* z/ +' +test_expect_success '--detect-bulk-moves everything from toplevel.' ' + cat >expected <<-EOF && + :040000 040000 X X R# ./* z/ + :100644 100644 X X R# path0 z/path0 + :100644 100644 X X R# path1 z/path1 + :100644 100644 X X R# path2 z/path2 + :100644 100644 X X R# path3 z/path3 + EOF + git diff-index --detect-bulk-moves HEAD >current && + compare_diff_raw expected current +' + +test_done
Signature · 1 line
1.7.2.3
PATCH 5/6 Unified diff output format for bulk moves.
In reply to Yann DirsonThe output produced is as shown below.
diff --git-detect-bulk-moves mips/nxp/pnx833x/common/ mips/pnx833x/common/ bulk move with similarity index 100%
bulk move from mips/nxp/pnx833x/common/
bulk move to mips/pnx833x/common/
--- Documentation/diff-generate-patch.txt | 19 +++++++++++++ diff.c | 48 +++++++++++++++++++++++++------- 2 files changed, 56 insertions(+), 11 deletions(-)
Documentation/diff-generate-patch.txt +19 -0
@@ -71,6 +71,25 @@ separate lines indicate the old and the new mode. rename to a +bulk move entries +----------------- + +When a bulk move is detected, a special block is output in addition to +the renames that constitute the bulk move, looking like this: + + diff --git-detect-bulk-moves a/dir1/ b/dir2/ + +It is essentially similar to the standard diff header, with a special +syntax showing we are describing a difference between two directories, +and not a change to be applied as-is to a file. + +It is followed by three specific extended header lines: + + bulk move with similarity index <number> + bulk move from <dir1>/ + bulk move to <dir2>/ + + combined diff format --------------------
diff.c +37 -11
74 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 6/6 Allow hiding renames of individual files involved in a directory rename.
In reply to Yann DirsonOnce has identified groups of bulk-moved files, and then
the --hide-bulk-move-details flag hides those of the individual renames which carry no other information (further name change, or content changes).
This makes it much easier to a human reader to spot content changes in a commit that also moves a whole subtree.
--- Documentation/diff-options.txt | 5 +++ diff.c | 7 ++++ diff.h | 3 ++ diffcore-rename.c | 68 ++++++++++++++++++++++++++++++++++++++-- diffcore.h | 1 + 5 files changed, 81 insertions(+), 3 deletions(-)
Documentation/diff-options.txt +5 -0
@@ -249,6 +249,11 @@ endif::git-log[] Detect bulk move of all files of a directory into a different one. +--hide-bulk-move-details:: + Hide the individual files moves that make up a bulk move, + without hinding other changes to the involved files (contents + change, name change relative to the bulk move's destination). + -C[<n>]:: --detect-copies[=<n>]:: Detect copies as well as renames. See also `--find-copies-harder`.
diff.c +7 -0
@@ -3230,6 +3230,13 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)if (!options->detect_rename) options->detect_rename =DIFF_DETECT_RENAME ; } +else if (!strcmp (arg,"--hide-bulk-move-details" )) { +DIFF_OPT_SET (options,HIDE_DIR_RENAME_DETAILS ); +if (!DIFF_OPT_TST (options,DETECT_BULK_MOVES )) +DIFF_OPT_SET (options,DETECT_BULK_MOVES ); +if (!options->detect_rename) + options->detect_rename =DIFF_DETECT_RENAME ; + }else if (!strcmp (arg,"--follow" ))DIFF_OPT_SET (options,FOLLOW_RENAMES );else if (!strcmp (arg,"--color" ))
diff.h +3 -0
@@ -79,6 +79,7 @@ typedef struct strbuf *(*diff_prefix_fn_t)(struct diff_options *opt, void *data)#define DIFF_OPT_IGNORE_DIRTY_SUBMODULES (1 << 26)#define DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG (1 << 27)#define DIFF_OPT_DETECT_BULK_MOVES (1 << 28) +#define DIFF_OPT_HIDE_DIR_RENAME_DETAILS (1 << 29)#define DIFF_OPT_TST (opts, flag) ((opts)->flags & DIFF_OPT_##flag)#define DIFF_OPT_SET (opts, flag) ((opts)->flags |= DIFF_OPT_##flag)
@@ -268,6 +269,8 @@ extern void diffcore_fix_diff_index(struct diff_options *);" try unchanged files as candidate for copy detection.\n" \" --detect-bulk-moves\n" \" detect moves of all files of a single directory.\n" \ +" --hide-bulk-move-details\n" \ +" hide individual files moves in a bulk move.\n" \" -l<n> limit rename attempts up to <n> paths.\n" \" -O<file> reorder diffs according to the <file>.\n" \" -S<string> find filepair whose only one side contains the string.\n" \
diffcore-rename.c +65 -3
96 lines not on this page · raw message
diffcore.h +1 -0
@@ -69,6 +69,7 @@ struct diff_filepair { unsigned broken_pair : 1; unsigned renamed_pair : 1; unsigned is_unmerged : 1; + unsigned uninteresting_rename : 1; unsigned is_bulkmove : 1; };#define DIFF_PAIR_UNMERGED (p) ((p)->is_unmerged)
Signature · 1 line
1.7.2.3