Merge branch 'jc/diff-no-no-index'
authorJunio C Hamano <gitster@pobox.com>
Tue, 27 May 2008 05:38:19 +0000 (22:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 27 May 2008 05:38:19 +0000 (22:38 -0700)
* jc/diff-no-no-index:
git diff --no-index: default to page like other diff frontends
git-diff: allow --no-index semantics a bit more
"git diff": do not ignore index without --no-index
diff-files: do not play --no-index games
tests: do not use implicit "git diff --no-index"

60 files changed:
Documentation/git-diff-files.txt
Makefile
builtin-diff-files.c
builtin-diff.c
diff-lib.c
diff-no-index.c [new file with mode: 0644]
diff.h
git.c
t/diff-lib.sh
t/t0030-stripspace.sh
t/t0040-parse-options.sh
t/t1000-read-tree-m-3way.sh
t/t1001-read-tree-m-2way.sh
t/t1002-read-tree-m-u-2way.sh
t/t1300-repo-config.sh
t/t1303-wacky-config.sh
t/t1502-rev-parse-parseopt.sh
t/t3001-ls-files-others-exclude.sh
t/t3002-ls-files-dashpath.sh
t/t3030-merge-recursive.sh
t/t3040-subprojects-basic.sh
t/t3100-ls-tree-restrict.sh
t/t3101-ls-tree-dirname.sh
t/t3300-funny-names.sh
t/t3900-i18n-commit.sh
t/t4006-diff-mode.sh
t/t4013-diff-various.sh
t/t4013/diff.diff_--name-status_dir2_dir
t/t4013/diff.diff_--no-index_--name-status_dir2_dir [new file with mode: 0644]
t/t4014-format-patch.sh
t/t4015-diff-whitespace.sh
t/t4016-diff-quote.sh
t/t4018-diff-funcname.sh
t/t4100-apply-stat.sh
t/t4104-apply-boundary.sh
t/t4115-apply-symlink.sh
t/t4116-apply-reverse.sh
t/t4117-apply-reject.sh
t/t4118-apply-empty-context.sh
t/t4200-rerere.sh
t/t5305-include-tag.sh
t/t5400-send-pack.sh
t/t5401-update-hooks.sh
t/t5503-tagfollow.sh
t/t5505-remote.sh
t/t5515-fetch-merge-logic.sh
t/t6006-rev-list-format.sh
t/t6023-merge-file.sh
t/t6024-recursive-merge.sh
t/t6029-merge-subtree.sh
t/t6120-describe.sh
t/t6200-fmt-merge-msg.sh
t/t6300-for-each-ref.sh
t/t7003-filter-branch.sh
t/t7004-tag.sh
t/t7102-reset.sh
t/t7502-status.sh
t/t9100-git-svn-basic.sh
t/t9300-fast-import.sh
t/t9600-cvsimport.sh
index 6d2ea16a25989eaf2fa6cc219bca212251498ed3..ca1bb6a8ee9ccb6ffa5a01c7e13af7c8caa83cdf 100644 (file)
@@ -8,7 +8,7 @@ git-diff-files - Compares files in the working tree and the index
 
 SYNOPSIS
 --------
-'git-diff-files' [-q] [-0|-1|-2|-3|-c|--cc|--no-index] [<common diff options>] [<path>...]
+'git-diff-files' [-q] [-0|-1|-2|-3|-c|--cc] [<common diff options>] [<path>...]
 
 DESCRIPTION
 -----------
@@ -36,9 +36,6 @@ omit diff output for unmerged entries and just show "Unmerged".
        diff, similar to the way 'diff-tree' shows a merge
        commit with these flags.
 
---no-index::
-       Compare the two given files / directories.
-
 -q::
        Remain silent even on nonexistent files
 
index 4e36487c3c4d671a90ce255561afb00f1e02c8fd..cce5a6e1bf9ad8f5ebf8046a5053588d18e90bc6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -405,6 +405,7 @@ LIB_OBJS += diffcore-order.o
 LIB_OBJS += diffcore-pickaxe.o
 LIB_OBJS += diffcore-rename.o
 LIB_OBJS += diff-delta.o
+LIB_OBJS += diff-no-index.o
 LIB_OBJS += diff-lib.o
 LIB_OBJS += diff.o
 LIB_OBJS += dir.o
index 907392a1f3d9b548389708c8c56c20a05bb5a69c..384d871263383e89c6f8f52b16e9e7e147426d1d 100644 (file)
 #include "builtin.h"
 
 static const char diff_files_usage[] =
-"git-diff-files [-q] [-0/-1/2/3 |-c|--cc|--no-index] [<common diff options>] [<path>...]"
+"git-diff-files [-q] [-0/-1/2/3 |-c|--cc] [<common diff options>] [<path>...]"
 COMMON_DIFF_OPTIONS_HELP;
 
 int cmd_diff_files(int argc, const char **argv, const char *prefix)
 {
        struct rev_info rev;
-       int nongit;
        int result;
+       unsigned options = 0;
 
-       prefix = setup_git_directory_gently(&nongit);
        init_revisions(&rev, prefix);
        git_config(git_diff_basic_config, NULL); /* no "diff" UI options */
        rev.abbrev = 0;
 
-       if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))
-               argc = 0;
-       else
-               argc = setup_revisions(argc, argv, &rev, NULL);
+       argc = setup_revisions(argc, argv, &rev, NULL);
+       while (1 < argc && argv[1][0] == '-') {
+               if (!strcmp(argv[1], "--base"))
+                       rev.max_count = 1;
+               else if (!strcmp(argv[1], "--ours"))
+                       rev.max_count = 2;
+               else if (!strcmp(argv[1], "--theirs"))
+                       rev.max_count = 3;
+               else if (!strcmp(argv[1], "-q"))
+                       options |= DIFF_SILENT_ON_REMOVED;
+               else
+                       usage(diff_files_usage);
+               argv++; argc--;
+       }
        if (!rev.diffopt.output_format)
                rev.diffopt.output_format = DIFF_FORMAT_RAW;
-       result = run_diff_files_cmd(&rev, argc, argv);
+
+       /*
+        * Make sure there are NO revision (i.e. pending object) parameter,
+        * rev.max_count is reasonable (0 <= n <= 3), and
+        * there is no other revision filtering parameters.
+        */
+       if (rev.pending.nr ||
+           rev.min_age != -1 || rev.max_age != -1 ||
+           3 < rev.max_count)
+               usage(diff_files_usage);
+
+       if (rev.max_count == -1 &&
+           (rev.diffopt.output_format & DIFF_FORMAT_PATCH))
+               rev.combine_merges = rev.dense_combined_merges = 1;
+
+       if (read_cache() < 0) {
+               perror("read_cache");
+               return -1;
+       }
+       result = run_diff_files(&rev, options);
        return diff_result_code(&rev.diffopt, result);
 }
index 583291a9c0e52ed8c8e678606be7ec02b603db60..4c289e798a25ee3893a483abd8465740999dcbef 100644 (file)
@@ -202,6 +202,37 @@ static void refresh_index_quietly(void)
        rollback_lock_file(lock_file);
 }
 
