summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--diff-cache.c12
-rw-r--r--diff-files.c13
-rw-r--r--diff-stages.c15
-rw-r--r--diff-tree.c6
-rw-r--r--t/t4003-diff-rename-1.sh3
-rw-r--r--t/t4005-diff-rename-2.sh2
-rw-r--r--t/t4007-rename-3.sh2
-rw-r--r--t/t4009-diff-rename-4.sh2
8 files changed, 37 insertions, 18 deletions
diff --git a/diff-cache.c b/diff-cache.c
index 13baaa3..603a6b7 100644
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -5,6 +5,7 @@ static int cached_only = 0;
static int diff_output_format = DIFF_FORMAT_HUMAN;
static int match_nonexisting = 0;
static int detect_rename = 0;
+static int find_copies_harder = 0;
static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
@@ -75,7 +76,7 @@ static int show_modified(struct cache_entry *old,
oldmode = old->ce_mode;
if (mode == oldmode && !memcmp(sha1, old->sha1, 20) &&
- detect_rename < DIFF_DETECT_COPY)
+ !find_copies_harder)
return 0;
mode = ntohl(mode);
@@ -158,7 +159,7 @@ static void mark_merge_entries(void)
}
static char *diff_cache_usage =
-"git-diff-cache [-p] [-r] [-z] [-m] [-M] [-C] [-R] [-S<string>] [-O<orderfile>] [--cached] <tree-ish> [<path>...]";
+"git-diff-cache [-p] [-r] [-z] [-m] [--cached] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> [<path>...]";
int main(int argc, const char **argv)
{
@@ -213,6 +214,10 @@ int main(int argc, const char **argv)
usage(diff_cache_usage);
continue;
}
+ if (!strcmp(arg, "--find-copies-harder")) {
+ find_copies_harder = 1;
+ continue;
+ }
if (!strcmp(arg, "-z")) {
diff_output_format = DIFF_FORMAT_MACHINE;
continue;
@@ -248,6 +253,9 @@ int main(int argc, const char **argv)
usage(diff_cache_usage);
}
+ if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
+ usage(diff_cache_usage);
+
if (!tree_name || get_sha1(tree_name, sha1))
usage(diff_cache_usage);
diff --git a/diff-files.c b/diff-files.c
index b6d972e..4d60017 100644
--- a/diff-files.c
+++ b/diff-files.c
@@ -7,10 +7,11 @@
#include "diff.h"
static const char *diff_files_usage =
-"git-diff-files [-p] [-q] [-r] [-z] [-M] [-C] [-R] [-S<string>] [-O<orderfile>] [paths...]";
+"git-diff-files [-p] [-q] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] [<path>...]";
static int diff_output_format = DIFF_FORMAT_HUMAN;
static int detect_rename = 0;
+static int find_copies_harder = 0;
static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
@@ -81,11 +82,16 @@ int main(int argc, const char **argv)
usage(diff_files_usage);
detect_rename = DIFF_DETECT_COPY;
}
+ else if (!strcmp(argv[1], "--find-copies-harder"))
+ find_copies_harder = 1;
else
usage(diff_files_usage);
argv++; argc--;
}
+ if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
+ usage(diff_files_usage);
+
/* At this point, if argc == 1, then we are doing everything.
* Otherwise argv[1] .. argv[argc-1] have the explicit paths.
*/
@@ -122,12 +128,11 @@ int main(int argc, const char **argv)
continue;
}
changed = ce_match_stat(ce, &st);
- if (!changed && detect_rename < DIFF_DETECT_COPY)
+ if (!changed && !find_copies_harder)
continue;
-
oldmode = ntohl(ce->ce_mode);
show_modified(oldmode, DIFF_FILE_CANON_MODE(st.st_mode),
- ce->sha1, null_sha1,
+ ce->sha1, (changed ? null_sha1 : ce->sha1),
ce->name);
}
diffcore_std((1 < argc) ? argv + 1 : NULL,
diff --git a/diff-stages.c b/diff-stages.c
index 4b87c8e..f099814 100644
--- a/diff-stages.c
+++ b/diff-stages.c
@@ -7,6 +7,7 @@
static int diff_output_format = DIFF_FORMAT_HUMAN;
static int detect_rename = 0;
+static int find_copies_harder = 0;
static int diff_setup_opt = 0;
static int diff_score_opt = 0;
static const char *pickaxe = NULL;
@@ -16,7 +17,7 @@ static const char *orderfile = NULL;
static const char *diff_filter = NULL;
static char *diff_stages_usage =
-"git-diff-stages [-p] [-r] [-z] [-M] [-C] [-R] [-S<string>] [-O<orderfile>] <stage1> <stage2> [<path>...]";
+"git-diff-stages [-p] [-r] [-z] [-R] [-B] [-M] [-C] [--find-copies-harder] [-O<orderfile>] [-S<string>] [--pickaxe-all] <stage1> <stage2> [<path>...]";
static void diff_stages(int stage1, int stage2)
{
@@ -50,9 +51,10 @@ static void diff_stages(int stage1, int stage2)
diff_addremove('-', ntohl(one->ce_mode),
one->sha1, name, NULL);
else if (memcmp(one->sha1, two->sha1, 20) ||
- (one->ce_mode != two->ce_mode))
- diff_change(ntohl(one->ce_mode), ntohl(two->ce_mode),
- one->sha1, two->sha1, name, NULL);
+ (one->ce_mode != two->ce_mode) ||
+ find_copies_harder)
+ diff_change(ntohl(one->ce_mode), ntohl(two->ce_mode),
+ one->sha1, two->sha1, name, NULL);
}
}
@@ -81,6 +83,8 @@ int main(int ac, const char **av)
if ((diff_score_opt = diff_scoreopt_parse(arg)) == -1)
usage(diff_stages_usage);
}
+ else if (!strcmp(arg, "--find-copies-harder"))
+ find_copies_harder = 1;
else if (!strcmp(arg, "-z"))
diff_output_format = DIFF_FORMAT_MACHINE;
else if (!strcmp(arg, "-R"))
@@ -102,7 +106,8 @@ int main(int ac, const char **av)
sscanf(av[1], "%d", &stage1) != 1 ||
! (0 <= stage1 && stage1 <= 3) ||
sscanf(av[2], "%d", &stage2) != 1 ||
- ! (0 <= stage2 && stage2 <= 3))
+ ! (0 <= stage2 && stage2 <= 3) ||
+ find_copies_harder && detect_rename != DIFF_DETECT_COPY)
usage(diff_stages_usage);
av += 3; /* The rest from av[0] are for paths restriction. */
diff --git a/diff-tree.c b/diff-tree.c
index 2075715..7446e09 100644
--- a/diff-tree.c
+++ b/diff-tree.c
@@ -201,7 +201,7 @@ static int interesting(void *tree, unsigned long size, const char *base)
static void show_tree(const char *prefix, void *tree, unsigned long size, const char *base)
{
while (size) {
- if (find_copies_harder || interesting(tree, size, base))
+ if (interesting(tree, size, base))
show_file(prefix, tree, size, base);
update_tree_entry(&tree, &size);
}
@@ -269,7 +269,7 @@ static void call_diff_setup(void)
static int call_diff_flush(void)
{
- diffcore_std(find_copies_harder ? paths : 0,
+ diffcore_std(NULL,
detect_rename, diff_score_opt,
pickaxe, pickaxe_opts,
diff_break_opt,
@@ -401,7 +401,7 @@ static int diff_tree_stdin(char *line)
}
static char *diff_tree_usage =
-"git-diff-tree [-p] [-r] [-z] [--stdin] [-M] [-C] [-R] [-S<string>] [-O<orderfile>] [-m] [-s] [-v] [--pretty] [-t] <tree-ish> <tree-ish>";
+"git-diff-tree [-p] [-r] [-z] [--stdin] [-m] [-s] [-v] [--pretty] [-t] [-R] [-B] [-M] [-C] [--find-copies-header] [-O<orderfile>] [-S<string>] [--pickaxe-all] <tree-ish> <tree-ish>";
static enum cmit_fmt get_commit_format(const char *arg)
{
diff --git a/t/t4003-diff-rename-1.sh b/t/t4003-diff-rename-1.sh
index 63a3103..8e3091a 100644
--- a/t/t4003-diff-rename-1.sh
+++ b/t/t4003-diff-rename-1.sh
@@ -108,7 +108,8 @@ test_expect_success \
# the diff-core. Unchanged rezrov, although being fed to
# git-diff-cache as well, should not be mentioned.
-GIT_DIFF_OPTS=--unified=0 git-diff-cache -C -p $tree >current
+GIT_DIFF_OPTS=--unified=0 \
+ git-diff-cache -C --find-copies-harder -p $tree >current
cat >expected <<\EOF
diff --git a/COPYING b/COPYING.1
copy from COPYING
diff --git a/t/t4005-diff-rename-2.sh b/t/t4005-diff-rename-2.sh
index 1921299..cee06e4 100644
--- a/t/t4005-diff-rename-2.sh
+++ b/t/t4005-diff-rename-2.sh
@@ -136,7 +136,7 @@ test_expect_success \
'cat ../../COPYING >COPYING &&
git-update-cache --add --remove COPYING COPYING.1'
-git-diff-cache -C $tree >current
+git-diff-cache -C --find-copies-harder $tree >current
cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234 COPYING COPYING.1
EOF
diff --git a/t/t4007-rename-3.sh b/t/t4007-rename-3.sh
index a55d6b6..ab83ea3 100644
--- a/t/t4007-rename-3.sh
+++ b/t/t4007-rename-3.sh
@@ -26,7 +26,7 @@ test_expect_success \
# path1 both have COPYING and the latter is a copy of path0/COPYING.
# Comparing the full tree with cache should tell us so.
-git-diff-cache -C $tree >current
+git-diff-cache -C --find-copies-harder $tree >current
cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 C100 path0/COPYING path1/COPYING
diff --git a/t/t4009-diff-rename-4.sh b/t/t4009-diff-rename-4.sh
index 318915f..6229a5b 100644
--- a/t/t4009-diff-rename-4.sh
+++ b/t/t4009-diff-rename-4.sh
@@ -143,7 +143,7 @@ test_expect_success \
'cat ../../COPYING >COPYING &&
git-update-cache --add --remove COPYING COPYING.1'
-git-diff-cache -z -C $tree >current
+git-diff-cache -z -C --find-copies-harder $tree >current
cat >expected <<\EOF
:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0603b3238a076dc6c8022aedc6648fa523a17178 C1234
COPYING