Browse Source

Merge branch 'js/diff-ni'

* js/diff-ni:
  Get rid of the dependency to GNU diff in the tests
  diff --no-index: support /dev/null as filename
  diff-ni: fix the diff with standard input
  diff: support reading a file from stdin via "-"
maint
Junio C Hamano 18 years ago
parent
commit
cf6981d493
  1. 42
      diff-lib.c
  2. 33
      diff.c
  3. 6
      t/diff-lib.sh
  4. 2
      t/t1000-read-tree-m-3way.sh
  5. 26
      t/t1001-read-tree-m-2way.sh
  6. 2
      t/t1002-read-tree-m-u-2way.sh
  7. 8
      t/t1300-repo-config.sh
  8. 4
      t/t3001-ls-files-others-exclude.sh
  9. 10
      t/t3002-ls-files-dashpath.sh
  10. 2
      t/t3100-ls-tree-restrict.sh
  11. 2
      t/t3101-ls-tree-dirname.sh
  12. 30
      t/t3300-funny-names.sh
  13. 2
      t/t3900-i18n-commit.sh
  14. 2
      t/t4006-diff-mode.sh
  15. 2
      t/t4013-diff-various.sh
  16. 12
      t/t4015-diff-whitespace.sh
  17. 4
      t/t4016-diff-quote.sh
  18. 14
      t/t4100-apply-stat.sh
  19. 4
      t/t4104-apply-boundary.sh
  20. 4
      t/t4115-apply-symlink.sh
  21. 2
      t/t4116-apply-reverse.sh
  22. 12
      t/t4117-apply-reject.sh
  23. 6
      t/t4118-apply-empty-context.sh
  24. 6
      t/t4200-rerere.sh
  25. 2
      t/t5400-send-pack.sh
  26. 10
      t/t5401-update-hooks.sh
  27. 2
      t/t5515-fetch-merge-logic.sh
  28. 8
      t/t6023-merge-file.sh
  29. 4
      t/t6024-recursive-merge.sh
  30. 10
      t/t6200-fmt-merge-msg.sh
  31. 6
      t/t9100-git-svn-basic.sh
  32. 28
      t/t9300-fast-import.sh

42
diff-lib.c