+static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv)
+{
+       int result;
+       unsigned int options = 0;
+
+       while (1 < argc && argv[1][0] == '-') {
+               if (!strcmp(argv[1], "--base"))
+                       revs->max_count = 1;
+               else if (!strcmp(argv[1], "--ours"))
+                       revs->max_count = 2;
+               else if (!strcmp(argv[1], "--theirs"))
+                       revs->max_count = 3;
+               else if (!strcmp(argv[1], "-q"))
+                       options |= DIFF_SILENT_ON_REMOVED;
+               else
+                       return error("invalid option: %s", argv[1]);
+               argv++; argc--;
+       }
+
+       if (revs->max_count == -1 &&
+           (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
+               revs->combine_merges = revs->dense_combined_merges = 1;
+
+       if (read_cache() < 0) {
+               perror("read_cache");
+               return -1;
+       }
+       result = run_diff_files(revs, options);
+       return diff_result_code(&revs->diffopt, result);
+}
+
 int cmd_diff(int argc, const char **argv, const char *prefix)
 {
        int i;
@@ -230,6 +261,9 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
         * N=2, M=0:
         *      tree vs tree (diff-tree)
         *
+        * N=0, M=0, P=2:
+        *      compare two filesystem entities (aka --no-index).
+        *
         * Other cases are errors.
         */
 
@@ -240,21 +274,21 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
                diff_use_color_default = git_use_color_default;
 
        init_revisions(&rev, prefix);
+
+       /* If this is a no-index diff, just run it and exit there. */
+       diff_no_index(&rev, argc, argv, nongit, prefix);
+
+       /* Otherwise, we are doing the usual "git" diff */
        rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;
 
-       if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))
-               argc = 0;
-       else
-               argc = setup_revisions(argc, argv, &rev, NULL);
+       if (nongit)
+               die("Not a git repository");
+       argc = setup_revisions(argc, argv, &rev, NULL);
        if (!rev.diffopt.output_format) {
                rev.diffopt.output_format = DIFF_FORMAT_PATCH;
                if (diff_setup_done(&rev.diffopt) < 0)
                        die("diff_setup_done failed");
        }
-       if (rev.diffopt.prefix && nongit) {
-               rev.diffopt.prefix = NULL;
-               rev.diffopt.prefix_length = 0;
-       }
        DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
        DIFF_OPT_SET(&rev.diffopt, RECURSIVE);
 
@@ -265,7 +299,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        if (!DIFF_OPT_TST(&rev.diffopt, EXIT_WITH_STATUS))
                setup_pager();
 
-       /* Do we have --cached and not have a pending object, then
+       /*
+        * Do we have --cached and not have a pending object, then
         * default to HEAD by hand.  Eek.
         */
        if (!rev.pending.nr) {
@@ -333,7 +368,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
        if (!ents) {
                switch (blobs) {
                case 0:
-                       result = run_diff_files_cmd(&rev, argc, argv);
+                       result = builtin_diff_files(&rev, argc, argv);
                        break;
                case 1:
                        if (paths != 1)
index fe2ccec7e6b3230715cbdf04591d1c0efb6a6389..b17722d66a7008b822125bb96ab1b7921e8b627b 100644 (file)
@@ -8,7 +8,6 @@
 #include "diffcore.h"
 #include "revision.h"
 #include "cache-tree.h"
-#include "path-list.h"
 #include "unpack-trees.h"
 #include "refs.h"
 
  * diff-files
  */
 
-static int read_directory(const char *path, struct path_list *list)
-{
-       DIR *dir;
-       struct dirent *e;
-
-       if (!(dir = opendir(path)))
-               return error("Could not open directory %s", path);
-
-       while ((e = readdir(dir)))
-               if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
-                       path_list_insert(e->d_name, list);
-
-       closedir(dir);
-       return 0;
-}
-
-static int get_mode(const char *path, int *mode)
-{
-       struct stat st;
-
-       if (!path || !strcmp(path, "/dev/null"))
-               *mode = 0;
-       else if (!strcmp(path, "-"))
-               *mode = create_ce_mode(0666);
-       else if (stat(path, &st))
-               return error("Could not access '%s'", path);
-       else
-               *mode = st.st_mode;
-       return 0;
-}
-
-static int queue_diff(struct diff_options *o,
-               const char *name1, const char *name2)
-{
-       int mode1 = 0, mode2 = 0;
-
-       if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
-               return -1;
-
-       if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
-               return error("file/directory conflict: %s, %s", name1, name2);
-
-       if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
-               char buffer1[PATH_MAX], buffer2[PATH_MAX];
-               struct path_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1};
-               int len1 = 0, len2 = 0, i1, i2, ret = 0;
-
-               if (name1 && read_directory(name1, &p1))
-                       return -1;
-               if (name2 && read_directory(name2, &p2)) {
-                       path_list_clear(&p1, 0);
-                       return -1;
-               }
-
-               if (name1) {
-                       len1 = strlen(name1);
-                       if (len1 > 0 && name1[len1 - 1] == '/')
-                               len1--;
-                       memcpy(buffer1, name1, len1);
-                       buffer1[len1++] = '/';
-               }
-
-               if (name2) {
-                       len2 = strlen(name2);
-                       if (len2 > 0 && name2[len2 - 1] == '/')
-                               len2--;
-                       memcpy(buffer2, name2, len2);
-                       buffer2[len2++] = '/';
-               }
-
-               for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) {
-                       const char *n1, *n2;
-                       int comp;
-
-                       if (i1 == p1.nr)
-                               comp = 1;
-                       else if (i2 == p2.nr)
-                               comp = -1;
-                       else
-                               comp = strcmp(p1.items[i1].path,
-                                       p2.items[i2].path);
-
-                       if (comp > 0)
-                               n1 = NULL;
-                       else {
-                               n1 = buffer1;
-                               strncpy(buffer1 + len1, p1.items[i1++].path,
-                                               PATH_MAX - len1);
-                       }
-
-                       if (comp < 0)
-                               n2 = NULL;
-                       else {
-                               n2 = buffer2;
-                               strncpy(buffer2 + len2, p2.items[i2++].path,
-                                               PATH_MAX - len2);
-                       }
-
-                       ret = queue_diff(o, n1, n2);
-               }
-               path_list_clear(&p1, 0);
-               path_list_clear(&p2, 0);
-
-               return ret;
-       } else {
-               struct diff_filespec *d1, *d2;
-
-               if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
-                       unsigned tmp;
-                       const char *tmp_c;
-                       tmp = mode1; mode1 = mode2; mode2 = tmp;
-                       tmp_c = name1; name1 = name2; name2 = tmp_c;
-               }
-
-               if (!name1)
-                       name1 = "/dev/null";
-               if (!name2)
-                       name2 = "/dev/null";
-               d1 = alloc_filespec(name1);
-               d2 = alloc_filespec(name2);
-               fill_filespec(d1, null_sha1, mode1);
-               fill_filespec(d2, null_sha1, mode2);
-
-               diff_queue(&diff_queued_diff, d1, d2);
-               return 0;
-       }
-}
-
-/*
- * Does the path name a blob in the working tree, or a directory
- * in the working tree?
- */
-static int is_in_index(const char *path)
-{
-       int len, pos;
-       struct cache_entry *ce;
-
-       len = strlen(path);
-       while (path[len-1] == '/')
-               len--;
-       if (!len)
-               return 1; /* "." */
-       pos = cache_name_pos(path, len);
-       if (0 <= pos)
-               return 1;
-       pos = -1 - pos;
-       while (pos < active_nr) {
-               ce = active_cache[pos++];
-               if (ce_namelen(ce) <= len ||
-                   strncmp(ce->name, path, len) ||
-                   (ce->name[len] > '/'))
-                       break; /* path cannot be a prefix */
-               if (ce->name[len] == '/')
-                       return 1;
-       }
-       return 0;
-}
-
-static int handle_diff_files_args(struct rev_info *revs,
-                                 int argc, const char **argv,
-                                 unsigned int *options)
-{
-       *options = 0;
-
-       /* revs->max_count == -2 means --no-index */
-       while (1 < argc && argv[1][0] == '-') {
-               if (!strcmp(argv[1], "--base"))
-                       revs->max_count = 1;
-               else if (!strcmp(argv[1], "--ours"))
-                       revs->max_count = 2;
-               else if (!strcmp(argv[1], "--theirs"))
-                       revs->max_count = 3;
-               else if (!strcmp(argv[1], "-n") ||
-                               !strcmp(argv[1], "--no-index")) {
-                       revs->max_count = -2;
-                       DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
-                       DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
-               }
-               else if (!strcmp(argv[1], "-q"))
-                       *options |= DIFF_SILENT_ON_REMOVED;
-               else
-                       return error("invalid option: %s", argv[1]);
-               argv++; argc--;
-       }
-
-       if (revs->max_count == -1 && revs->diffopt.nr_paths == 2) {
-               /*
-                * If two files are specified, and at least one is untracked,
-                * default to no-index.
-                */
-               read_cache();
-               if (!is_in_index(revs->diffopt.paths[0]) ||
-                                       !is_in_index(revs->diffopt.paths[1])) {
-                       revs->max_count = -2;
-                       DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
-               }
-       }
-
-       /*
-        * Make sure there are NO revision (i.e. pending object) parameter,
-        * rev.max_count is reasonable (0 <= n <= 3),
-        * there is no other revision filtering parameters.
-        */
-       if (revs->pending.nr || revs->max_count > 3 ||
-           revs->min_age != -1 || revs->max_age != -1)
-               return error("no revision allowed with diff-files");
-
-       if (revs->max_count == -1 &&
-           (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
-               revs->combine_merges = revs->dense_combined_merges = 1;
-
-       return 0;
-}
-
-static int is_outside_repo(const char *path, int nongit, const char *prefix)
-{
-       int i;
-       if (nongit || !strcmp(path, "-") || is_absolute_path(path))
-               return 1;
-       if (prefixcmp(path, "../"))
-               return 0;
-       if (!prefix)
-               return 1;
-       for (i = strlen(prefix); !prefixcmp(path, "../"); ) {
-               while (i > 0 && prefix[i - 1] != '/')
-                       i--;
-               if (--i < 0)
-                       return 1;
-               path += 3;
-       }
-       return 0;
-}
-
-int setup_diff_no_index(struct rev_info *revs,
-               int argc, const char ** argv, int nongit, const char *prefix)
-{
-       int i;
-       for (i = 1; i < argc; i++)
-               if (argv[i][0] != '-' || argv[i][1] == '\0')
-                       break;
-               else if (!strcmp(argv[i], "--")) {
-                       i++;
-                       break;
-               } else if (i < argc - 3 && !strcmp(argv[i], "--no-index")) {
-                       i = argc - 3;
-                       DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
-                       break;
-               }
-       if (nongit && argc != i + 2)
-               die("git diff [--no-index] takes two paths");
-
-       if (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&
-                               !is_outside_repo(argv[i], nongit, prefix)))
-               return -1;
-
-       diff_setup(&revs->diffopt);
-       for (i = 1; i < argc - 2; )
-               if (!strcmp(argv[i], "--no-index"))
-                       i++;
-               else {
-                       int j = diff_opt_parse(&revs->diffopt,
-                                       argv + i, argc - i);
-                       if (!j)
-                               die("invalid diff option/value: %s", argv[i]);
-                       i += j;
-               }
-
-       if (prefix) {
-               int len = strlen(prefix);
-
-               revs->diffopt.paths = xcalloc(2, sizeof(char*));
-               for (i = 0; i < 2; i++) {
-                       const char *p = argv[argc - 2 + i];
-                       /*
-                        * stdin should be spelled as '-'; if you have
-                        * path that is '-', spell it as ./-.
-                        */
-                       p = (strcmp(p, "-")
-                            ? xstrdup(prefix_filename(prefix, len, p))
-                            : p);
-                       revs->diffopt.paths[i] = p;
-               }
-       }
-       else
-               revs->diffopt.paths = argv + argc - 2;
-       revs->diffopt.nr_paths = 2;
-       DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
-       revs->max_count = -2;
-       if (diff_setup_done(&revs->diffopt) < 0)
-               die("diff_setup_done failed");
-       return 0;
-}
-
-int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)
-{
-       unsigned int options;
-
-       if (handle_diff_files_args(revs, argc, argv, &options))
-               return -1;
-
-       if (DIFF_OPT_TST(&revs->diffopt, NO_INDEX)) {
-               if (revs->diffopt.nr_paths != 2)
-                       return error("need two files/directories with --no-index");
-               if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
-                               revs->diffopt.paths[1]))
-                       return -1;
-               diffcore_std(&revs->diffopt);
-               diff_flush(&revs->diffopt);
-               /*
-                * The return code for --no-index imitates diff(1):
-                * 0 = no changes, 1 = changes, else error
-                */
-               return revs->diffopt.found_changes;
-       }
-
-       if (read_cache() < 0) {
-               perror("read_cache");
-               return -1;
-       }
-       return run_diff_files(revs, options);
-}
-
 /*
  * Has the work tree entity been removed?
  *
diff --git a/diff-no-index.c b/diff-no-index.c
new file mode 100644 (file)
index 0000000..f6994cf
--- /dev/null
@@ -0,0 +1,263 @@
+/*
+ * "diff --no-index" support
+ * Copyright (c) 2007 by Johannes Schindelin
+ * Copyright (c) 2008 by Junio C Hamano
+ */
+
+#include "cache.h"
+#include "color.h"
+#include "commit.h"
+#include "blob.h"
+#include "tag.h"
+#include "diff.h"
+#include "diffcore.h"
+#include "revision.h"
+#include "log-tree.h"
+#include "builtin.h"
+#include "path-list.h"
+
+static int read_directory(const char *path, struct path_list *list)
+{
+       DIR *dir;
+       struct dirent *e;
+
+       if (!(dir = opendir(path)))
+               return error("Could not open directory %s", path);
+
+       while ((e = readdir(dir)))
+               if (strcmp(".", e->d_name) && strcmp("..", e->d_name))
+                       path_list_insert(e->d_name, list);
+
+       closedir(dir);
+       return 0;
+}
+
+static int get_mode(const char *path, int *mode)
+{
+       struct stat st;
+
+       if (!path || !strcmp(path, "/dev/null"))
+               *mode = 0;
+       else if (!strcmp(path, "-"))
+               *mode = create_ce_mode(0666);
+       else if (stat(path, &st))
+               return error("Could not access '%s'", path);
+       else
+               *mode = st.st_mode;
+       return 0;
+}
+
+static int queue_diff(struct diff_options *o,
+               const char *name1, const char *name2)
+{
+       int mode1 = 0, mode2 = 0;
+
+       if (get_mode(name1, &mode1) || get_mode(name2, &mode2))
+               return -1;
+
+       if (mode1 && mode2 && S_ISDIR(mode1) != S_ISDIR(mode2))
+               return error("file/directory conflict: %s, %s", name1, name2);
+
+       if (S_ISDIR(mode1) || S_ISDIR(mode2)) {
+               char buffer1[PATH_MAX], buffer2[PATH_MAX];
+               struct path_list p1 = {NULL, 0, 0, 1}, p2 = {NULL, 0, 0, 1};
+               int len1 = 0, len2 = 0, i1, i2, ret = 0;
+
+               if (name1 && read_directory(name1, &p1))
+                       return -1;
+               if (name2 && read_directory(name2, &p2)) {
+                       path_list_clear(&p1, 0);
+                       return -1;
+               }
+
+               if (name1) {
+                       len1 = strlen(name1);
+                       if (len1 > 0 && name1[len1 - 1] == '/')
+                               len1--;
+                       memcpy(buffer1, name1, len1);
+                       buffer1[len1++] = '/';
+               }
+
+               if (name2) {
+                       len2 = strlen(name2);
+                       if (len2 > 0 && name2[len2 - 1] == '/')
+                               len2--;
+                       memcpy(buffer2, name2, len2);
+                       buffer2[len2++] = '/';
+               }
+
+               for (i1 = i2 = 0; !ret && (i1 < p1.nr || i2 < p2.nr); ) {
+                       const char *n1, *n2;
+                       int comp;
+
+                       if (i1 == p1.nr)
+                               comp = 1;
+                       else if (i2 == p2.nr)
+                               comp = -1;
+                       else
+                               comp = strcmp(p1.items[i1].path,
+                                       p2.items[i2].path);
+
+                       if (comp > 0)
+                               n1 = NULL;
+                       else {
+                               n1 = buffer1;
+                               strncpy(buffer1 + len1, p1.items[i1++].path,
+                                               PATH_MAX - len1);
+                       }
+
+                       if (comp < 0)
+                               n2 = NULL;
+                       else {
+                               n2 = buffer2;
+                               strncpy(buffer2 + len2, p2.items[i2++].path,
+                                               PATH_MAX - len2);
+                       }
+
+                       ret = queue_diff(o, n1, n2);
+               }
+               path_list_clear(&p1, 0);
+               path_list_clear(&p2, 0);
+
+               return ret;
+       } else {
+               struct diff_filespec *d1, *d2;
+
+               if (DIFF_OPT_TST(o, REVERSE_DIFF)) {
+                       unsigned tmp;
+                       const char *tmp_c;
+                       tmp = mode1; mode1 = mode2; mode2 = tmp;
+                       tmp_c = name1; name1 = name2; name2 = tmp_c;
+               }
+
+               if (!name1)
+                       name1 = "/dev/null";
+               if (!name2)
+                       name2 = "/dev/null";
+               d1 = alloc_filespec(name1);
+               d2 = alloc_filespec(name2);
+               fill_filespec(d1, null_sha1, mode1);
+               fill_filespec(d2, null_sha1, mode2);
+
+               diff_queue(&diff_queued_diff, d1, d2);
+               return 0;
+       }
+}
+
+static int path_outside_repo(const char *path)
+{
+       /*
+        * We have already done setup_git_directory_gently() so we
+        * know we are inside a git work tree already.
+        */
+       const char *work_tree;
+       size_t len;
+
+       if (!is_absolute_path(path))
+               return 0;
+       work_tree = get_git_work_tree();
+       len = strlen(work_tree);
+       if (strncmp(path, work_tree, len) ||
+           (path[len] != '\0' && path[len] != '/'))
+               return 1;
+       return 0;
+}
+
+void diff_no_index(struct rev_info *revs,
+                  int argc, const char **argv,
+                  int nongit, const char *prefix)
+{
+       int i;
+       int no_index = 0;
+       unsigned options = 0;
+
+       /* Were we asked to do --no-index explicitly? */
+       for (i = 1; i < argc; i++) {
+               if (!strcmp(argv[i], "--"))
+                       return;
+               if (!strcmp(argv[i], "--no-index"))
+                       no_index = 1;
+               if (argv[i][0] != '-')
+                       break;
+       }
+
+       if (!no_index && !nongit) {
+               /*
+                * Inside a git repository, without --no-index.  Only
+                * when a path outside the repository is given,
+                * e.g. "git diff /var/tmp/[12]", or "git diff
+                * Makefile /var/tmp/Makefile", allow it to be used as
+                * a colourful "diff" replacement.
+                */
+               if ((argc != i + 2) ||
+                   (!path_outside_repo(argv[i]) &&
+                    !path_outside_repo(argv[i+1])))
+                       return;
+       }
+       if (argc != i + 2)
+               die("git diff %s takes two paths",
+                   no_index ? "--no-index" : "[--no-index]");
+
+       /*
+        * If the user asked for our exit code then don't start a
+        * pager or we would end up reporting its exit code instead.
+        */
+       if (!DIFF_OPT_TST(&revs->diffopt, EXIT_WITH_STATUS))
+               setup_pager();
+
+       diff_setup(&revs->diffopt);
+       if (!revs->diffopt.output_format)
+               revs->diffopt.output_format = DIFF_FORMAT_PATCH;
+       for (i = 1; i < argc - 2; ) {
+               int j;
+               if (!strcmp(argv[i], "--no-index"))
+                       i++;
+               else if (!strcmp(argv[1], "-q"))
+                       options |= DIFF_SILENT_ON_REMOVED;
+               else {
+                       j = diff_opt_parse(&revs->diffopt, argv + i, argc - i);
+                       if (!j)
+                               die("invalid diff option/value: %s", argv[i]);
+                       i += j;
+               }
+       }
+
+       if (prefix) {
+               int len = strlen(prefix);
+
+               revs->diffopt.paths = xcalloc(2, sizeof(char*));
+               for (i = 0; i < 2; i++) {
+                       const char *p = argv[argc - 2 + i];
+                       /*
+                        * stdin should be spelled as '-'; if you have
+                        * path that is '-', spell it as ./-.
+                        */
+                       p = (strcmp(p, "-")
+                            ? xstrdup(prefix_filename(prefix, len, p))
+                            : p);
+                       revs->diffopt.paths[i] = p;
+               }
+       }
+       else
+               revs->diffopt.paths = argv + argc - 2;
+       revs->diffopt.nr_paths = 2;
+
+       DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
+       DIFF_OPT_SET(&revs->diffopt, NO_INDEX);
+
+       revs->max_count = -2;
+       if (diff_setup_done(&revs->diffopt) < 0)
+               die("diff_setup_done failed");
+
+       if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
+                      revs->diffopt.paths[1]))
+               exit(1);
+       diffcore_std(&revs->diffopt);
+       diff_flush(&revs->diffopt);
+
+       /*
+        * The return code for --no-index imitates diff(1):
+        * 0 = no changes, 1 = changes, else error
+        */
+       exit(revs->diffopt.found_changes);
+}
diff --git a/diff.h b/diff.h
index b0b700a5f6ec71174c40285f376fc1b2bfb34e3a..5dc0cb595b64868ca8b8e26e5311d2df102c89e0 100644 (file)
--- a/diff.h
+++ b/diff.h
@@ -251,10 +251,6 @@ extern const char *diff_unique_abbrev(const unsigned char *, int);
 /* report racily-clean paths as modified */
 #define DIFF_RACY_IS_MODIFIED 02
 extern int run_diff_files(struct rev_info *revs, unsigned int option);
