aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2007-03-14 01:17:04 +0100
committerJunio C Hamano <junkio@cox.net>2007-03-14 16:21:19 -0700
commit41bbf9d58575095234c64df979ee884334469758 (patch)
tree916fb0b719369166e3cea928ec4831482ad4e9fa /diff.c
parent803527f1d9b284fa848d4a4bad23158c162a5d54 (diff)
downloadgit-41bbf9d58575095234c64df979ee884334469758.tar.gz
git-41bbf9d58575095234c64df979ee884334469758.tar.xz
Allow git-diff exit with codes similar to diff(1)
This introduces a new command-line option: --exit-code. The diff programs will return 1 for differences, return 0 for equality, and something else for errors. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/diff.c b/diff.c
index 954ca83e0..cc818011b 100644
--- a/diff.c
+++ b/diff.c
@@ -2134,6 +2134,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->color_diff = options->color_diff_words = 1;
else if (!strcmp(arg, "--no-renames"))
options->detect_rename = 0;
+ else if (!strcmp(arg, "--exit-code"))
+ options->exit_with_status = 1;
else
return 0;
return 1;
@@ -2910,6 +2912,8 @@ void diffcore_std(struct diff_options *options)
diffcore_order(options->orderfile);
diff_resolve_rename_copy();
diffcore_apply_filter(options->filter);
+ if (options->exit_with_status)
+ options->has_changes = !!diff_queued_diff.nr;
}
@@ -2920,6 +2924,8 @@ void diffcore_std_no_resolve(struct diff_options *options)
if (options->orderfile)
diffcore_order(options->orderfile);
diffcore_apply_filter(options->filter);
+ if (options->exit_with_status)
+ options->has_changes = !!diff_queued_diff.nr;
}
void diff_addremove(struct diff_options *options,