diff options
author | Junio C Hamano <junkio@cox.net> | 2005-05-29 16:56:13 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-05-30 10:35:49 -0700 |
commit | befe86392c767b62e4a6498cf951faae6f2c5ea3 (patch) | |
tree | 773e4f15fd5652983309b27c5f22dd29899cb749 | |
parent | [PATCH] diff-helper: Fix R/C score parsing under -z flag. (diff) | |
download | tgif-befe86392c767b62e4a6498cf951faae6f2c5ea3.tar.xz |
[PATCH] diff: consolidate various calls into diffcore.
The three diff-* brothers had a sequence of calls into diffcore
that were almost identical. Introduce a new diffcore_std()
function that takes all the necessary arguments to consolidate
it. This will make later enhancements and changing the order of
diffcore application simpler.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | diff-cache.c | 9 | ||||
-rw-r--r-- | diff-files.c | 9 | ||||
-rw-r--r-- | diff-tree.c | 7 | ||||
-rw-r--r-- | diff.c | 12 | ||||
-rw-r--r-- | diff.h | 4 |
5 files changed, 25 insertions, 16 deletions
diff --git a/diff-cache.c b/diff-cache.c index 1e0fda5299..c097826719 100644 --- a/diff-cache.c +++ b/diff-cache.c @@ -240,12 +240,9 @@ int main(int argc, const char **argv) die("unable to read tree object %s", tree_name); ret = diff_cache(active_cache, active_nr); - if (pathspec) - diffcore_pathspec(pathspec); - if (detect_rename) - diffcore_rename(detect_rename, diff_score_opt); - if (pickaxe) - diffcore_pickaxe(pickaxe, pickaxe_opts); + diffcore_std(pathspec, + detect_rename, diff_score_opt, + pickaxe, pickaxe_opts); diff_flush(diff_output_format, 1); return ret; } diff --git a/diff-files.c b/diff-files.c index 8ab7915977..3f20e7eee3 100644 --- a/diff-files.c +++ b/diff-files.c @@ -116,12 +116,9 @@ int main(int argc, const char **argv) show_modified(oldmode, mode, ce->sha1, null_sha1, ce->name); } - if (1 < argc) - diffcore_pathspec(argv + 1); - if (detect_rename) - diffcore_rename(detect_rename, diff_score_opt); - if (pickaxe) - diffcore_pickaxe(pickaxe, pickaxe_opts); + diffcore_std(argv + 1, + detect_rename, diff_score_opt, + pickaxe, pickaxe_opts); diff_flush(diff_output_format, 1); return 0; } diff --git a/diff-tree.c b/diff-tree.c index 8bdb1dba59..d634cb19e4 100644 --- a/diff-tree.c +++ b/diff-tree.c @@ -261,10 +261,9 @@ static void call_diff_setup(void) static int call_diff_flush(void) { - if (detect_rename) - diffcore_rename(detect_rename, diff_score_opt); - if (pickaxe) - diffcore_pickaxe(pickaxe, pickaxe_opts); + diffcore_std(0, + detect_rename, diff_score_opt, + pickaxe, pickaxe_opts); if (diff_queue_is_empty()) { diff_flush(DIFF_FORMAT_NO_OUTPUT, 0); return 0; @@ -887,6 +887,18 @@ void diff_flush(int diff_output_style, int resolve_rename_copy) q->nr = q->alloc = 0; } +void diffcore_std(const char **paths, + int detect_rename, int rename_score, + const char *pickaxe, int pickaxe_opts) +{ + if (paths && paths[0]) + diffcore_pathspec(paths); + if (detect_rename) + diffcore_rename(detect_rename, rename_score); + if (pickaxe) + diffcore_pickaxe(pickaxe, pickaxe_opts); +} + void diff_addremove(int addremove, unsigned mode, const unsigned char *sha1, const char *base, const char *path) @@ -43,6 +43,10 @@ extern void diffcore_pickaxe(const char *needle, int opts); extern void diffcore_pathspec(const char **pathspec); +extern void diffcore_std(const char **paths, + int detect_rename, int rename_score, + const char *pickaxe, int pickaxe_opts); + extern int diff_queue_is_empty(void); #define DIFF_FORMAT_HUMAN 0 |