-extern int setup_diff_no_index(struct rev_info *revs,
-               int argc, const char ** argv, int nongit, const char *prefix);
-extern int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv);
-
 extern int run_diff_index(struct rev_info *revs, int cached);
 
 extern int do_diff_cache(const unsigned char *, struct diff_options *);
@@ -262,4 +258,6 @@ extern int diff_flush_patch_id(struct diff_options *, unsigned char *);
 
 extern int diff_result_code(struct diff_options *, int);
 
+extern void diff_no_index(struct rev_info *, int, const char **, int, const char *);
+
 #endif /* DIFF_H */
diff --git a/git.c b/git.c
index 2c9004f02e33180dcdbbc5b2e90266599ad41cc1..272bf03da3b3aee7dbdb088ddc1042c18567492a 100644 (file)
--- a/git.c
+++ b/git.c
@@ -294,7 +294,7 @@ static void handle_internal_command(int argc, const char **argv)
                { "count-objects", cmd_count_objects, RUN_SETUP },
                { "describe", cmd_describe, RUN_SETUP },
                { "diff", cmd_diff },
-               { "diff-files", cmd_diff_files },
+               { "diff-files", cmd_diff_files, RUN_SETUP },
                { "diff-index", cmd_diff_index, RUN_SETUP },
                { "diff-tree", cmd_diff_tree, RUN_SETUP },
                { "fast-export", cmd_fast_export, RUN_SETUP },
index 28b941c493ca96b726c6cde27660e987fc31bedc..4bddeb591ecc17ec532164d0d6cf1ad1a54eb996 100644 (file)
@@ -11,7 +11,7 @@ compare_diff_raw () {
 
     sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
     sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
-    git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+    test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
 }
 
 sanitize_diff_raw_z='/^:/s/ '"$_x40"' '"$_x40"' \([A-Z]\)[0-9]*$/ X X \1#/'
