summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorAlex Riesen <raa.lkml@gmail.com>2007-03-14 00:17:04 (GMT)
committerJunio C Hamano <junkio@cox.net>2007-03-14 23:21:19 (GMT)
commit41bbf9d58575095234c64df979ee884334469758 (patch)
tree916fb0b719369166e3cea928ec4831482ad4e9fa /diff.c
parent803527f1d9b284fa848d4a4bad23158c162a5d54 (diff)
downloadgit-41bbf9d58575095234c64df979ee884334469758.zip
git-41bbf9d58575095234c64df979ee884334469758.tar.gz
git-41bbf9d58575095234c64df979ee884334469758.tar.bz2
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 954ca83..cc81801 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,