aboutsummaryrefslogtreecommitdiff
path: root/diff-files.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-05-19 03:32:35 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-19 08:59:40 -0700
commit5c97558c9a813a0a775c438a79cfc438def00c22 (patch)
tree59b9eaa38cd2ec6f846ed2f2b6767055022a227a /diff-files.c
parenta310d4349467d78266f38d29e500c77b96ee5bef (diff)
downloadgit-5c97558c9a813a0a775c438a79cfc438def00c22.tar.gz
git-5c97558c9a813a0a775c438a79cfc438def00c22.tar.xz
[PATCH] Detect renames in diff family.
This rips out the rename detection engine from diff-helper and moves it to the diff core, and updates the internal calling convention used by diff-tree family into the diff core. In order to give the same option name to diff-tree family as well as to diff-helper, I've changed the earlier diff-helper '-r' option to '-M' (stands for Move; sorry but the natural abbreviation 'r' for 'rename' is already taken for 'recursive'). Although I did a fair amount of test with the git-diff-tree with existing rename commits in the core GIT repository, this should still be considered beta (preview) release. This patch depends on the diff-delta infrastructure just committed. This implements almost everything I wanted to see in this series of patch, except a few minor cleanups in the calling convention into diff core, but that will be a separate cleanup patch. Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'diff-files.c')
-rw-r--r--diff-files.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/diff-files.c b/diff-files.c
index d556b9688..7ffe66361 100644
--- a/diff-files.c
+++ b/diff-files.c
@@ -7,10 +7,11 @@
#include "diff.h"
static const char *diff_files_usage =
-"diff-files [-p] [-q] [-r] [-z] [paths...]";
+"diff-files [-p] [-q] [-r] [-z] [-M] [paths...]";
static int generate_patch = 0;
static int line_termination = '\n';
+static int detect_rename = 0;
static int silent = 0;
static int matches_pathspec(struct cache_entry *ce, char **spec, int cnt)
@@ -79,6 +80,9 @@ int main(int argc, char **argv)
; /* no-op */
else if (!strcmp(argv[1], "-z"))
line_termination = 0;
+ else if (!strcmp(argv[1], "-M")) {
+ detect_rename = generate_patch = 1;
+ }
else
usage(diff_files_usage);
argv++; argc--;
@@ -92,6 +96,9 @@ int main(int argc, char **argv)
exit(1);
}
+ if (generate_patch)
+ diff_setup(detect_rename, 0, 0, 0, 0);
+
for (i = 0; i < entries; i++) {
struct stat st;
unsigned int oldmode, mode;
@@ -132,5 +139,7 @@ int main(int argc, char **argv)
show_modified(oldmode, mode, ce->sha1, null_sha1,
ce->name);
}
+ if (generate_patch)
+ diff_flush();
return 0;
}