@@ -23,7 +23,7 @@ compare_diff_raw_z () {
 
     perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
     perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
-    git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+    test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
 }
 
 compare_diff_patch () {
@@ -37,5 +37,5 @@ compare_diff_patch () {
        /^[dis]*imilarity index [0-9]*%$/d
        /^index [0-9a-f]*\.\.[0-9a-f]/d
     ' <"$2" >.tmp-2
-    git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
+    test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
 }
index 3ecdd6626aa58f7e2bbe0addb292b57dd2168a14..ccb0a3cb61be3bb591033564b221726a4cd3968d 100755 (executable)
@@ -16,96 +16,96 @@ test_expect_success \
     'long lines without spaces should be unchanged' '
     echo "$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt$ttt$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt$ttt$ttt$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
     'lines with spaces at the beginning should be unchanged' '
     echo "$sss$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$sss$sss$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$sss$sss$sss$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
     'lines with intermediate spaces should be unchanged' '
     echo "$ttt$sss$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt$sss$sss$ttt" >expect &&
     git stripspace <expect >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
     'consecutive blank lines should be unified' '
     printf "$ttt\n\n$ttt\n" > expect &&
     printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt\n\n$ttt\n" > expect &&
     printf "$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
     printf "$ttt$ttt$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$ttt\n" > expect &&
     printf "$ttt\n\n\n\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$ttt$ttt\n" > expect &&
     printf "$ttt\n\n\n\n\n$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
     printf "$ttt\n\n\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$ttt\n" > expect &&
     printf "$ttt\n\t\n \n\n  \t\t\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt\n\n$ttt\n" > expect &&
     printf "$ttt$ttt\n\t\n \n\n  \t\t\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt$ttt\n\n$ttt\n" > expect &&
     printf "$ttt$ttt$ttt\n\t\n \n\n  \t\t\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$ttt\n" > expect &&
     printf "$ttt\n\t\n \n\n  \t\t\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$ttt$ttt\n" > expect &&
     printf "$ttt\n\t\n \n\n  \t\t\n$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$ttt$ttt$ttt\n" > expect &&
     printf "$ttt\n\t\n \n\n  \t\t\n$ttt$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
@@ -113,114 +113,114 @@ test_expect_success \
     > expect &&
 
     printf "\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "\n\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$sss\n$sss\n$sss\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$sss$sss\n$sss\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "\n$sss\n$sss$sss\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$sss$sss$sss$sss\n\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "\n$sss$sss$sss$sss\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "\n\n$sss$sss$sss$sss\n" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
     'consecutive blank lines at the beginning should be removed' '
     printf "$ttt\n" > expect &&
     printf "\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n" > expect &&
     printf "\n\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt\n" > expect &&
     printf "\n\n\n$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt$ttt\n" > expect &&
     printf "\n\n\n$ttt$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt$ttt$ttt\n" > expect &&
     printf "\n\n\n$ttt$ttt$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n" > expect &&
 
     printf "$sss\n$sss\n$sss\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "\n$sss\n$sss$sss\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$sss$sss\n$sss\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$sss$sss$sss\n\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "\n$sss$sss$sss\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "\n\n$sss$sss$sss\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
     'consecutive blank lines at the end should be removed' '
     printf "$ttt\n" > expect &&
     printf "$ttt\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n" > expect &&
     printf "$ttt\n\n\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt\n" > expect &&
     printf "$ttt$ttt\n\n\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt$ttt\n" > expect &&
     printf "$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt$ttt$ttt\n" > expect &&
     printf "$ttt$ttt$ttt$ttt\n\n\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n" > expect &&
 
     printf "$ttt\n$sss\n$sss\n$sss\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$sss\n$sss$sss\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n$sss$sss\n$sss\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n$sss$sss$sss\n\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n$sss$sss$sss\n\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n\n\n$sss$sss$sss\n" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
@@ -257,27 +257,27 @@ test_expect_success \
     'text plus spaces without newline should show the correct lines' '
     printf "$ttt\n" >expect &&
     printf "$ttt$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n" >expect &&
     printf "$ttt$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n" >expect &&
     printf "$ttt$sss$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt\n" >expect &&
     printf "$ttt$ttt$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt\n" >expect &&
     printf "$ttt$ttt$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt$ttt\n" >expect &&
     printf "$ttt$ttt$ttt$sss" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
@@ -294,27 +294,27 @@ test_expect_success \
     'text plus spaces at end should be cleaned and newline must remain' '
     echo "$ttt" >expect &&
     echo "$ttt$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt" >expect &&
     echo "$ttt$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt" >expect &&
     echo "$ttt$sss$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt$ttt" >expect &&
     echo "$ttt$ttt$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt$ttt" >expect &&
     echo "$ttt$ttt$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$ttt$ttt$ttt" >expect &&
     echo "$ttt$ttt$ttt$sss" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 # spaces only:
@@ -324,19 +324,19 @@ test_expect_success \
     printf "" >expect &&
 
     echo | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$sss$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     echo "$sss$sss$sss$sss" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
@@ -353,43 +353,43 @@ test_expect_success \
     printf "" >expect &&
 
     printf "" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$sss$sss$sss" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$sss$sss$sss$sss" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success \
     'consecutive text lines should be unchanged' '
     printf "$ttt$ttt\n$ttt\n" >expect &&
     printf "$ttt$ttt\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n$ttt$ttt\n$ttt\n" >expect &&
     printf "$ttt\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" >expect &&
     printf "$ttt\n$ttt\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" >expect &&
     printf "$ttt\n$ttt\n\n$ttt$ttt\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" >expect &&
     printf "$ttt$ttt\n\n$ttt\n$ttt$ttt\n" | git stripspace >actual &&
-    git diff expect actual &&
+    test_cmp expect actual &&
 
     printf "$ttt\n$ttt$ttt\n\n$ttt\n" >expect &&
     printf "$ttt\n$ttt$ttt\n\n$ttt\n" | git stripspace >actual &&
-    git diff expect actual
+    test_cmp expect actual
 '
 
 test_expect_success 'strip comments, too' '
index c23f0ace85c83f54fd7562d72af6ef6c1ea2eca3..9965cfa1dca7948f24a835d5beae4608e6947c0a 100755 (executable)
@@ -29,7 +29,7 @@ EOF
 test_expect_success 'test help' '
        ! test-parse-options -h > output 2> output.err &&
        test ! -s output &&
-       git diff expect.err output.err
+       test_cmp expect.err output.err
 '
 
 cat > expect << EOF
@@ -40,7 +40,7 @@ EOF
 
 test_expect_success 'short options' '
        test-parse-options -s123 -b -i 1729 -b > output 2> output.err &&
-       git diff expect output &&
+       test_cmp expect output &&
        test ! -s output.err
 '
 cat > expect << EOF
@@ -53,7 +53,7 @@ test_expect_success 'long options' '
        test-parse-options --boolean --integer 1729 --boolean --string2=321 \
                > output 2> output.err &&
        test ! -s output.err &&
-       git diff expect output
+       test_cmp expect output
 '
 
 cat > expect << EOF
@@ -69,7 +69,7 @@ test_expect_success 'intermingled arguments' '
        test-parse-options a1 --string 123 b1 --boolean -j 13 -- --boolean \
                > output 2> output.err &&
        test ! -s output.err &&
-       git diff expect output
+       test_cmp expect output
 '
 
 cat > expect << EOF
@@ -81,13 +81,13 @@ EOF
 test_expect_success 'unambiguously abbreviated option' '
        test-parse-options --int 2 --boolean --no-bo > output 2> output.err &&
        test ! -s output.err &&
-       git diff expect output
+       test_cmp expect output
 '
 
 test_expect_success 'unambiguously abbreviated option with "="' '
        test-parse-options --int=2 > output 2> output.err &&
        test ! -s output.err &&
-       git diff expect output
+       test_cmp expect output
 '
 
 test_expect_success 'ambiguously abbreviated option' '
@@ -104,7 +104,7 @@ EOF
 test_expect_success 'non ambiguous option (after two options it abbreviates)' '
        test-parse-options --st 123 > output 2> output.err &&
        test ! -s output.err &&
-       git diff expect output
+       test_cmp expect output
 '
 
 cat > expect.err << EOF
@@ -114,7 +114,7 @@ EOF
 test_expect_success 'detect possible typos' '
        ! test-parse-options -boolean > output 2> output.err &&
        test ! -s output &&
-       git diff expect.err output.err
+       test_cmp expect.err output.err
 '
 
 cat > expect <<EOF
@@ -127,7 +127,7 @@ EOF
 test_expect_success 'keep some options as arguments' '
        test-parse-options --quux > output 2> output.err &&
         test ! -s output.err &&
-        git diff expect output
+        test_cmp expect output
 '
 
 test_done
index 17f519f547356d550c16668b929d9140b568a6f7..807fb83af8c65304f1dae2ee35ba0f2909ddf465 100755 (executable)
@@ -131,7 +131,7 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 
 check_result () {
     git ls-files --stage | sed -e 's/ '"$_x40"' / X /' >current &&
-    git diff expected current
+    test_cmp expected current
 }
 
 # This is done on an empty work directory, which is the normal
index b01b0037a0c4923549b5b2261ed931b3718a7671..4b44e131b27df0cc6a73590b045c2eb87b104f59 100755 (executable)
@@ -33,7 +33,7 @@ compare_change () {
            -e '/^--- /d; /^+++ /d; /^@@ /d;' \
            -e 's/^\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /p' \
            "$1"
-       git diff expected current
+       test_cmp expected current
 }
 
 check_cache_at () {
@@ -86,7 +86,7 @@ test_expect_success \
     'rm -f .git/index &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >1-3.out &&
-     git diff M.out 1-3.out &&
+     test_cmp M.out 1-3.out &&
      check_cache_at bozbar dirty &&
      check_cache_at frotz dirty &&
      check_cache_at nitfol dirty'
@@ -101,7 +101,7 @@ test_expect_success \
      git update-index --add yomin &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >4.out || return 1
-     git diff M.out 4.out >4diff.out
+     git diff --no-index M.out 4.out >4diff.out
      compare_change 4diff.out expected &&
      check_cache_at yomin clean'
 
@@ -115,7 +115,7 @@ test_expect_success \
      echo yomin yomin >yomin &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >5.out || return 1
-     git diff M.out 5.out >5diff.out
+     git diff --no-index M.out 5.out >5diff.out
      compare_change 5diff.out expected &&
      check_cache_at yomin dirty'
 
@@ -127,7 +127,7 @@ test_expect_success \
      git update-index --add frotz &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >6.out &&
-     git diff M.out 6.out &&
+     test_cmp M.out 6.out &&
      check_cache_at frotz clean'
 
 test_expect_success \
@@ -140,7 +140,7 @@ test_expect_success \
      echo frotz frotz >frotz &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >7.out &&
-     git diff M.out 7.out &&
+     test_cmp M.out 7.out &&
      check_cache_at frotz dirty'
 
 test_expect_success \
@@ -171,7 +171,7 @@ test_expect_success \
      git update-index --add rezrov &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >10.out &&
-     git diff M.out 10.out'
+     test_cmp M.out 10.out'
 
 test_expect_success \
     '11 - dirty path removed.' \
@@ -216,7 +216,7 @@ test_expect_success \
      git update-index --add nitfol &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >14.out || return 1
-     git diff M.out 14.out >14diff.out
+     git diff --no-index M.out 14.out >14diff.out
      compare_change 14diff.out expected &&
      check_cache_at nitfol clean'
 
@@ -230,7 +230,7 @@ test_expect_success \
      echo nitfol nitfol nitfol >nitfol &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >15.out || return 1
-     git diff M.out 15.out >15diff.out
+     git diff --no-index M.out 15.out >15diff.out
      compare_change 15diff.out expected &&
      check_cache_at nitfol dirty'
 
@@ -262,7 +262,7 @@ test_expect_success \
      git update-index --add bozbar &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >18.out &&
-     git diff M.out 18.out &&
+     test_cmp M.out 18.out &&
      check_cache_at bozbar clean'
 
 test_expect_success \
@@ -275,7 +275,7 @@ test_expect_success \
      echo gnusto gnusto >bozbar &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >19.out &&
-     git diff M.out 19.out &&
+     test_cmp M.out 19.out &&
      check_cache_at bozbar dirty'
 
 test_expect_success \
@@ -287,7 +287,7 @@ test_expect_success \
      git update-index --add bozbar &&
      read_tree_twoway $treeH $treeM &&
      git ls-files --stage >20.out &&
-     git diff M.out 20.out &&
+     test_cmp M.out 20.out &&
      check_cache_at bozbar dirty'
 
 test_expect_success \
@@ -337,7 +337,7 @@ test_expect_success \
      git update-index --add DF &&
      read_tree_twoway $treeDF $treeDFDF &&
      git ls-files --stage >DFDFcheck.out &&
-     git diff DFDF.out DFDFcheck.out &&
+     test_cmp DFDF.out DFDFcheck.out &&
      check_cache_at DF/DF dirty &&
      :'
 
index 42e5cf81813a7703ff2173dcc29e35ffdc68f552..e04990eafda82578c5e19971db7f87c3bc5a772f 100755 (executable)
@@ -16,7 +16,7 @@ compare_change () {
        sed >current \
            -e '/^--- /d; /^+++ /d; /^@@ /d;' \
            -e 's/^\(.[0-7][0-7][0-7][0-7][0-7][0-7]\) '"$_x40"' /\1 X /' "$1"
-       git diff expected current
+       test_cmp expected current
 }
 
 check_cache_at () {
index a675cbb51b5dafad22dd494784a0b4c8ec396db3..afe7e663fb96484474f69af51268d42c78a04185 100755 (executable)
@@ -427,13 +427,13 @@ cat > expect << EOF
 weird
 EOF
 
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
 
 test_expect_success "rename non-existing section" '
        ! git config --rename-section branch."world domination" branch.drei
 '
 
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
 
 test_expect_success "rename another section" \
        'git config --rename-section branch."1 234 blabl/a" branch.drei'
@@ -449,7 +449,7 @@ cat > expect << EOF
 weird
 EOF
 
-test_expect_success "rename succeeded" "git diff expect .git/config"
+test_expect_success "rename succeeded" "test_cmp expect .git/config"
 
 cat >> .git/config << EOF
   [branch "zwei"] a = 1 [branch "vier"]
@@ -465,7 +465,7 @@ weird
 EOF
 
 test_expect_success "section was removed properly" \
-       "git diff -u expect .git/config"
+       "test_cmp expect .git/config"
 
 rm .git/config
 
index f366b53fb671a5ef52c34516bc4ab3869a142d8e..f98f4c51796e6f7a7181568a134e21ecd9dc2c4f 100755 (executable)
@@ -11,7 +11,7 @@ setup() {
 check() {
        echo "$2" >expected
        git config --get "$1" >actual
-       git diff actual expected
+       test_cmp actual expected
 }
 
 test_expect_success 'modify same key' '
index 762af5faf75562cd2a24197eae56357b1443737d..d24a47d1149061565822391542c044a7db193ce5 100755 (executable)
@@ -37,7 +37,7 @@ C?        option C with an optional argument
 Extras
 extra1    line above used to cause a segfault but no longer does
 EOF
-       git diff expect.err output.err
+       test_cmp expect.err output.err
 '
 
 test_done
index 55f057cebeb37a8ba8cd9c1e6aa5101c66988bcb..1caeacafa7ae70506e626498d274dbfa25f1b036 100755 (executable)
@@ -65,7 +65,7 @@ test_expect_success \
        --exclude-per-directory=.gitignore \
        --exclude-from=.git/ignore \
        >output &&
-     git diff expect output'
+     test_cmp expect output'
 
 # Test \r\n (MSDOS-like systems)
 printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore
@@ -77,7 +77,7 @@ test_expect_success \
        --exclude-per-directory=.gitignore \
        --exclude-from=.git/ignore \
        >output &&
-     git diff expect output'
+     test_cmp expect output'
 
 cat > excludes-file << EOF
 *.[1-8]
index 8687a01d2b169c1afafcd811d9108a85ad9fdd56..8704b04e1b4150357a7a01c91ac59bb1f22cbb8e 100755 (executable)
@@ -23,7 +23,7 @@ test_expect_success \
 test_expect_success \
     'git ls-files without path restriction.' \
     'git ls-files --others >output &&
-     git diff output - <<EOF
+     test_cmp output - <<EOF
 --
 -foo
 output
@@ -34,7 +34,7 @@ EOF
 test_expect_success \
     'git ls-files with path restriction.' \
     'git ls-files --others path0 >output &&
-       git diff output - <<EOF
+       test_cmp output - <<EOF
 path0
 EOF
 '
@@ -42,7 +42,7 @@ EOF
 test_expect_success \
     'git ls-files with path restriction with --.' \
     'git ls-files --others -- path0 >output &&
-       git diff output - <<EOF
+       test_cmp output - <<EOF
 path0
 EOF
 '
@@ -50,7 +50,7 @@ EOF
 test_expect_success \
     'git ls-files with path restriction with -- --.' \
     'git ls-files --others -- -- >output &&
-       git diff output - <<EOF
+       test_cmp output - <<EOF
 --
 EOF
 '
@@ -58,7 +58,7 @@ EOF
 test_expect_success \
     'git ls-files with no path restriction.' \
     'git ls-files --others -- >output &&
-       git diff output - <<EOF
+       test_cmp output - <<EOF
 --
 -foo
 output
index 607f57ff941b7da5296ab58cbf5e30db66087669..aff360303ae2a304bff4799def6906defdb85843 100755 (executable)
@@ -43,7 +43,7 @@ test_expect_success 'setup 1' '
                echo "100644 $o0 0      c"
                echo "100644 $o1 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'setup 2' '
@@ -61,7 +61,7 @@ test_expect_success 'setup 2' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual &&
+       test_cmp expected actual &&
 
        echo goodbye >>a &&
        o2=$(git hash-object a) &&
@@ -82,7 +82,7 @@ test_expect_success 'setup 2' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'setup 3' '
@@ -100,7 +100,7 @@ test_expect_success 'setup 3' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual &&
+       test_cmp expected actual &&
 
        rm -f b && mkdir b && echo df-1 >b/c && git add b/c &&
        o3=$(git hash-object b/c) &&
@@ -119,7 +119,7 @@ test_expect_success 'setup 3' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'setup 4' '
@@ -137,7 +137,7 @@ test_expect_success 'setup 4' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual &&
+       test_cmp expected actual &&
 
        rm -f a && mkdir a && echo df-2 >a/c && git add a/c &&
        o4=$(git hash-object a/c) &&
@@ -156,7 +156,7 @@ test_expect_success 'setup 4' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'setup 5' '
@@ -174,7 +174,7 @@ test_expect_success 'setup 5' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual &&
+       test_cmp expected actual &&
 
        rm -f b &&
        echo remove-conflict >a &&
@@ -195,7 +195,7 @@ test_expect_success 'setup 5' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
@@ -214,7 +214,7 @@ test_expect_success 'setup 6' '
                echo "100644 $o0 0      c"
                echo "100644 $o0 0      d/e"
        ) >expected &&
-       git diff -u expected actual &&
+       test_cmp expected actual &&
 
        rm -fr d && echo df-3 >d && git add d &&
        o6=$(git hash-object d) &&
@@ -233,7 +233,7 @@ test_expect_success 'setup 6' '
                echo "100644 $o0 0      c"
                echo "100644 $o6 0      d"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'merge-recursive simple' '
@@ -265,7 +265,7 @@ test_expect_success 'merge-recursive result' '
                echo "100644 $o0 0      c"
                echo "100644 $o1 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
@@ -297,7 +297,7 @@ test_expect_success 'merge-recursive remove conflict' '
                echo "100644 $o0 0      c"
                echo "100644 $o1 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
@@ -318,7 +318,7 @@ test_expect_success 'merge-recursive result' '
                echo "100644 $o0 0      c"
                echo "100644 $o1 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
@@ -352,7 +352,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
                echo "100644 $o0 0      c"
                echo "100644 $o1 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
@@ -386,7 +386,7 @@ test_expect_success 'merge-recursive d/f conflict result the other way' '
                echo "100644 $o0 0      c"
                echo "100644 $o1 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
@@ -420,7 +420,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
                echo "100644 $o0 1      d/e"
                echo "100644 $o1 2      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
@@ -454,7 +454,7 @@ test_expect_success 'merge-recursive d/f conflict result' '
                echo "100644 $o0 1      d/e"
                echo "100644 $o1 3      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
@@ -480,7 +480,7 @@ test_expect_success 'reset and bind merge' '
                echo "100644 $o0 0      c"
                echo "100644 $o1 0      d/e"
        ) >expected &&
-       git diff -u expected actual &&
+       test_cmp expected actual &&
 
        git read-tree --prefix=a1/ master &&
        git ls-files -s >actual &&
@@ -498,7 +498,7 @@ test_expect_success 'reset and bind merge' '
                echo "100644 $o0 0      c"
                echo "100644 $o1 0      d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
        git read-tree --prefix=z/ master &&
        git ls-files -s >actual &&
@@ -520,7 +520,7 @@ test_expect_success 'reset and bind merge' '
                echo "100644 $o0 0      z/c"
                echo "100644 $o1 0      z/d/e"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 
 '
 
index 79b9f23654d1983966091bae0f42e7d8d3c7a621..f6973e96a59916c6048222bfa0064aec5dea3746 100755 (executable)
@@ -24,7 +24,7 @@ test_expect_success 'create subprojects' \
     git add sub2 &&
     git commit -q -m "subprojects added" &&
     git diff-tree --abbrev=5 HEAD^ HEAD |cut -d" " -f-3,5- >current &&
-    git diff expected current'
+    test_cmp expected current'
 
 git branch save HEAD
 
@@ -62,7 +62,7 @@ test_expect_success 'check if clone works' \
     'git ls-files -s >expected &&
     git clone -l -s . cloned &&
     ( cd cloned && git ls-files -s ) >current &&
-    git diff expected current'
+    test_cmp expected current'
 
 test_expect_success 'removing and adding subproject' \
     'git update-index --force-remove -- sub2 &&
index 46427e3f365ad0ec09c432f8cedf2106afe4dc08..6e6a2542a22712006ae23874069c55943a3cba27 100755 (executable)
@@ -35,7 +35,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 test_output () {
     sed -e "s/ $_x40   / X     /" <current >check
-    git diff expected check
+    test_cmp expected check
 }
 
 test_expect_success \
index 70f9ce9d52827cb35fee7ac0f13471023291d1fa..4dd7d12bac62eae23516686c0ece0edf037f0317 100755 (executable)
@@ -43,7 +43,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
 _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 test_output () {
     sed -e "s/ $_x40   / X     /" <current >check
-    git diff expected check
+    test_cmp expected check
 }
 
 test_expect_success \
index 24a00a9df13b0781700f24e6a8e75505696a11dd..0574ef1f101df172a30755726b0ea1b6c2ef5f7d 100755 (executable)
@@ -35,7 +35,7 @@ no-funny' >expected
 test_expect_success 'git ls-files no-funny' \
        'git update-index --add "$p0" "$p2" &&
        git ls-files >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 t0=`git write-tree`
 echo "$t0" >t0
@@ -48,14 +48,14 @@ EOF
 test_expect_success 'git ls-files with-funny' \
        'git update-index --add "$p1" &&
        git ls-files >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 echo 'just space
 no-funny
 tabs   ," (dq) and spaces' >expected
 test_expect_success 'git ls-files -z with-funny' \
        'git ls-files -z | perl -pe y/\\000/\\012/ >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 t1=`git write-tree`
 echo "$t1" >t1
@@ -67,28 +67,28 @@ no-funny
 EOF
 test_expect_success 'git ls-tree with funny' \
        'git ls-tree -r $t1 | sed -e "s/^[^     ]*      //" >current &&
-        git diff expected current'
+        test_cmp expected current'
 
 cat > expected <<\EOF
 A      "tabs\t,\" (dq) and spaces"
 EOF
 test_expect_success 'git diff-index with-funny' \
        'git diff-index --name-status $t0 >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 test_expect_success 'git diff-tree with-funny' \
        'git diff-tree --name-status $t0 $t1 >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 echo 'A
 tabs   ," (dq) and spaces' >expected
 test_expect_success 'git diff-index -z with-funny' \
        'git diff-index -z --name-status $t0 | perl -pe y/\\000/\\012/ >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 test_expect_success 'git diff-tree -z with-funny' \
        'git diff-tree -z --name-status $t0 $t1 | perl -pe y/\\000/\\012/ >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 cat > expected <<\EOF
 CNUM   no-funny        "tabs\t,\" (dq) and spaces"
@@ -96,7 +96,7 @@ EOF
 test_expect_success 'git diff-tree -C with-funny' \
        'git diff-tree -C --find-copies-harder --name-status \
                $t0 $t1 | sed -e 's/^C[0-9]*/CNUM/' >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 cat > expected <<\EOF
 RNUM   no-funny        "tabs\t,\" (dq) and spaces"
@@ -105,7 +105,7 @@ test_expect_success 'git diff-tree delete with-funny' \
        'git update-index --force-remove "$p0" &&
        git diff-index -M --name-status \
                $t0 | sed -e 's/^R[0-9]*/RNUM/' >current &&
-       git diff expected current'
+       test_cmp expected current'
 
 cat > expected <<\EOF
 diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
@@ -116,7 +116,7 @@ EOF
 test_expect_success 'git diff-tree delete with-funny' \
        'git diff-index -M -p $t0 |
         sed -e "s/index [0-9]*%/index NUM%/" >current &&
-        git diff expected current'
+        test_cmp expected current'
 
 chmod +x "$p1"
 cat > expected <<\EOF
@@ -130,7 +130,7 @@ EOF
 test_expect_success 'git diff-tree delete with-funny' \
        'git diff-index -M -p $t0 |
         sed -e "s/index [0-9]*%/index NUM%/" >current &&
-        git diff expected current'
+        test_cmp expected current'
 
 cat >expected <<\EOF
  "tabs\t,\" (dq) and spaces"
@@ -139,7 +139,7 @@ EOF
 test_expect_success 'git diff-tree rename with-funny applied' \
        'git diff-index -M -p $t0 |
         git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
-        git diff expected current'
+        test_cmp expected current'
 
 cat > expected <<\EOF
  no-funny
@@ -149,12 +149,12 @@ EOF
 test_expect_success 'git diff-tree delete with-funny applied' \
        'git diff-index -p $t0 |
         git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
-        git diff expected current'
+        test_cmp expected current'
 
 test_expect_success 'git apply non-git diff' \
        'git diff-index -p $t0 |
         sed -ne "/^[-+@]/p" |
         git apply --stat | sed -e "s/|.*//" -e "s/ *\$//" >current &&
-        git diff expected current'
+        test_cmp expected current'
 
 test_done
index 94b1c24b0a3629a6b06466186006a526bb9b4d9d..883281dbd6c02ea7b2d90336c2629eafacee0257 100755 (executable)
@@ -9,7 +9,7 @@ test_description='commit and log output encodings'
 
 compare_with () {
        git show -s $1 | sed -e '1,/^$/d' -e 's/^    //' >current &&
-       git diff current "$2"
+       test_cmp current "$2"
 }
 
 test_expect_success setup '
index ab5406dd9f241edee7a6067a1426f0a65076eb10..4e92fce1d00a55cfbc39e55b53f95cc309e96ff2 100755 (executable)
@@ -38,6 +38,6 @@ echo ":100644 100755 X X M    rezrov" >expected
 
 test_expect_success \
     'verify' \
-    'git diff expected check'
+    'test_cmp expected check'
 
 test_done
index 6b4d1c52bbf1e3edf01dd67794bf221effc581a7..9337b81064bbdbe4e7f590830b458c48226c4a17 100755 (executable)
@@ -112,7 +112,7 @@ do
                } >"$actual" &&
                if test -f "$expect"
                then
-                       git diff "$expect" "$actual" &&
+                       test_cmp "$expect" "$actual" &&
                        rm -f "$actual"
                else
                        # this is to help developing new tests.
@@ -257,6 +257,7 @@ diff --patch-with-raw initial..side
 diff --patch-with-stat -r initial..side
 diff --patch-with-raw -r initial..side
 diff --name-status dir2 dir
+diff --no-index --name-status dir2 dir
 EOF
 
 test_done
index ef7fdb73356ad95f62412055c7d8c6b64758308d..d0d96aaa91eec7f5a6cb833e43bbd3ec89efad98 100644 (file)
@@ -1,3 +1,2 @@
 $ git diff --name-status dir2 dir
-A      dir/sub
 $
diff --git a/t/t4013/diff.diff_--no-index_--name-status_dir2_dir b/t/t4013/diff.diff_--no-index_--name-status_dir2_dir
new file mode 100644 (file)
index 0000000..6a47584
--- /dev/null
@@ -0,0 +1,3 @@
+$ git diff --no-index --name-status dir2 dir
+A      dir/sub
+$
index b2b7a8db859fe7f5d8c74fb27b77e4eba583ebc4..3583e68e92148a5145b82f93ec8a52fd4bb7f200 100755 (executable)
@@ -226,7 +226,7 @@ test_expect_success 'shortlog of cover-letter wraps overly-long onelines' '
 
        git format-patch --cover-letter -2 &&
        sed -e "1,/A U Thor/d" -e "/^$/q" < 0000-cover-letter.patch > output &&
-       git diff expect output
+       test_cmp expect output
 
 '
 
index 83c54b747f4efe1f99b67284a7ba72b89df07a6d..ca0302f41b332df053baa72362099ba691f2ff97 100755 (executable)
@@ -43,13 +43,13 @@ index adf3937..6edc172 100644
 EOF
 
 git diff > out
-test_expect_success "Ray's example without options" 'git diff expect out'
+test_expect_success "Ray's example without options" 'test_cmp expect out'
 
 git diff -w > out
-test_expect_success "Ray's example with -w" 'git diff expect out'
+test_expect_success "Ray's example with -w" 'test_cmp expect out'
 
 git diff -b > out
-test_expect_success "Ray's example with -b" 'git diff expect out'
+test_expect_success "Ray's example with -b" 'test_cmp expect out'
 
 tr 'Q' '\015' << EOF > x
 whitespace at beginning
@@ -90,14 +90,14 @@ index d99af23..8b32fb5 100644
 +CR at end
 EOF
 git diff > out
-test_expect_success 'another test, without options' 'git diff expect out'
+test_expect_success 'another test, without options' 'test_cmp expect out'
 
 cat << EOF > expect
 diff --git a/x b/x
 index d99af23..8b32fb5 100644
 EOF
 git diff -w > out
-test_expect_success 'another test, with -w' 'git diff expect out'
+test_expect_success 'another test, with -w' 'test_cmp expect out'
 
 tr 'Q' '\015' << EOF > expect
 diff --git a/x b/x
@@ -115,7 +115,7 @@ index d99af23..8b32fb5 100644
  CR at endQ
 EOF
 git diff -b > out
-test_expect_success 'another test, with -b' 'git diff expect out'
+test_expect_success 'another test, with -b' 'test_cmp expect out'
 
 test_expect_success 'check mixed spaces and tabs in indent' '
 
index 5dbdc0c9faf81ea95939fec0c285b2020e07a8d9..0950250c9be7f7833b7542f5491a4dad8f5ef82e 100755 (executable)
@@ -49,7 +49,7 @@ cat >expect <<\EOF
 EOF
 test_expect_success 'git diff --summary -M HEAD' '
        git diff --summary -M HEAD >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >expect <<\EOF
@@ -64,7 +64,7 @@ cat >expect <<\EOF
 EOF
 test_expect_success 'git diff --stat -M HEAD' '
        git diff --stat -M HEAD >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_done
index f9db81d3abae824f1f34faeeec537c5607e8ebad..6d3ef6c60bd5a26e2ed4d533fc4db7711bb92cfb 100755 (executable)
@@ -33,13 +33,13 @@ EOF
 sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
 
 test_expect_success 'default behaviour' '
-       git diff Beer.java Beer-correct.java |
+       git diff --no-index Beer.java Beer-correct.java |
        grep "^@@.*@@ public class Beer"
 '
 
 test_expect_success 'preset java pattern' '
        echo "*.java diff=java" >.gitattributes &&
-       git diff Beer.java Beer-correct.java |
+       git diff --no-index Beer.java Beer-correct.java |
        grep "^@@.*@@ public static void main("
 '
 
@@ -48,13 +48,13 @@ git config diff.java.funcname '!static
 [^     ].*s.*'
 
 test_expect_success 'custom pattern' '
-       git diff Beer.java Beer-correct.java |
+       git diff --no-index Beer.java Beer-correct.java |
        grep "^@@.*@@ int special;$"
 '
 
 test_expect_success 'last regexp must not be negated' '
        git config diff.java.funcname "!static" &&
-       ! git diff Beer.java Beer-correct.java
+       ! git diff --no-index Beer.java Beer-correct.java
 '
 
 test_done
index 435f65b370e8855c4aca6adfbf12c098338f3b45..8073a5a1f23ebb76cb1273c80d1e031a03a03ed8 100755 (executable)
@@ -11,36 +11,36 @@ test_description='git apply --stat --summary test.
 test_expect_success \
     'rename' \
     'git apply --stat --summary <../t4100/t-apply-1.patch >current &&
-    git diff ../t4100/t-apply-1.expect current'
+    test_cmp ../t4100/t-apply-1.expect current'
 
 test_expect_success \
     'copy' \
     'git apply --stat --summary <../t4100/t-apply-2.patch >current &&
-    git diff ../t4100/t-apply-2.expect current'
+    test_cmp ../t4100/t-apply-2.expect current'
 
 test_expect_success \
     'rewrite' \
     'git apply --stat --summary <../t4100/t-apply-3.patch >current &&
-    git diff ../t4100/t-apply-3.expect current'
+    test_cmp ../t4100/t-apply-3.expect current'
 
 test_expect_success \
     'mode' \
     'git apply --stat --summary <../t4100/t-apply-4.patch >current &&
-    git diff ../t4100/t-apply-4.expect current'
+    test_cmp ../t4100/t-apply-4.expect current'
 
 test_expect_success \
     'non git' \
     'git apply --stat --summary <../t4100/t-apply-5.patch >current &&
-    git diff ../t4100/t-apply-5.expect current'
+    test_cmp ../t4100/t-apply-5.expect current'
 
 test_expect_success \
     'non git' \
     'git apply --stat --summary <../t4100/t-apply-6.patch >current &&
-    git diff ../t4100/t-apply-6.expect current'
+    test_cmp ../t4100/t-apply-6.expect current'
 
 test_expect_success \
     'non git' \
     'git apply --stat --summary <../t4100/t-apply-7.patch >current &&
-    git diff ../t4100/t-apply-7.expect current'
+    test_cmp ../t4100/t-apply-7.expect current'
 
 test_done
index 43943ab8ca181edbdcc6a68d208cf584b5cda86d..e7e2913de745cc9f7639103757933f6238fdd564 100755 (executable)
@@ -90,7 +90,7 @@ do
                                cat '"$kind-patch.$with"'
                                (exit 1)
                        } &&
