summaryrefslogtreecommitdiff
path: root/diff-cache.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-cache.c
parenta310d4349467d78266f38d29e500c77b96ee5bef (diff)
downloadgit-5c97558c9a813a0a775c438a79cfc438def00c22.tar.gz
[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-cache.c')
-rw-r--r--diff-cache.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/diff-cache.c b/diff-cache.c
index 4cfbcdb9ed..2bdea9cc3a 100644
--- a/diff-cache.c
+++ b/diff-cache.c
@@ -5,6 +5,7 @@ static int cached_only = 0;
static int generate_patch = 0;
static int match_nonexisting = 0;
static int line_termination = '\n';
+static int detect_rename = 0;
/* A file entry went away or appeared */
static void show_file(const char *prefix, struct cache_entry *ce, unsigned char *sha1, unsigned int mode)
@@ -165,13 +166,14 @@ static void mark_merge_entries(void)
}
static char *diff_cache_usage =
-"git-diff-cache [-p] [-r] [-z] [-m] [--cached] <tree sha1>";
+"git-diff-cache [-p] [-r] [-z] [-m] [-M] [--cached] <tree-ish>";
int main(int argc, char **argv)
{
unsigned char tree_sha1[20];
void *tree;
unsigned long size;
+ int ret;
read_cache();
while (argc > 2) {
@@ -186,6 +188,10 @@ int main(int argc, char **argv)
generate_patch = 1;
continue;
}
+ if (!strcmp(arg, "-M")) {
+ generate_patch = detect_rename = 1;
+ continue;
+ }
if (!strcmp(arg, "-z")) {
line_termination = '\0';
continue;
@@ -204,6 +210,9 @@ int main(int argc, char **argv)
if (argc != 2 || get_sha1(argv[1], tree_sha1))
usage(diff_cache_usage);
+ if (generate_patch)
+ diff_setup(detect_rename, 0, 0, 0, 0);
+
mark_merge_entries();
tree = read_object_with_reference(tree_sha1, "tree", &size, 0);
@@ -212,5 +221,8 @@ int main(int argc, char **argv)
if (read_tree(tree, size, 1))
die("unable to read tree object %s", argv[1]);
- return diff_cache(active_cache, active_nr);
+ ret = diff_cache(active_cache, active_nr);
+ if (generate_patch)
+ diff_flush();
+ return ret;
}