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;
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);
}
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)
{
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;
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);
#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;
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.
*/
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,
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;
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)
{
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);
}
}
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"))
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. */
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);
}
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,
}
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)
{
# 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
'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
# 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
'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