-                       git diff '"$kind"'-expect victim
+                       test_cmp '"$kind"'-expect victim
                '
        done
 done
@@ -108,7 +108,7 @@ do
                        cat '"$kind-ng.without"'
                        (exit 1)
                } &&
-               git diff '"$kind"'-expect victim
+               test_cmp '"$kind"'-expect victim
        '
 done
 
index a07ff42c2ff8e9a918d83435043a73f6404a9a9e..9ace578f17a07aafc050ccaf935aef8a4a3cab4e 100755 (executable)
@@ -33,7 +33,7 @@ test_expect_success 'apply symlink patch' '
        git checkout side &&
        git apply patch &&
        git diff-files -p >patched &&
-       git diff patch patched
+       test_cmp patch patched
 
 '
 
@@ -42,7 +42,7 @@ test_expect_success 'apply --index symlink patch' '
        git checkout -f side &&
        git apply --index patch &&
        git diff-index --cached -p HEAD >patched &&
-       git diff patch patched
+       test_cmp patch patched
 
 '
 
index c3f45790076e8e5f80322ad272dc4bf1ff4b9715..1459a90716c909cf4e0497e452eab3398ba05b83 100755 (executable)
@@ -42,7 +42,7 @@ test_expect_success 'apply in reverse' '
        git reset --hard second &&
        git apply --reverse --binary --index patch &&
        git diff >diff &&
-       git diff /dev/null diff
+       test_cmp /dev/null diff
 
 '
 
index 659e17c92e474ad5828656f83d28cab2a5ecac64..e9ccd161ee96a5bdbb4bf77de406ea51dacfb5de 100755 (executable)
@@ -54,7 +54,7 @@ test_expect_success 'apply without --reject should fail' '
                exit 1
        fi
 
-       git diff file1 saved.file1
+       test_cmp file1 saved.file1
 '
 
 test_expect_success 'apply without --reject should fail' '
@@ -65,7 +65,7 @@ test_expect_success 'apply without --reject should fail' '
                exit 1
        fi
 
-       git diff file1 saved.file1
+       test_cmp file1 saved.file1
 '
 
 test_expect_success 'apply with --reject should fail but update the file' '
@@ -79,7 +79,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
                exit 1
        fi
 
-       git diff file1 expected &&
+       test_cmp file1 expected &&
 
        cat file1.rej &&
 
@@ -105,7 +105,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
                echo "file1 still exists?"
                exit 1
        }
-       git diff file2 expected &&
+       test_cmp file2 expected &&
 
        cat file2.rej &&
 