@ -30,22 +30,28 @@ static int read_directory(const char *path, struct path_list *list) @@ -30,22 +30,28 @@ static int read_directory(const char *path, struct path_list *list)
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 = ntohl(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)
{
struct stat st;
int mode1 = 0, mode2 = 0;

if (name1) {
if (stat(name1, &st))
return error("Could not access '%s'", name1);
mode1 = st.st_mode;
}
if (name2) {
if (stat(name2, &st))
return error("Could not access '%s'", name2);
mode2 = st.st_mode;
}
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);
@ -224,7 +230,7 @@ int setup_diff_no_index(struct rev_info *revs, @@ -224,7 +230,7 @@ int setup_diff_no_index(struct rev_info *revs,
{
int i;
for (i = 1; i < argc; i++)
if (argv[i][0] != '-')
if (argv[i][0] != '-' || argv[i][1] == '\0')
break;
else if (!strcmp(argv[i], "--")) {
i++;
@ -254,9 +260,15 @@ int setup_diff_no_index(struct rev_info *revs, @@ -254,9 +260,15 @@ int setup_diff_no_index(struct rev_info *revs,

revs->diffopt.paths = xcalloc(2, sizeof(char*));
for (i = 0; i < 2; i++) {
const char *p;
p = prefix_filename(prefix, len, argv[argc - 2 + i]);
revs->diffopt.paths[i] = xstrdup(p);
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

33
diff.c

@ -1364,6 +1364,32 @@ static struct sha1_size_cache *locate_size_cache(unsigned char *sha1, @@ -1364,6 +1364,32 @@ static struct sha1_size_cache *locate_size_cache(unsigned char *sha1,
return e;
}

static int populate_from_stdin(struct diff_filespec *s)
{
#define INCREMENT 1024
char *buf;
unsigned long size;
int got;

size = 0;
buf = NULL;
while (1) {
buf = xrealloc(buf, size + INCREMENT);
got = xread(0, buf + size, INCREMENT);
if (!got)
break; /* EOF */
if (got < 0)
return error("error while reading from stdin %s",
strerror(errno));
size += got;
}
s->should_munmap = 0;
s->data = buf;
s->size = size;
s->should_free = 1;
return 0;
}

/*
* While doing rename detection and pickaxe operation, we may need to
* grab the data for the blob (or file) for our own in-core comparison.
@ -1389,6 +1415,9 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only) @@ -1389,6 +1415,9 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
char *buf;
unsigned long size;

if (!strcmp(s->path, "-"))
return populate_from_stdin(s);

if (lstat(s->path, &st) < 0) {
if (errno == ENOENT) {
err_empty:
@ -1690,6 +1719,10 @@ static void diff_fill_sha1_info(struct diff_filespec *one) @@ -1690,6 +1719,10 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
if (DIFF_FILE_VALID(one)) {
if (!one->sha1_valid) {
struct stat st;
if (!strcmp(one->path, "-")) {
hashcpy(one->sha1, null_sha1);
return;
}
if (lstat(one->path, &st) < 0)
die("stat %s", one->path);
if (index_path(one->sha1, one->path, &st, 0))

6
t/diff-lib.sh

@ -11,7 +11,7 @@ compare_diff_raw () { @@ -11,7 +11,7 @@ compare_diff_raw () {

sed -e "$sanitize_diff_raw" <"$1" >.tmp-1
sed -e "$sanitize_diff_raw" <"$2" >.tmp-2
diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
git diff .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 () { @@ -23,7 +23,7 @@ compare_diff_raw_z () {

tr '\0' '\012' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1
tr '\0' '\012' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2
diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}

compare_diff_patch () {
@ -37,5 +37,5 @@ 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
diff -u .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
git diff .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
}

2
t/t1000-read-tree-m-3way.sh

@ -131,7 +131,7 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" @@ -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 &&
diff -u expected current
git diff expected current
}

# This is done on an empty work directory, which is the normal

26
t/t1001-read-tree-m-2way.sh

@ -33,7 +33,7 @@ compare_change () { @@ -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"
diff -u expected current
git diff expected current
}

check_cache_at () {
@ -86,7 +86,7 @@ test_expect_success \ @@ -86,7 +86,7 @@ test_expect_success \
'rm -f .git/index &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >1-3.out &&
diff -u M.out 1-3.out &&
git diff 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 \ @@ -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
diff -u M.out 4.out >4diff.out
git diff M.out 4.out >4diff.out
compare_change 4diff.out expected &&
check_cache_at yomin clean'

@ -115,7 +115,7 @@ test_expect_success \ @@ -115,7 +115,7 @@ test_expect_success \
echo yomin yomin >yomin &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >5.out || return 1
diff -u M.out 5.out >5diff.out
git diff M.out 5.out >5diff.out
compare_change 5diff.out expected &&
check_cache_at yomin dirty'

@ -127,7 +127,7 @@ test_expect_success \ @@ -127,7 +127,7 @@ test_expect_success \
git-update-index --add frotz &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >6.out &&
diff -u M.out 6.out &&
git diff M.out 6.out &&
check_cache_at frotz clean'

test_expect_success \
@ -140,7 +140,7 @@ 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 &&
diff -u M.out 7.out &&
git diff M.out 7.out &&
check_cache_at frotz dirty'

test_expect_success \
@ -171,7 +171,7 @@ 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 &&
diff -u M.out 10.out'
git diff M.out 10.out'

test_expect_success \
'11 - dirty path removed.' \
@ -216,7 +216,7 @@ test_expect_success \ @@ -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
diff -u M.out 14.out >14diff.out
git diff M.out 14.out >14diff.out
compare_change 14diff.out expected &&
check_cache_at nitfol clean'

@ -230,7 +230,7 @@ test_expect_success \ @@ -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
diff -u M.out 15.out >15diff.out
git diff M.out 15.out >15diff.out
compare_change 15diff.out expected &&
check_cache_at nitfol dirty'

@ -262,7 +262,7 @@ test_expect_success \ @@ -262,7 +262,7 @@ test_expect_success \
git-update-index --add bozbar &&
read_tree_twoway $treeH $treeM &&
git-ls-files --stage >18.out &&
diff -u M.out 18.out &&
git diff M.out 18.out &&
check_cache_at bozbar clean'

test_expect_success \
@ -275,7 +275,7 @@ 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 &&
diff -u M.out 19.out &&
git diff M.out 19.out &&
check_cache_at bozbar dirty'

test_expect_success \
@ -287,7 +287,7 @@ 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 &&
diff -u M.out 20.out &&
git diff M.out 20.out &&
check_cache_at bozbar dirty'

test_expect_success \
@ -337,7 +337,7 @@ 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 &&
diff -u DFDF.out DFDFcheck.out &&
git diff DFDF.out DFDFcheck.out &&
check_cache_at DF/DF dirty &&
:'


2
t/t1002-read-tree-m-u-2way.sh

@ -16,7 +16,7 @@ compare_change () { @@ -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"
diff -u expected current
git diff expected current
}

check_cache_at () {

8
t/t1300-repo-config.sh

@ -368,12 +368,12 @@ cat > expect << EOF @@ -368,12 +368,12 @@ cat > expect << EOF
weird
EOF

test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success "rename succeeded" "git diff expect .git/config"

test_expect_failure "rename non-existing section" \
'git-config --rename-section branch."world domination" branch.drei'

test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success "rename succeeded" "git diff expect .git/config"

test_expect_success "rename another section" \
'git-config --rename-section branch."1 234 blabl/a" branch.drei'
@ -389,7 +389,7 @@ cat > expect << EOF @@ -389,7 +389,7 @@ cat > expect << EOF
weird
EOF

test_expect_success "rename succeeded" "diff -u expect .git/config"
test_expect_success "rename succeeded" "git diff expect .git/config"

cat >> .git/config << EOF
[branch "zwei"] a = 1 [branch "vier"]
@ -405,7 +405,7 @@ weird @@ -405,7 +405,7 @@ weird
EOF

test_expect_success "section was removed properly" \
"diff -u expect .git/config"
"git diff -u expect .git/config"

test_expect_success numbers '


4
t/t3001-ls-files-others-exclude.sh

@ -65,7 +65,7 @@ test_expect_success \ @@ -65,7 +65,7 @@ test_expect_success \
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
diff -u expect output'
git diff expect output'

# Test \r\n (MSDOS-like systems)
printf '*.1\r\n/*.3\r\n!*.6\r\n' >.gitignore
@ -77,6 +77,6 @@ test_expect_success \ @@ -77,6 +77,6 @@ test_expect_success \
--exclude-per-directory=.gitignore \
--exclude-from=.git/ignore \
>output &&
diff -u expect output'
git diff expect output'

test_done

10
t/t3002-ls-files-dashpath.sh

@ -23,7 +23,7 @@ test_expect_success \ @@ -23,7 +23,7 @@ test_expect_success \
test_expect_success \
'git-ls-files without path restriction.' \
'git-ls-files --others >output &&
diff -u output - <<EOF
git diff output - <<EOF
--
-foo
output
@ -34,7 +34,7 @@ EOF @@ -34,7 +34,7 @@ EOF
test_expect_success \
'git-ls-files with path restriction.' \
'git-ls-files --others path0 >output &&
diff -u output - <<EOF
git diff output - <<EOF
path0
EOF
'
@ -42,7 +42,7 @@ EOF @@ -42,7 +42,7 @@ EOF
test_expect_success \
'git-ls-files with path restriction with --.' \
'git-ls-files --others -- path0 >output &&
diff -u output - <<EOF
git diff output - <<EOF
path0
EOF
'
@ -50,7 +50,7 @@ EOF @@ -50,7 +50,7 @@ EOF
test_expect_success \
'git-ls-files with path restriction with -- --.' \
'git-ls-files --others -- -- >output &&
diff -u output - <<EOF
git diff output - <<EOF
--
EOF
'
@ -58,7 +58,7 @@ EOF @@ -58,7 +58,7 @@ EOF
test_expect_success \
'git-ls-files with no path restriction.' \
'git-ls-files --others -- >output &&
diff -u output - <<EOF
git diff output - <<EOF
--
-foo
output

2
t/t3100-ls-tree-restrict.sh

@ -35,7 +35,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' @@ -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
diff -u expected check
git diff expected check
}

test_expect_success \

2
t/t3101-ls-tree-dirname.sh

@ -43,7 +43,7 @@ _x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]' @@ -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
diff -u expected check
git diff expected check
}

test_expect_success \

30
t/t3300-funny-names.sh

@ -35,7 +35,7 @@ no-funny' >expected @@ -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 &&
diff -u expected current'
git diff expected current'

t0=`git-write-tree`
echo "$t0" >t0
@ -48,14 +48,14 @@ EOF @@ -48,14 +48,14 @@ EOF
test_expect_success 'git-ls-files with-funny' \
'git-update-index --add "$p1" &&
git-ls-files >current &&
diff -u expected current'
git diff 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 | tr \\0 \\012 >current &&
diff -u expected current'
git diff expected current'

t1=`git-write-tree`
echo "$t1" >t1
@ -67,28 +67,28 @@ no-funny @@ -67,28 +67,28 @@ no-funny
EOF
test_expect_success 'git-ls-tree with funny' \
'git-ls-tree -r $t1 | sed -e "s/^[^ ]* //" >current &&
diff -u expected current'
git diff 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 &&
diff -u expected current'
git diff expected current'

test_expect_success 'git-diff-tree with-funny' \
'git-diff-tree --name-status $t0 $t1 >current &&
diff -u expected current'
git diff 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 | tr \\0 \\012 >current &&
diff -u expected current'
git diff expected current'

test_expect_success 'git-diff-tree -z with-funny' \
'git-diff-tree -z --name-status $t0 $t1 | tr \\0 \\012 >current &&
diff -u expected current'
git diff expected current'

cat > expected <<\EOF
CNUM no-funny "tabs\t,\" (dq) and spaces"
@ -96,7 +96,7 @@ EOF @@ -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 &&
diff -u expected current'
git diff 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' \ @@ -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 &&
diff -u expected current'
git diff expected current'

cat > expected <<\EOF
diff --git a/no-funny "b/tabs\t,\" (dq) and spaces"
@ -116,7 +116,7 @@ EOF @@ -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 &&
diff -u expected current'
git diff expected current'

chmod +x "$p1"
cat > expected <<\EOF
@ -130,7 +130,7 @@ 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 &&
diff -u expected current'
git diff expected current'

cat >expected <<\EOF
"tabs\t,\" (dq) and spaces"
@ -139,7 +139,7 @@ EOF @@ -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 &&
diff -u expected current'
git diff expected current'

cat > expected <<\EOF
no-funny
@ -149,12 +149,12 @@ EOF @@ -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 &&
diff -u expected current'
git diff 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 &&
diff -u expected current'
git diff expected current'

test_done

2
t/t3900-i18n-commit.sh

@ -9,7 +9,7 @@ test_description='commit and log output encodings' @@ -9,7 +9,7 @@ test_description='commit and log output encodings'

compare_with () {
git-show -s $1 | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current &&
diff -u current "$2"
git diff current "$2"
}

test_expect_success setup '

2
t/t4006-diff-mode.sh

@ -38,7 +38,7 @@ echo ":100644 100755 X X M rezrov" >expected @@ -38,7 +38,7 @@ echo ":100644 100755 X X M rezrov" >expected

test_expect_success \
'verify' \
'diff -u expected check'
'git diff expected check'

test_done


2
t/t4013-diff-various.sh

@ -111,7 +111,7 @@ do @@ -111,7 +111,7 @@ do
} >"$actual" &&
if test -f "$expect"
then
diff -u "$expect" "$actual" &&
git diff "$expect" "$actual" &&
rm -f "$actual"
else
# this is to help developing new tests.

12
t/t4015-diff-whitespace.sh

@ -43,13 +43,13 @@ index adf3937..6edc172 100644 @@ -43,13 +43,13 @@ index adf3937..6edc172 100644
EOF

git-diff > out
test_expect_success "Ray's example without options" 'diff -u expect out'
test_expect_success "Ray's example without options" 'git diff expect out'

git-diff -w > out
test_expect_success "Ray's example with -w" 'diff -u expect out'
test_expect_success "Ray's example with -w" 'git diff expect out'

git-diff -b > out
test_expect_success "Ray's example with -b" 'diff -u expect out'
test_expect_success "Ray's example with -b" 'git diff expect out'

tr 'Q' '\015' << EOF > x
whitespace at beginning
@ -90,14 +90,14 @@ index d99af23..8b32fb5 100644 @@ -90,14 +90,14 @@ index d99af23..8b32fb5 100644
+CR at end
EOF
git-diff > out
test_expect_success 'another test, without options' 'diff -u expect out'
test_expect_success 'another test, without options' 'git diff 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' 'diff -u expect out'
test_expect_success 'another test, with -w' 'git diff expect out'

tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
@ -115,6 +115,6 @@ index d99af23..8b32fb5 100644 @@ -115,6 +115,6 @@ index d99af23..8b32fb5 100644
CR at endQ
EOF
git-diff -b > out
test_expect_success 'another test, with -b' 'diff -u expect out'
test_expect_success 'another test, with -b' 'git diff expect out'

test_done

4
t/t4016-diff-quote.sh

@ -49,7 +49,7 @@ cat >expect <<\EOF @@ -49,7 +49,7 @@ cat >expect <<\EOF
EOF
test_expect_success 'git diff --summary -M HEAD' '
git diff --summary -M HEAD >actual &&
diff -u expect actual
git diff expect actual
'

cat >expect <<\EOF
@ -64,7 +64,7 @@ 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 &&
diff -u expect actual
git diff expect actual
'

test_done

14
t/t4100-apply-stat.sh

@ -11,37 +11,37 @@ test_description='git-apply --stat --summary test. @@ -11,37 +11,37 @@ test_description='git-apply --stat --summary test.
test_expect_success \
'rename' \
'git-apply --stat --summary <../t4100/t-apply-1.patch >current &&
diff -u ../t4100/t-apply-1.expect current'
git diff ../t4100/t-apply-1.expect current'

test_expect_success \
'copy' \
'git-apply --stat --summary <../t4100/t-apply-2.patch >current &&
diff -u ../t4100/t-apply-2.expect current'
git diff ../t4100/t-apply-2.expect current'

test_expect_success \
'rewrite' \
'git-apply --stat --summary <../t4100/t-apply-3.patch >current &&
diff -u ../t4100/t-apply-3.expect current'
git diff ../t4100/t-apply-3.expect current'

test_expect_success \
'mode' \
'git-apply --stat --summary <../t4100/t-apply-4.patch >current &&
diff -u ../t4100/t-apply-4.expect current'
git diff ../t4100/t-apply-4.expect current'

test_expect_success \
'non git' \
'git-apply --stat --summary <../t4100/t-apply-5.patch >current &&
diff -u ../t4100/t-apply-5.expect current'
git diff ../t4100/t-apply-5.expect current'

test_expect_success \
'non git' \
'git-apply --stat --summary <../t4100/t-apply-6.patch >current &&
diff -u ../t4100/t-apply-6.expect current'
git diff ../t4100/t-apply-6.expect current'

test_expect_success \
'non git' \
'git-apply --stat --summary <../t4100/t-apply-7.patch >current &&
diff -u ../t4100/t-apply-7.expect current'
git diff ../t4100/t-apply-7.expect current'

test_done


4
t/t4104-apply-boundary.sh

@ -90,7 +90,7 @@ do @@ -90,7 +90,7 @@ do
cat '"$kind-patch.$with"'
(exit 1)
} &&
diff -u '"$kind"'-expect victim
git diff '"$kind"'-expect victim
'
done
done
@ -108,7 +108,7 @@ do @@ -108,7 +108,7 @@ do
cat '"$kind-ng.without"'
(exit 1)
} &&
diff -u '"$kind"'-expect victim
git diff '"$kind"'-expect victim
'
done


4
t/t4115-apply-symlink.sh

@ -33,7 +33,7 @@ test_expect_success 'apply symlink patch' ' @@ -33,7 +33,7 @@ test_expect_success 'apply symlink patch' '
git checkout side &&
git apply patch &&
git diff-files -p >patched &&
diff -u patch patched
git diff patch patched

'

@ -42,7 +42,7 @@ test_expect_success 'apply --index symlink patch' ' @@ -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 &&
diff -u patch patched
git diff patch patched

'


2
t/t4116-apply-reverse.sh

@ -42,7 +42,7 @@ test_expect_success 'apply in reverse' ' @@ -42,7 +42,7 @@ test_expect_success 'apply in reverse' '
git reset --hard second &&
git apply --reverse --binary --index patch &&
git diff >diff &&
diff -u /dev/null diff
git diff /dev/null diff

'


12
t/t4117-apply-reject.sh

@ -54,7 +54,7 @@ test_expect_success 'apply without --reject should fail' ' @@ -54,7 +54,7 @@ test_expect_success 'apply without --reject should fail' '
exit 1
fi

diff -u file1 saved.file1
git diff file1 saved.file1
'

test_expect_success 'apply without --reject should fail' '
@ -65,7 +65,7 @@ test_expect_success 'apply without --reject should fail' ' @@ -65,7 +65,7 @@ test_expect_success 'apply without --reject should fail' '
exit 1
fi

diff -u file1 saved.file1
git diff 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' ' @@ -79,7 +79,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
exit 1
fi

diff -u file1 expected &&
git diff file1 expected &&

cat file1.rej &&

@ -105,7 +105,7 @@ test_expect_success 'apply with --reject should fail but update the file' ' @@ -105,7 +105,7 @@ test_expect_success 'apply with --reject should fail but update the file' '
echo "file1 still exists?"
exit 1
}
diff -u file2 expected &&
git diff file2 expected &&

cat file2.rej &&

@ -132,7 +132,7 @@ test_expect_success 'the same test with --verbose' ' @@ -132,7 +132,7 @@ test_expect_success 'the same test with --verbose' '
echo "file1 still exists?"
exit 1
}
diff -u file2 expected &&
git diff file2 expected &&

cat file2.rej &&

@ -151,7 +151,7 @@ test_expect_success 'apply cleanly with --verbose' ' @@ -151,7 +151,7 @@ test_expect_success 'apply cleanly with --verbose' '

git apply --verbose patch.1 &&

diff -u file1 clean
git diff file1 clean
'

test_done

6
t/t4118-apply-empty-context.sh

@ -37,7 +37,7 @@ test_expect_success 'apply --numstat' ' @@ -37,7 +37,7 @@ test_expect_success 'apply --numstat' '
echo "0 1 file1" &&
echo "0 1 file2"
} >expect &&
diff -u expect actual
git diff expect actual

'

@ -47,8 +47,8 @@ test_expect_success 'apply --apply' ' @@ -47,8 +47,8 @@ test_expect_success 'apply --apply' '
cat file2.orig >file2 &&
git update-index file1 file2 &&
git apply --index diff.output &&
diff -u file1.mods file1 &&
diff -u file2.mods file2
git diff file1.mods file1 &&
git diff file2.mods file2
'

test_done

6
t/t4200-rerere.sh

@ -70,7 +70,7 @@ EOF @@ -70,7 +70,7 @@ EOF

git rerere diff > out

test_expect_success 'rerere diff' 'diff -u expect out'
test_expect_success 'rerere diff' 'git diff expect out'

cat > expect << EOF
a1
@ -78,7 +78,7 @@ EOF @@ -78,7 +78,7 @@ EOF

git rerere status > out

test_expect_success 'rerere status' 'diff -u expect out'
test_expect_success 'rerere status' 'git diff expect out'

test_expect_success 'commit succeeds' \
"git commit -q -a -m 'prefer first over second'"
@ -94,7 +94,7 @@ test_expect_failure 'another conflicting merge' 'git pull . first' @@ -94,7 +94,7 @@ test_expect_failure 'another conflicting merge' 'git pull . first'
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' 'diff -u a1 expect'
test_expect_success 'rerere prefers first change' 'git diff a1 expect'

rm $rr/postimage
echo "$sha1 a1" | tr '\012' '\0' > .git/rr-cache/MERGE_RR

2
t/t5400-send-pack.sh

@ -110,7 +110,7 @@ test_expect_success \ @@ -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
! diff .git/refs/heads/master victim/.git/refs/heads/master
! git diff .git/refs/heads/master victim/.git/refs/heads/master
'

test_done

10
t/t5401-update-hooks.sh

@ -84,23 +84,23 @@ test_expect_success 'pre-receive hook arguments' ' @@ -84,23 +84,23 @@ test_expect_success 'pre-receive hook arguments' '
echo \
refs/heads/master $commit0 $commit1 \
refs/heads/tofail $commit1 $commit0 \
| diff - victim/.git/pre-receive.args
| git diff - victim/.git/pre-receive.args
'

test_expect_success 'update hook arguments' '
(echo refs/heads/master $commit0 $commit1;
echo refs/heads/tofail $commit1 $commit0
) | diff - victim/.git/update.args
) | git diff - victim/.git/update.args
'

test_expect_success 'post-receive hook arguments' '
echo refs/heads/master $commit0 $commit1 |
diff - victim/.git/post-receive.args
git diff - victim/.git/post-receive.args
'

test_expect_success 'post-update hook arguments' '
echo refs/heads/master |
diff -u - victim/.git/post-update.args
git diff - victim/.git/post-update.args
'

test_expect_success 'all hook stdin is /dev/null' '
@ -128,7 +128,7 @@ STDERR post-update @@ -128,7 +128,7 @@ STDERR post-update
EOF
test_expect_success 'send-pack stderr contains hook messages' '
egrep ^STD send.err >actual &&
diff - actual <expect
git diff - actual <expect
'

test_done

2
t/t5515-fetch-merge-logic.sh

@ -149,7 +149,7 @@ do @@ -149,7 +149,7 @@ do
} >"$actual" &&
if test -f "$expect"
then
diff -u "$expect" "$actual" &&
git diff -u "$expect" "$actual" &&
rm -f "$actual"
else
# this is to help developing new tests.

8
t/t6023-merge-file.sh

@ -63,7 +63,7 @@ test_expect_success "merge without conflict (missing LF at EOF)" \ @@ -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" \
"diff -u test.txt test2.txt"
"git diff test.txt test2.txt"

cp test.txt backup.txt
test_expect_failure "merge with conflicts" \
@ -86,7 +86,7 @@ non timebo mala, quoniam tu mecum es: @@ -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" "diff -u test.txt expect.txt"
test_expect_success "expected conflict markers" "git diff test.txt expect.txt"

cp backup.txt test.txt
test_expect_failure "merge with conflicts, using -L" \
@ -110,7 +110,7 @@ virga tua et baculus tuus ipsa me consolata sunt. @@ -110,7 +110,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
EOF

test_expect_success "expected conflict markers, with -L" \
"diff -u test.txt expect.txt"
"git diff test.txt expect.txt"

sed "s/ tu / TU /" < new1.txt > new5.txt
test_expect_failure "conflict in removed tail" \
@ -132,7 +132,7 @@ virga tua et baculus tuus ipsa me consolata sunt. @@ -132,7 +132,7 @@ virga tua et baculus tuus ipsa me consolata sunt.
>>>>>>> new5.txt
EOF

test_expect_success "expected conflict markers" "diff -u expect out"
test_expect_success "expected conflict markers" "git diff expect out"

test_done


4
t/t6024-recursive-merge.sh

@ -70,7 +70,7 @@ G @@ -70,7 +70,7 @@ G
>>>>>>> G:a1
EOF

test_expect_success "result contains a conflict" "diff -u expect a1"
test_expect_success "result contains a conflict" "git diff expect a1"

git ls-files --stage > out
cat > expect << EOF
@ -79,6 +79,6 @@ cat > expect << EOF @@ -79,6 +79,6 @@ cat > expect << EOF
100644 fd7923529855d0b274795ae3349c5e0438333979 3 a1
EOF

test_expect_success "virtual trees were processed" "diff -u expect out"
test_expect_success "virtual trees were processed" "git diff expect out"

test_done

10
t/t6200-fmt-merge-msg.sh

@ -79,7 +79,7 @@ test_expect_success 'merge-msg test #1' ' @@ -79,7 +79,7 @@ test_expect_success 'merge-msg test #1' '
git fetch . left &&

git fmt-merge-msg <.git/FETCH_HEAD >actual &&
diff -u actual expected
git diff actual expected
'

cat >expected <<\EOF
@ -92,7 +92,7 @@ test_expect_success 'merge-msg test #2' ' @@ -92,7 +92,7 @@ test_expect_success 'merge-msg test #2' '
git fetch ../trash left &&

git fmt-merge-msg <.git/FETCH_HEAD >actual &&
diff -u actual expected
git diff actual expected
'

cat >expected <<\EOF
@ -115,7 +115,7 @@ test_expect_success 'merge-msg test #3' ' @@ -115,7 +115,7 @@ test_expect_success 'merge-msg test #3' '
git fetch . left &&

git fmt-merge-msg <.git/FETCH_HEAD >actual &&
diff -u actual expected
git diff actual expected
'

cat >expected <<\EOF
@ -145,7 +145,7 @@ test_expect_success 'merge-msg test #4' ' @@ -145,7 +145,7 @@ test_expect_success 'merge-msg test #4' '
git fetch . left right &&

git fmt-merge-msg <.git/FETCH_HEAD >actual &&
diff -u actual expected
git diff actual expected
'

test_expect_success 'merge-msg test #5' '
@ -157,7 +157,7 @@ test_expect_success 'merge-msg test #5' ' @@ -157,7 +157,7 @@ test_expect_success 'merge-msg test #5' '
git fetch . left right &&

git fmt-merge-msg <.git/FETCH_HEAD >actual &&
diff -u actual expected
git diff actual expected
'

test_done

6
t/t9100-git-svn-basic.sh

@ -169,7 +169,7 @@ test_expect_success "$name" " @@ -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 &&
diff -u help $SVN_TREE/exec-2.sh"
git diff help $SVN_TREE/exec-2.sh"

if test "$have_utf8" = t
then
@ -193,7 +193,7 @@ test_expect_success "$name" \ @@ -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 &&
diff -u a b"
git diff a b"

name='check imported tree checksums expected tree checksums'
rm -f expected
@ -211,7 +211,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e @@ -211,7 +211,7 @@ tree d667270a1f7b109f5eb3aaea21ede14b56bfdd6e
tree 8f51f74cf0163afc9ad68a4b1537288c4558b5a4
EOF

test_expect_success "$name" "diff -u a expected"
test_expect_success "$name" "git diff a expected"

test_expect_failure 'exit if remote refs are ambigious' "
git-config --add svn-remote.svn.fetch \

28
t/t9300-fast-import.sh

@ -74,7 +74,7 @@ EOF @@ -74,7 +74,7 @@ EOF
test_expect_success \
'A: verify commit' \
'git-cat-file commit master | sed 1d >actual &&
diff -u expect actual'
git diff expect actual'

cat >expect <<EOF
100644 blob file2
@ -84,22 +84,22 @@ EOF @@ -84,22 +84,22 @@ EOF
test_expect_success \
'A: verify tree' \
'git-cat-file -p master^{tree} | sed "s/ [0-9a-f]* / /" >actual &&
diff -u expect actual'
git diff expect actual'

echo "$file2_data" >expect
test_expect_success \
'A: verify file2' \
'git-cat-file blob master:file2 >actual && diff -u expect actual'
'git-cat-file blob master:file2 >actual && git diff expect actual'

echo "$file3_data" >expect
test_expect_success \
'A: verify file3' \
'git-cat-file blob master:file3 >actual && diff -u expect actual'
'git-cat-file blob master:file3 >actual && git diff expect actual'

printf "$file4_data" >expect
test_expect_success \
'A: verify file4' \
'git-cat-file blob master:file4 >actual && diff -u expect actual'
'git-cat-file blob master:file4 >actual && git diff expect actual'

cat >expect <<EOF
:2 `git-rev-parse --verify master:file2`
@ -109,7 +109,7 @@ cat >expect <<EOF @@ -109,7 +109,7 @@ cat >expect <<EOF
EOF
test_expect_success \
'A: verify marks output' \
'diff -u expect marks.out'
'git diff expect marks.out'

test_expect_success \
'A: verify marks import' \
@ -117,7 +117,7 @@ test_expect_success \ @@ -117,7 +117,7 @@ test_expect_success \
--import-marks=marks.out \
--export-marks=marks.new \
</dev/null &&
diff -u expect marks.new'
git diff -u expect marks.new'

###
### series B
@ -183,7 +183,7 @@ EOF @@ -183,7 +183,7 @@ EOF
test_expect_success \
'C: verify commit' \
'git-cat-file commit branch | sed 1d >actual &&
diff -u expect actual'
git diff expect actual'

cat >expect <<EOF
:000000 100755 0000000000000000000000000000000000000000 f1fb5da718392694d0076d677d6d0e364c79b0bc A file2/newf
@ -240,13 +240,13 @@ echo "$file5_data" >expect @@ -240,13 +240,13 @@ echo "$file5_data" >expect
test_expect_success \
'D: verify file5' \
'git-cat-file blob branch:newdir/interesting >actual &&
diff -u expect actual'
git diff expect actual'

echo "$file6_data" >expect
test_expect_success \
'D: verify file6' \
'git-cat-file blob branch:newdir/exec.sh >actual &&
diff -u expect actual'
git diff expect actual'

###
### series E
@ -282,7 +282,7 @@ EOF @@ -282,7 +282,7 @@ EOF
test_expect_success \
'E: verify commit' \
'git-cat-file commit branch | sed 1,2d >actual &&
diff -u expect actual'
git diff expect actual'

###
### series F
@ -335,7 +335,7 @@ EOF @@ -335,7 +335,7 @@ EOF
test_expect_success \
'F: verify other commit' \
'git-cat-file commit other >actual &&
diff -u expect actual'
git diff expect actual'

###
### series G
@ -413,7 +413,7 @@ echo "$file5_data" >expect @@ -413,7 +413,7 @@ echo "$file5_data" >expect
test_expect_success \
'H: verify file' \
'git-cat-file blob H:h/e/l/lo >actual &&
diff -u expect actual'
git diff expect actual'

###
### series I
@ -439,7 +439,7 @@ EOF @@ -439,7 +439,7 @@ EOF
test_expect_success \
'I: verify edge list' \
'sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
diff -u expect actual'
git diff expect actual'

###
### series J

Loading…
Cancel
Save