Code

gitweb: Add support for hash_parent_base parameter for blobdiffs
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index a8710cb9e2388ce915fabc99cb86caacd1020961..7a238d023336d4340efd67534dae4ed23dd5d3c0 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -13,9 +13,9 @@
 
 static int use_size_cache;
 
-static int diff_detect_rename_default = 0;
+static int diff_detect_rename_default;
 static int diff_rename_limit_default = -1;
-static int diff_use_color_default = 0;
+static int diff_use_color_default;
 
 /* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */
 static char diff_colors[][24] = {
@@ -904,9 +904,7 @@ static int mmfile_is_binary(mmfile_t *mf)
        long sz = mf->size;
        if (FIRST_FEW_BYTES < sz)
                sz = FIRST_FEW_BYTES;
-       if (memchr(mf->ptr, 0, sz))
-               return 1;
-       return 0;
+       return !!memchr(mf->ptr, 0, sz);
 }
 
 static void builtin_diff(const char *name_a,
@@ -1104,7 +1102,7 @@ void fill_filespec(struct diff_filespec *spec, const unsigned char *sha1,
        if (mode) {
                spec->mode = canon_mode(mode);
                memcpy(spec->sha1, sha1, 20);
-               spec->sha1_valid = !!memcmp(sha1, null_sha1, 20);
+               spec->sha1_valid = !is_null_sha1(sha1);
        }
 }
 
@@ -1679,6 +1677,19 @@ void diff_setup(struct diff_options *options)
 
 int diff_setup_done(struct diff_options *options)
 {
+       int count = 0;
+
+       if (options->output_format & DIFF_FORMAT_NAME)
+               count++;
+       if (options->output_format & DIFF_FORMAT_NAME_STATUS)
+               count++;
+       if (options->output_format & DIFF_FORMAT_CHECKDIFF)
+               count++;
+       if (options->output_format & DIFF_FORMAT_NO_OUTPUT)
+               count++;
+       if (count > 1)
+               die("--name-only, --name-status, --check and -s are mutually exclusive");
+
        if (options->find_copies_harder)
                options->detect_rename = DIFF_DETECT_COPY;