@@ -132,7 +132,7 @@ test_expect_success 'the same test with --verbose' '
                echo "file1 still exists?"
                exit 1
        }
-       git diff file2 expected &&
+       test_cmp file2 expected &&
 
        cat file2.rej &&
 
@@ -151,7 +151,7 @@ test_expect_success 'apply cleanly with --verbose' '
 
        git apply --verbose patch.1 &&
 
-       git diff file1 clean
+       test_cmp file1 clean
 '
 
 test_done
index 1d531caf798b9e8dfbe17714ad1eb09be14f7f93..f92e259cc6f251ec6f89edee3fc16720f264d82f 100755 (executable)
@@ -38,7 +38,7 @@ test_expect_success 'apply --numstat' '
                echo "0 1       file1" &&
                echo "0 1       file2"
        } >expect &&
-       git diff expect actual
+       test_cmp expect actual
 
 '
 
@@ -48,8 +48,8 @@ test_expect_success 'apply --apply' '
        cat file2.orig >file2 &&
        git update-index file1 file2 &&
        git apply --index diff.output &&
-       git diff file1.mods file1 &&
-       git diff file2.mods file2
+       test_cmp file1.mods file1 &&
+       test_cmp file2.mods file2
 '
 
 test_done
index 3cbfee704e6238eb31fa1b519567fb064ca27ad8..85d7e3edcd04be761167ca87cb39a1597908201e 100755 (executable)
@@ -101,7 +101,7 @@ cat > expect << EOF
 EOF
 git rerere diff > out
 
-test_expect_success 'rerere diff' 'git diff expect out'
+test_expect_success 'rerere diff' 'test_cmp expect out'
 
 cat > expect << EOF
 a1
@@ -109,7 +109,7 @@ EOF
 
 git rerere status > out
 
-test_expect_success 'rerere status' 'git diff expect out'
+test_expect_success 'rerere status' 'test_cmp expect out'
 
 test_expect_success 'commit succeeds' \
        "git commit -q -a -m 'prefer first over second'"
@@ -126,7 +126,7 @@ test_expect_success 'another conflicting merge' '
 git show first:a1 | sed 's/To die: t/To die! T/' > expect
 test_expect_success 'rerere kicked in' "! grep ======= a1"
 
-test_expect_success 'rerere prefers first change' 'git diff a1 expect'
+test_expect_success 'rerere prefers first change' 'test_cmp a1 expect'
 
 rm $rr/postimage
 echo "$sha1    a1" | perl -pe 'y/\012/\000/' > .git/rr-cache/MERGE_RR
index 0db27547ac9aa49c4b06ec371f6e04f5b9a7f16c..fb471a08c698b431cd2440e9d4f0e77e2fef6b08 100755 (executable)
@@ -50,7 +50,7 @@ test_expect_success 'check unpacked result (have commit, no tag)' '
                test_must_fail git cat-file -e $tag &&
                git rev-list --objects $commit
        ) >list.actual &&
-       git diff list.expect list.actual
+       test_cmp list.expect list.actual
 '
 
 rm -rf clone.git
@@ -78,7 +78,7 @@ test_expect_success 'check unpacked result (have commit, have tag)' '
                export GIT_DIR &&
                git rev-list --objects $tag
        ) >list.actual &&
-       git diff list.expect list.actual
+       test_cmp list.expect list.actual
 '
 
 test_done
index 2b6b6e3f71613d807aa4ebfa48eebe5f73d2b980..68c2ae688c2b7ff96ec927622f92fd512e7beefe 100755 (executable)
@@ -110,7 +110,7 @@ test_expect_success \
        cd .. &&
        git update-ref refs/heads/master master^ || return 1
        git-send-pack --force ./victim/.git/ master && return 1
-       ! git diff .git/refs/heads/master victim/.git/refs/heads/master
+       ! test_cmp .git/refs/heads/master victim/.git/refs/heads/master
 '
 
 test_expect_success \
index 9a12024241aea21b6ebdbe692b2d7c173d4d2579..2fff3001530bdf3e6acc283042d432a0698cea03 100755 (executable)
@@ -83,23 +83,23 @@ test_expect_success 'hooks ran' '
 test_expect_success 'pre-receive hook input' '
        (echo $commit0 $commit1 refs/heads/master;
         echo $commit1 $commit0 refs/heads/tofail
-       ) | git diff - victim/.git/pre-receive.stdin
+       ) | test_cmp - victim/.git/pre-receive.stdin
 '
 
 test_expect_success 'update hook arguments' '
        (echo refs/heads/master $commit0 $commit1;
         echo refs/heads/tofail $commit1 $commit0
-       ) | git diff - victim/.git/update.args
+       ) | test_cmp - victim/.git/update.args
 '
 
 test_expect_success 'post-receive hook input' '
        echo $commit0 $commit1 refs/heads/master |
-       git diff - victim/.git/post-receive.stdin
+       test_cmp - victim/.git/post-receive.stdin
 '
 
 test_expect_success 'post-update hook arguments' '
        echo refs/heads/master |
-       git diff - victim/.git/post-update.args
+       test_cmp - victim/.git/post-update.args
 '
 
 test_expect_success 'all hook stdin is /dev/null' '
@@ -130,7 +130,7 @@ STDERR post-update
 EOF
 test_expect_success 'send-pack stderr contains hook messages' '
        grep ^STD send.err >actual &&
-       git diff - actual <expect
+       test_cmp - actual <expect
 '
 
 test_done
index 86e5b9bc269b3639a882c6652f4d1f66a45121f7..4074e23ffa2c7a93fdbd4a367e273118224b9038 100755 (executable)
@@ -50,7 +50,7 @@ test_expect_success 'fetch A (new commit : 1 connection)' '
        ) &&
        test -s $U &&
        cut -d" " -f1,2 $U >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_expect_success "create tag T on A, create C on branch cat" '
@@ -82,7 +82,7 @@ test_expect_success 'fetch C, T (new branch, tag : 1 connection)' '
        ) &&
        test -s $U &&
        cut -d" " -f1,2 $U >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_expect_success "create commits O, B, tag S on B" '
@@ -118,7 +118,7 @@ test_expect_success 'fetch B, S (commit and tag : 1 connection)' '
        ) &&
        test -s $U &&
        cut -d" " -f1,2 $U >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat - <<EOF >expect
@@ -144,7 +144,7 @@ test_expect_success 'new clone fetch master and tags' '
        ) &&
        test -s $U &&
        cut -d" " -f1,2 $U >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_done
index 48ff2d424d1587bde388422da874feb3d55cbf0d..a37b6f52135fcd8f02cc7290568756b9067c5ec7 100755 (executable)
@@ -135,7 +135,7 @@ test_expect_success 'show' '
         git config --add remote.origin.push \
                +refs/tags/lastbackup &&
         git remote show origin > output &&
-        git diff expect output)
+        test_cmp expect output)
 '
 
 test_expect_success 'prune' '
@@ -179,7 +179,7 @@ test_expect_success 'update' '
         git remote add apis ../mirror &&
         git remote update &&
         git branch -r > output &&
-        git diff expect output)
+        test_cmp expect output)
 
 '
 
@@ -206,7 +206,7 @@ test_expect_success 'update with arguments' '
         git config remotes.titanus manduca &&
         git remote update phobaeticus titanus &&
         git branch -r > output &&
-        git diff expect output)
+        test_cmp expect output)
 
 '
 
@@ -229,7 +229,7 @@ test_expect_success 'update default' '
         git config remote.drosophila.skipDefaultUpdate true &&
         git remote update default &&
         git branch -r > output &&
-        git diff expect output)
+        test_cmp expect output)
 
 '
 
@@ -249,7 +249,7 @@ test_expect_success 'update default (overridden, with funny whitespace)' '
         git config remotes.default "$(printf "\t drosophila  \n")" &&
         git remote update default &&
         git branch -r > output &&
-        git diff expect output)
+        test_cmp expect output)
 
 '
 
index 65c37744aaa074d173afb862ca43fa668bc19452..3def75eeb29f0eeaa096ab4b9f4511a01a3ce3d8 100755 (executable)
@@ -151,7 +151,7 @@ do
                git show-ref >"$actual_r" &&
                if test -f "$expect_f"
                then
-                       git diff -u "$expect_f" "$actual_f" &&
+                       test_cmp "$expect_f" "$actual_f" &&
                        rm -f "$actual_f"
                else
                        # this is to help developing new tests.
@@ -160,7 +160,7 @@ do
                fi &&
                if test -f "$expect_r"
                then
-                       git diff -u "$expect_r" "$actual_r" &&
+                       test_cmp "$expect_r" "$actual_r" &&
                        rm -f "$actual_r"
                else
                        # this is to help developing new tests.
index 0dc915ea67b21d07d8e4dca44767906e05ad2278..9176484db2f78122f71c0f11889e01382effcfb9 100755 (executable)
@@ -15,7 +15,7 @@ test_format() {
        cat >expect.$1
        test_expect_success "format $1" "
 git rev-list --pretty=format:$2 master >output.$1 &&
-git diff expect.$1 output.$1
+test_cmp expect.$1 output.$1
 "
 }
 
index 79dc58b2ce962ea133c4796d0dff66eb9684b48a..74e9e6618e5b104c6d7e0731fd2772c0b95eefab 100755 (executable)
@@ -63,7 +63,7 @@ test_expect_success "merge without conflict (missing LF at EOF)" \
        "git merge-file test2.txt orig.txt new2.txt"
 
 test_expect_success "merge result added missing LF" \
-       "git diff test.txt test2.txt"
+       "test_cmp test.txt test2.txt"
 
 cp test.txt backup.txt
 test_expect_success "merge with conflicts" \
@@ -86,7 +86,7 @@ non timebo mala, quoniam tu mecum es:
 virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
-test_expect_success "expected conflict markers" "git diff test.txt expect.txt"
+test_expect_success "expected conflict markers" "test_cmp test.txt expect.txt"
 
 cp backup.txt test.txt
 test_expect_success "merge with conflicts, using -L" \
@@ -110,7 +110,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
 EOF
 
 test_expect_success "expected conflict markers, with -L" \
-       "git diff test.txt expect.txt"
+       "test_cmp test.txt expect.txt"
 
 sed "s/ tu / TU /" < new1.txt > new5.txt
 test_expect_success "conflict in removed tail" \
@@ -132,7 +132,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
 >>>>>>> new5.txt
 EOF
 
-test_expect_success "expected conflict markers" "git diff expect out"
+test_expect_success "expected conflict markers" "test_cmp expect out"
 
 test_expect_success 'binary files cannot be merged' '
        ! git merge-file -p orig.txt ../test4012.png new1.txt 2> merge.err &&
index 23d24d3feb9d1f3b5875771639a8e6d991d5ed76..6a6a13002d3dc66c043a43df910a79940b178da4 100755 (executable)
@@ -70,7 +70,7 @@ G
 >>>>>>> G:a1
 EOF
 
-test_expect_success "result contains a conflict" "git diff expect a1"
+test_expect_success "result contains a conflict" "test_cmp expect a1"
 
 git ls-files --stage > out
 cat > expect << EOF
@@ -79,7 +79,7 @@ cat > expect << EOF
 100644 fd7923529855d0b274795ae3349c5e0438333979 3      a1
 EOF
 
-test_expect_success "virtual trees were processed" "git diff expect out"
+test_expect_success "virtual trees were processed" "test_cmp expect out"
 
 test_expect_success 'refuse to merge binary files' '
        git reset --hard &&
index 43f5459c35dd862b2b15b9883a4f2354a20e8e25..5bbfa44e8d9ee3eebb18eb07e93380c802741a18 100755 (executable)
@@ -57,7 +57,7 @@ test_expect_success 'initial merge' '
                echo "100644 $o1 0      git-gui/git-gui.sh"
                echo "100644 $o2 0      git.c"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'merge update' '
@@ -73,7 +73,7 @@ test_expect_success 'merge update' '
                echo "100644 $o3 0      git-gui/git-gui.sh"
                echo "100644 $o2 0      git.c"
        ) >expected &&
-       git diff -u expected actual
+       test_cmp expected actual
 '
 
 test_done
index 56bbd8519d69a1fc31293f30eb3c8a7b20a285cc..ea476a2582c87b48ea5e8925a275184e8671391e 100755 (executable)
@@ -108,7 +108,7 @@ warning: tag 'A' is really 'Q' here
 EOF
 check_describe A-* HEAD
 test_expect_success 'warning was displayed for Q' '
-       git diff err.expect err.actual
+       test_cmp err.expect err.actual
 '
 test_expect_success 'rename tag Q back to A' '
        mv .git/refs/tags/Q .git/refs/tags/A
index c9bf6fdba3c3495b5215394d568fd8ac5b4f6daf..bc74349416d858834c43f6c648daa95c8b9f3a7a 100755 (executable)
@@ -79,7 +79,7 @@ test_expect_success 'merge-msg test #1' '
        git fetch . left &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-       git diff actual expected
+       test_cmp expected actual
 '
 
 cat >expected <<EOF
@@ -92,7 +92,7 @@ test_expect_success 'merge-msg test #2' '
        git fetch ../"$test" left &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-       git diff actual expected
+       test_cmp expected actual
 '
 
 cat >expected <<\EOF
@@ -117,7 +117,7 @@ test_expect_success 'merge-msg test #3-1' '
        git fetch . left &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-       git diff actual expected
+       test_cmp expected actual
 '
 
 test_expect_success 'merge-msg test #3-2' '
@@ -131,7 +131,7 @@ test_expect_success 'merge-msg test #3-2' '
        git fetch . left &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-       git diff actual expected
+       test_cmp expected actual
 '
 
 cat >expected <<\EOF
@@ -163,7 +163,7 @@ test_expect_success 'merge-msg test #4-1' '
        git fetch . left right &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-       git diff actual expected
+       test_cmp expected actual
 '
 
 test_expect_success 'merge-msg test #4-2' '
@@ -177,7 +177,7 @@ test_expect_success 'merge-msg test #4-2' '
        git fetch . left right &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-       git diff actual expected
+       test_cmp expected actual
 '
 
 test_expect_success 'merge-msg test #5-1' '
@@ -191,7 +191,7 @@ test_expect_success 'merge-msg test #5-1' '
        git fetch . left right &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-       git diff actual expected
+       test_cmp expected actual
 '
 
 test_expect_success 'merge-msg test #5-2' '
@@ -205,7 +205,7 @@ test_expect_success 'merge-msg test #5-2' '
        git fetch . left right &&
 
        git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-       git diff actual expected
+       test_cmp expected actual
 '
 
 test_done
index f46ec93c83d990c0887d3ff9d59f9d365b4d5eed..91ea85d99bc9ba306a9616b67903863d4379634d 100755 (executable)
@@ -75,14 +75,14 @@ EOF
 test_expect_success 'Check unformatted date fields output' '
        (git for-each-ref --shell --format="%(refname) %(committerdate) %(authordate)" refs/heads &&
        git for-each-ref --shell --format="%(refname) %(taggerdate)" refs/tags) >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'Check format "default" formatted date fields output' '
        f=default &&
        (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
        git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 # Don't know how to do relative check because I can't know when this script
@@ -109,7 +109,7 @@ test_expect_success 'Check format "short" date fields output' '
        f=short &&
        (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
        git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 cat >expected <<\EOF
@@ -121,7 +121,7 @@ test_expect_success 'Check format "local" date fields output' '
        f=local &&
        (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
        git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 cat >expected <<\EOF
@@ -133,7 +133,7 @@ test_expect_success 'Check format "iso8601" date fields output' '
        f=iso8601 &&
        (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
        git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 cat >expected <<\EOF
@@ -145,7 +145,7 @@ test_expect_success 'Check format "rfc2822" date fields output' '
        f=rfc2822 &&
        (git for-each-ref --shell --format="%(refname) %(committerdate:$f) %(authordate:$f)" refs/heads &&
        git for-each-ref --shell --format="%(refname) %(taggerdate:$f)" refs/tags) >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 cat >expected <<\EOF
@@ -155,7 +155,7 @@ EOF
 
 test_expect_success 'Verify ascending sort' '
        git-for-each-ref --format="%(refname)" --sort=refname >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 
@@ -166,7 +166,7 @@ EOF
 
 test_expect_success 'Verify descending sort' '
        git-for-each-ref --format="%(refname)" --sort=-refname >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 cat >expected <<\EOF
@@ -176,17 +176,17 @@ EOF
 
 test_expect_success 'Quoting style: shell' '
        git for-each-ref --shell --format="%(refname)" >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'Quoting style: perl' '
        git for-each-ref --perl --format="%(refname)" >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 test_expect_success 'Quoting style: python' '
        git for-each-ref --python --format="%(refname)" >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 cat >expected <<\EOF
@@ -196,7 +196,7 @@ EOF
 
 test_expect_success 'Quoting style: tcl' '
        git for-each-ref --tcl --format="%(refname)" >actual &&
-       git diff expected actual
+       test_cmp expected actual
 '
 
 for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
index 1639c7aa9624bf3219afd021daf14c6f07dcfc32..1e8a205e536c918569d6537883ee35d3bdcd515f 100755 (executable)
@@ -224,7 +224,7 @@ test_expect_success 'Tag name filtering retains tag message' '
        git cat-file tag T > expect &&
        git filter-branch -f --tag-name-filter cat &&
        git cat-file tag T > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 faux_gpg_tag='object XXXXXX
@@ -248,7 +248,7 @@ test_expect_success 'Tag name filtering strips gpg signature' '
        echo "$faux_gpg_tag" | sed -e s/XXXXXX/$sha1/ | head -n 6 > expect &&
        git filter-branch -f --tag-name-filter cat &&
        git cat-file tag S > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_done
index 2dcee7ccc572bbc9b239ff805aede076ff926f49..241c70dc66f71d9f53ddc6637e2f813020e740d6 100755 (executable)
@@ -116,9 +116,9 @@ mytag
 EOF
 test_expect_success \
        'trying to delete tags without params should succeed and do nothing' '
-       git tag -l > actual && git diff expect actual &&
+       git tag -l > actual && test_cmp expect actual &&
        git-tag -d &&
-       git tag -l > actual && git diff expect actual
+       git tag -l > actual && test_cmp expect actual
 '
 
 test_expect_success \
@@ -173,9 +173,9 @@ test_expect_success 'listing all tags should print them ordered' '
        git tag v1.0 &&
        git tag t210 &&
        git tag -l > actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git tag > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >expect <<EOF
@@ -186,7 +186,7 @@ EOF
 test_expect_success \
        'listing tags with substring as pattern must print those matching' '
        git-tag -l "*a*" > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >expect <<EOF
@@ -196,7 +196,7 @@ EOF
 test_expect_success \
        'listing tags with a suffix as pattern must print those matching' '
        git-tag -l "*.1" > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >expect <<EOF
@@ -206,7 +206,7 @@ EOF
 test_expect_success \
        'listing tags with a prefix as pattern must print those matching' '
        git-tag -l "t21*" > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >expect <<EOF
@@ -215,7 +215,7 @@ EOF
 test_expect_success \
        'listing tags using a name as pattern must print that one matching' '
        git-tag -l a1 > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >expect <<EOF
@@ -224,7 +224,7 @@ EOF
 test_expect_success \
        'listing tags using a name as pattern must print that one matching' '
        git-tag -l v1.0 > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >expect <<EOF
@@ -234,14 +234,14 @@ EOF
 test_expect_success \
        'listing tags with ? in the pattern should print those matching' '
        git-tag -l "v1.?.?" > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 >expect
 test_expect_success \
        'listing tags using v.* should print nothing because none have v.' '
        git-tag -l "v.*" > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >expect <<EOF
@@ -253,7 +253,7 @@ EOF
 test_expect_success \
        'listing tags using v* should print only those having v' '
        git-tag -l "v*" > actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 # creating and verifying lightweight tags:
@@ -302,7 +302,7 @@ test_expect_success \
        'creating an annotated tag with -m message should succeed' '
        git-tag -m "A message" annotated-tag &&
        get_tag_msg annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >msgfile <<EOF
@@ -315,7 +315,7 @@ test_expect_success \
        'creating an annotated tag with -F messagefile should succeed' '
        git-tag -F msgfile file-annotated-tag &&
        get_tag_msg file-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >inputmsg <<EOF
@@ -327,7 +327,7 @@ cat inputmsg >>expect
 test_expect_success 'creating an annotated tag with -F - should succeed' '
        git-tag -F - stdin-annotated-tag <inputmsg &&
        get_tag_msg stdin-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_expect_success \
@@ -358,7 +358,7 @@ test_expect_success \
        'creating a tag with an empty -m message should succeed' '
        git-tag -m "" empty-annotated-tag &&
        get_tag_msg empty-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 >emptyfile
@@ -367,7 +367,7 @@ test_expect_success \
        'creating a tag with an empty -F messagefile should succeed' '
        git-tag -F emptyfile emptyfile-annotated-tag &&
        get_tag_msg emptyfile-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 printf '\n\n  \n\t\nLeading blank lines\n' >blanksfile
@@ -388,7 +388,7 @@ test_expect_success \
        'extra blanks in the message for an annotated tag should be removed' '
        git-tag -F blanksfile blanks-annotated-tag &&
        get_tag_msg blanks-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 get_tag_header blank-annotated-tag $commit commit $time >expect
@@ -396,7 +396,7 @@ test_expect_success \
        'creating a tag with blank -m message with spaces should succeed' '
        git-tag -m "     " blank-annotated-tag &&
        get_tag_msg blank-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 echo '     ' >blankfile
@@ -407,7 +407,7 @@ test_expect_success \
        'creating a tag with blank -F messagefile with spaces should succeed' '
        git-tag -F blankfile blankfile-annotated-tag &&
        get_tag_msg blankfile-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 printf '      ' >blanknonlfile
@@ -416,7 +416,7 @@ test_expect_success \
        'creating a tag with -F file of spaces and no newline should succeed' '
        git-tag -F blanknonlfile blanknonlfile-annotated-tag &&
        get_tag_msg blanknonlfile-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 # messages with commented lines:
@@ -451,7 +451,7 @@ test_expect_success \
        'creating a tag using a -F messagefile with #comments should succeed' '
        git-tag -F commentsfile comments-annotated-tag &&
        get_tag_msg comments-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 get_tag_header comment-annotated-tag $commit commit $time >expect
@@ -459,7 +459,7 @@ test_expect_success \
        'creating a tag with a #comment in the -m message should succeed' '
        git-tag -m "#comment" comment-annotated-tag &&
        get_tag_msg comment-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 echo '#comment' >commentfile
@@ -470,7 +470,7 @@ test_expect_success \
        'creating a tag with #comments in the -F messagefile should succeed' '
        git-tag -F commentfile commentfile-annotated-tag &&
        get_tag_msg commentfile-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 printf '#comment' >commentnonlfile
@@ -479,7 +479,7 @@ test_expect_success \
        'creating a tag with a file of #comment and no newline should succeed' '
        git-tag -F commentnonlfile commentnonlfile-annotated-tag &&
        get_tag_msg commentnonlfile-annotated-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 # listing messages for annotated non-signed tags:
@@ -490,23 +490,23 @@ test_expect_success \
 
        echo "tag-one-line" >expect &&
        git-tag -l | grep "^tag-one-line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l | grep "^tag-one-line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l tag-one-line >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "tag-one-line    A msg" >expect &&
        git-tag -n1 -l | grep "^tag-one-line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n -l | grep "^tag-one-line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n1 -l tag-one-line >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n2 -l tag-one-line >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n999 -l tag-one-line >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_expect_success \
@@ -515,23 +515,23 @@ test_expect_success \
 
        echo "tag-zero-lines" >expect &&
        git-tag -l | grep "^tag-zero-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l | grep "^tag-zero-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l tag-zero-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "tag-zero-lines  " >expect &&
        git-tag -n1 -l | grep "^tag-zero-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n -l | grep "^tag-zero-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n1 -l tag-zero-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n2 -l tag-zero-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n999 -l tag-zero-lines >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 echo 'tag line one' >annotagmsg
@@ -543,39 +543,39 @@ test_expect_success \
 
        echo "tag-lines" >expect &&
        git-tag -l | grep "^tag-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l | grep "^tag-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l tag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "tag-lines       tag line one" >expect &&
        git-tag -n1 -l | grep "^tag-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n -l | grep "^tag-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n1 -l tag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "    tag line two" >>expect &&
        git-tag -n2 -l | grep "^ *tag.line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n2 -l tag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "    tag line three" >>expect &&
        git-tag -n3 -l | grep "^ *tag.line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n3 -l tag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n4 -l | grep "^ *tag.line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n4 -l tag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n99 -l | grep "^ *tag.line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n99 -l tag-lines >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 # subsequent tests require gpg; check if it is available
@@ -635,7 +635,7 @@ echo '-----BEGIN PGP SIGNATURE-----' >>expect
 test_expect_success 'creating a signed tag with -m message should succeed' '
        git-tag -s -m "A signed tag message" signed-tag &&
        get_tag_msg signed-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 get_tag_header u-signed-tag $commit commit $time >expect
@@ -645,7 +645,7 @@ test_expect_success 'sign with a given key id' '
 
        git tag -u committer@example.com -m "Another message" u-signed-tag &&
        get_tag_msg u-signed-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 
 '
 
@@ -675,7 +675,7 @@ echo '-----BEGIN PGP SIGNATURE-----' >>expect
 test_expect_success '-u implies signed tag' '
        GIT_EDITOR=./fakeeditor git-tag -u CDDE430D implied-sign &&
        get_tag_msg implied-sign >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >sigmsgfile <<EOF
@@ -689,7 +689,7 @@ test_expect_success \
        'creating a signed tag with -F messagefile should succeed' '
        git-tag -s -F sigmsgfile file-signed-tag &&
        get_tag_msg file-signed-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 cat >siginputmsg <<EOF
@@ -702,7 +702,7 @@ echo '-----BEGIN PGP SIGNATURE-----' >>expect
 test_expect_success 'creating a signed tag with -F - should succeed' '
        git-tag -s -F - stdin-signed-tag <siginputmsg &&
        get_tag_msg stdin-signed-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 get_tag_header implied-annotate $commit commit $time >expect
@@ -711,7 +711,7 @@ echo '-----BEGIN PGP SIGNATURE-----' >>expect
 test_expect_success '-s implies annotated tag' '
        GIT_EDITOR=./fakeeditor git-tag -s implied-annotate &&
        get_tag_msg implied-annotate >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_expect_success \
@@ -752,7 +752,7 @@ test_expect_success \
        'creating a signed tag with an empty -m message should succeed' '
        git-tag -s -m "" empty-signed-tag &&
        get_tag_msg empty-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v empty-signed-tag
 '
 
@@ -763,7 +763,7 @@ test_expect_success \
        'creating a signed tag with an empty -F messagefile should succeed' '
        git-tag -s -F sigemptyfile emptyfile-signed-tag &&
        get_tag_msg emptyfile-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v emptyfile-signed-tag
 '
 
@@ -786,7 +786,7 @@ test_expect_success \
        'extra blanks in the message for a signed tag should be removed' '
        git-tag -s -F sigblanksfile blanks-signed-tag &&
        get_tag_msg blanks-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v blanks-signed-tag
 '
 
@@ -796,7 +796,7 @@ test_expect_success \
        'creating a signed tag with a blank -m message should succeed' '
        git-tag -s -m "     " blank-signed-tag &&
        get_tag_msg blank-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v blank-signed-tag
 '
 
@@ -809,7 +809,7 @@ test_expect_success \
        'creating a signed tag with blank -F file with spaces should succeed' '
        git-tag -s -F sigblankfile blankfile-signed-tag &&
        get_tag_msg blankfile-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v blankfile-signed-tag
 '
 
@@ -820,7 +820,7 @@ test_expect_success \
        'creating a signed tag with spaces and no newline should succeed' '
        git-tag -s -F sigblanknonlfile blanknonlfile-signed-tag &&
        get_tag_msg blanknonlfile-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v signed-tag
 '
 
@@ -857,7 +857,7 @@ test_expect_success \
        'creating a signed tag with a -F file with #comments should succeed' '
        git-tag -s -F sigcommentsfile comments-signed-tag &&
        get_tag_msg comments-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v comments-signed-tag
 '
 
@@ -867,7 +867,7 @@ test_expect_success \
        'creating a signed tag with #commented -m message should succeed' '
        git-tag -s -m "#comment" comment-signed-tag &&
        get_tag_msg comment-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v comment-signed-tag
 '
 
@@ -880,7 +880,7 @@ test_expect_success \
        'creating a signed tag with #commented -F messagefile should succeed' '
        git-tag -s -F sigcommentfile commentfile-signed-tag &&
        get_tag_msg commentfile-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v commentfile-signed-tag
 '
 
@@ -891,7 +891,7 @@ test_expect_success \
        'creating a signed tag with a #comment and no newline should succeed' '
        git-tag -s -F sigcommentnonlfile commentnonlfile-signed-tag &&
        get_tag_msg commentnonlfile-signed-tag >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -v commentnonlfile-signed-tag
 '
 
@@ -903,23 +903,23 @@ test_expect_success \
 
        echo "stag-one-line" >expect &&
        git-tag -l | grep "^stag-one-line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l | grep "^stag-one-line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l stag-one-line >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "stag-one-line   A message line signed" >expect &&
        git-tag -n1 -l | grep "^stag-one-line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n -l | grep "^stag-one-line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n1 -l stag-one-line >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n2 -l stag-one-line >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n999 -l stag-one-line >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_expect_success \
@@ -928,23 +928,23 @@ test_expect_success \
 
        echo "stag-zero-lines" >expect &&
        git-tag -l | grep "^stag-zero-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l | grep "^stag-zero-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l stag-zero-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "stag-zero-lines " >expect &&
        git-tag -n1 -l | grep "^stag-zero-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n -l | grep "^stag-zero-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n1 -l stag-zero-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n2 -l stag-zero-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n999 -l stag-zero-lines >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 echo 'stag line one' >sigtagmsg
@@ -956,39 +956,39 @@ test_expect_success \
 
        echo "stag-lines" >expect &&
        git-tag -l | grep "^stag-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l | grep "^stag-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n0 -l stag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "stag-lines      stag line one" >expect &&
        git-tag -n1 -l | grep "^stag-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n -l | grep "^stag-lines" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n1 -l stag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "    stag line two" >>expect &&
        git-tag -n2 -l | grep "^ *stag.line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n2 -l stag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
 
        echo "    stag line three" >>expect &&
        git-tag -n3 -l | grep "^ *stag.line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n3 -l stag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n4 -l | grep "^ *stag.line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n4 -l stag-lines >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n99 -l | grep "^ *stag.line" >actual &&
-       git diff expect actual &&
+       test_cmp expect actual &&
        git-tag -n99 -l stag-lines >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 # tags pointing to objects different from commits:
@@ -1004,7 +1004,7 @@ test_expect_success \
        'creating a signed tag pointing to a tree should succeed' '
        git-tag -s -m "A message for a tree" tree-signed-tag HEAD^{tree} &&
        get_tag_msg tree-signed-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 get_tag_header blob-signed-tag $blob blob $time >expect
@@ -1014,7 +1014,7 @@ test_expect_success \
        'creating a signed tag pointing to a blob should succeed' '
        git-tag -s -m "A message for a blob" blob-signed-tag HEAD:foo &&
        get_tag_msg blob-signed-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 get_tag_header tag-signed-tag $tag tag $time >expect
@@ -1024,7 +1024,7 @@ test_expect_success \
        'creating a signed tag pointing to another tag should succeed' '
        git-tag -s -m "A message for another tag" tag-signed-tag signed-tag &&
        get_tag_msg tag-signed-tag >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 # try to sign with bad user.signingkey
@@ -1064,7 +1064,7 @@ test_expect_success \
        git tag -a -m "An annotation to be reused" reuse &&
        GIT_EDITOR=true git tag -f -a reuse &&
        get_tag_msg reuse >actual &&
-       git diff expect actual
+       test_cmp expect actual
 '
 
 test_done
index e5c9f30c73d4dbfe1fff6022bddfe6a387441a9b..39ba14148c953d17589450917975372802eecfed 100755 (executable)
@@ -34,13 +34,13 @@ test_expect_success 'creating initial files and commits' '
 
 check_changes () {
        test "$(git rev-parse HEAD)" = "$1" &&
-       git diff | git diff .diff_expect - &&
-       git diff --cached | git diff .cached_expect - &&
+       git diff | test_cmp .diff_expect - &&
+       git diff --cached | test_cmp .cached_expect - &&
        for FILE in *
        do
                echo $FILE':'
                cat $FILE || return
-       done | git diff .cat_expect -
+       done | test_cmp .cat_expect -
 }
 
 >.diff_expect
@@ -390,9 +390,9 @@ test_expect_success 'test --mixed <paths>' '
        git add file1 file3 file4 &&
        ! git reset HEAD -- file1 file2 file3 &&
        git diff > output &&
-       git diff output expect &&
+       test_cmp output expect &&
        git diff --cached > output &&
-       git diff output cached_expect
+       test_cmp output cached_expect
 '
 
 test_expect_success 'test resetting the index at give paths' '
@@ -425,7 +425,7 @@ EOF
 test_expect_success '--mixed refreshes the index' '
        echo 123 >> file2 &&
        git reset --mixed HEAD > output &&
-       git diff --exit-code expect output
+       test_cmp expect output
 '
 
 test_done
index e4bfcaece0c3ac4ea4b33521e84bd7fc1c19422e..80a438d4d988baa54a25e5725665904c6c45f431 100755 (executable)
@@ -63,7 +63,7 @@ EOF
 test_expect_success 'status (2)' '
 
        git status > output &&
-       git diff expect output
+       test_cmp expect output
 
 '
 
@@ -93,7 +93,7 @@ EOF
 test_expect_success 'status with relative paths' '
 
        (cd dir1 && git status) > output &&
-       git diff expect output
+       test_cmp expect output
 
 '
 
@@ -124,7 +124,7 @@ test_expect_success 'status without relative paths' '
 
        git config status.relativePaths false
        (cd dir1 && git status) > output &&
-       git diff expect output
+       test_cmp expect output
 
 '
 
index bdf29c17344051e5c65d61994744f5432ddf8ae3..242cdf092acdbfc88858de1dbcfe3c817a67a4c2 100755 (executable)
@@ -169,7 +169,7 @@ test_expect_success "$name" '
        svn up "$SVN_TREE" &&
        test -f "$SVN_TREE"/exec-2.sh &&
        test ! -L "$SVN_TREE"/exec-2.sh &&
-       git diff help "$SVN_TREE"/exec-2.sh'
+       test_cmp help "$SVN_TREE"/exec-2.sh'
 
 if test "$have_utf8" = t
 then
@@ -193,7 +193,7 @@ test_expect_success "$name" \
     'git-svn init "$svnrepo" && git-svn fetch &&
      git rev-list --pretty=raw remotes/git-svn | grep ^tree | uniq > a &&
      git rev-list --pretty=raw remotes/alt | grep ^tree | uniq > b &&
-     git diff a b'
+     test_cmp a b'
 
 name='check imported tree checksums expected tree checksums'
 rm -f expected
@@ -211,7 +211,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
 tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
 EOF
 
-test_expect_success "$name" "git diff a expected"
+test_expect_success "$name" "test_cmp a expected"
 
 test_expect_success 'exit if remote refs are ambigious' "
         git config --add svn-remote.svn.fetch \
index c4f4465dc687d30138a9111ae2efbc0e3aaf42b6..5edf56f198dc25b9db47ff363fe49958e5299162 100755 (executable)
@@ -74,7 +74,7 @@ EOF
 test_expect_success \
        'A: verify commit' \
        'git cat-file commit master | sed 1d >actual &&
-       git diff expect actual'
+       test_cmp expect actual'
 
 cat >expect <<EOF
 100644 blob file2
@@ -84,22 +84,22 @@ EOF
 test_expect_success \
        'A: verify tree' \
        'git cat-file -p master^{tree} | sed "s/ [0-9a-f]*      / /" >actual &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 echo "$file2_data" >expect
 test_expect_success \
        'A: verify file2' \
-       'git cat-file blob master:file2 >actual && git diff expect actual'
+       'git cat-file blob master:file2 >actual && test_cmp expect actual'
 
 echo "$file3_data" >expect
 test_expect_success \
        'A: verify file3' \
-       'git cat-file blob master:file3 >actual && git diff expect actual'
+       'git cat-file blob master:file3 >actual && test_cmp expect actual'
 
 printf "$file4_data" >expect
 test_expect_success \
        'A: verify file4' \
-       'git cat-file blob master:file4 >actual && git diff expect actual'
+       'git cat-file blob master:file4 >actual && test_cmp expect actual'
 
 cat >expect <<EOF
 :2 `git rev-parse --verify master:file2`
@@ -109,7 +109,7 @@ cat >expect <<EOF
 EOF
 test_expect_success \
        'A: verify marks output' \
-       'git diff expect marks.out'
+       'test_cmp expect marks.out'
 
 test_expect_success \
        'A: verify marks import' \
@@ -117,7 +117,7 @@ test_expect_success \
                --import-marks=marks.out \
                --export-marks=marks.new \
                </dev/null &&
-       git diff -u expect marks.new'
+       test_cmp expect marks.new'
 
 test_tick
 cat >input <<INPUT_END
@@ -259,7 +259,7 @@ EOF
 test_expect_success \
        'C: verify commit' \
        'git cat-file commit branch | sed 1d >actual &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 cat >expect <<EOF
 :000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A     file2/newf
@@ -316,13 +316,13 @@ echo "$file5_data" >expect
 test_expect_success \
        'D: verify file5' \
        'git cat-file blob branch:newdir/interesting >actual &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 echo "$file6_data" >expect
 test_expect_success \
        'D: verify file6' \
        'git cat-file blob branch:newdir/exec.sh >actual &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 ###
 ### series E
@@ -358,7 +358,7 @@ EOF
 test_expect_success \
        'E: verify commit' \
        'git cat-file commit branch | sed 1,2d >actual &&
-       git diff expect actual'
+       test_cmp expect actual'
 
 ###
 ### series F
@@ -411,7 +411,7 @@ EOF
 test_expect_success \
        'F: verify other commit' \
        'git cat-file commit other >actual &&
-       git diff expect actual'
+       test_cmp expect actual'
 
 ###
 ### series G
@@ -489,7 +489,7 @@ echo "$file5_data" >expect
 test_expect_success \
        'H: verify file' \
        'git cat-file blob H:h/e/l/lo >actual &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 ###
 ### series I
@@ -515,7 +515,7 @@ EOF
 test_expect_success \
        'I: verify edge list' \
        'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 ###
 ### series J
@@ -625,7 +625,7 @@ test_expect_success \
     'L: verify internal tree sorting' \
        'git-fast-import <input &&
         git diff-tree --abbrev --raw L^ L >output &&
-        git diff expect output'
+        test_cmp expect output'
 
 ###
 ### series M
@@ -885,7 +885,7 @@ test_expect_success \
         test 8 = `find .git/objects/pack -type f | wc -l` &&
         test `git rev-parse refs/tags/O3-2nd` = `git rev-parse O3^` &&
         git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 cat >input <<INPUT_END
 commit refs/heads/O4
@@ -916,6 +916,6 @@ test_expect_success \
        'O: progress outputs as requested by input' \
        'git-fast-import <input >actual &&
         grep "progress " <input >expect &&
-        git diff expect actual'
+        test_cmp expect actual'
 
 test_done
index 0b115a17ab46e02ca7ec67f08feada0c48c8628a..655f88270b27b637b6d4b7d3fdb3af76f525064f 100755 (executable)
@@ -69,7 +69,7 @@ EOF
 test_expect_success 'import a trivial module' '
 
        git cvsimport -a -z 0 -C module-git module &&
-       git diff module-cvs/o_fortuna module-git/o_fortuna
+       test_cmp module-cvs/o_fortuna module-git/o_fortuna
 
 '
 
@@ -110,7 +110,7 @@ test_expect_success 'update git module' '
        git cvsimport -a -z 0 module &&
        git merge origin &&
        cd .. &&
-       git diff module-cvs/o_fortuna module-git/o_fortuna
+       test_cmp module-cvs/o_fortuna module-git/o_fortuna
 
 '
 
@@ -131,7 +131,7 @@ test_expect_success 'cvsimport.module config works' '
                git cvsimport -a -z0 &&
                git merge origin &&
        cd .. &&
-       git diff module-cvs/tick module-git/tick
+       test_cmp module-cvs/tick module-git/tick
 
 '
 
@@ -142,7 +142,7 @@ test_expect_success 'import from a CVS working tree' '
                git cvsimport -a -z0 &&
                echo 1 >expect &&
                git log -1 --pretty=format:%s%n >actual &&
-               git diff actual expect &&
+               test_cmp actual expect &&
        cd ..
 
 '