Skip to content

Commit

Permalink
t4013: add tests for diff/log family output options.
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Jun 26, 2006
1 parent 1ef9e05 commit 3c2f75b
Show file tree
Hide file tree
Showing 72 changed files with 2,579 additions and 0 deletions.
202 changes: 202 additions & 0 deletions t/t4013-diff-various.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
#!/bin/sh
#
# Copyright (c) 2006 Junio C Hamano
#

test_description='Various diff formatting options'

. ./test-lib.sh

test_expect_success setup '
GIT_AUTHOR_DATE="2006-06-26 00:00:00 +0000" &&
GIT_COMMITTER_DATE="2006-06-26 00:00:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
mkdir dir &&
for i in 1 2 3; do echo $i; done >file0 &&
for i in A B; do echo $i; done >dir/sub &&
cat file0 >file2 &&
git add file0 file2 dir/sub &&
git commit -m Initial &&
git branch initial &&
git branch side &&
GIT_AUTHOR_DATE="2006-06-26 00:01:00 +0000" &&
GIT_COMMITTER_DATE="2006-06-26 00:01:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
for i in 4 5 6; do echo $i; done >>file0 &&
for i in C D; do echo $i; done >>dir/sub &&
rm -f file2 &&
git update-index --remove file0 file2 dir/sub &&
git commit -m Second &&
GIT_AUTHOR_DATE="2006-06-26 00:02:00 +0000" &&
GIT_COMMITTER_DATE="2006-06-26 00:02:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
for i in A B C; do echo $i; done >file1 &&
git add file1 &&
for i in E F; do echo $i; done >>dir/sub &&
git update-index dir/sub &&
git commit -m Third &&
GIT_AUTHOR_DATE="2006-06-26 00:03:00 +0000" &&
GIT_COMMITTER_DATE="2006-06-26 00:03:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
git checkout side &&
for i in A B C; do echo $i; done >>file0 &&
for i in 1 2; do echo $i; done >>dir/sub &&
cat dir/sub >file3 &&
git add file3 &&
git update-index file0 dir/sub &&
git commit -m Side &&
GIT_AUTHOR_DATE="2006-06-26 00:04:00 +0000" &&
GIT_COMMITTER_DATE="2006-06-26 00:04:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
git checkout master &&
git pull -s ours . side &&
GIT_AUTHOR_DATE="2006-06-26 00:05:00 +0000" &&
GIT_COMMITTER_DATE="2006-06-26 00:05:00 +0000" &&
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
for i in A B C; do echo $i; done >>file0 &&
for i in 1 2; do echo $i; done >>dir/sub &&
git update-index file0 dir/sub &&
EDITOR=: VISUAL=: git commit --amend &&
git show-branch
'

: <<\EOF
! [initial] Initial
* [master] Merge branch 'side'
! [side] Side
---
- [master] Merge branch 'side'
*+ [side] Side
* [master^] Second
+*+ [initial] Initial
EOF

while read cmd
do
case "$cmd" in
'' | '#'*) continue ;;
esac
test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
cnt=`expr $test_count + 1`
pfx=`printf "%04d" $cnt`
expect="../t4013/diff.$test"
actual="$pfx-diff.$test"

test_expect_success "git $cmd" '
{
echo "\$ git $cmd"
git $cmd
echo "\$"
} >"$actual" &&
if test -f "$expect"
then
diff -u "$expect" "$actual" &&
rm -f "$actual"
else
# this is to help developing new tests.
cp "$actual" "$expect"
false
fi
'
done <<\EOF
diff-tree initial
diff-tree -r initial
diff-tree -r --abbrev initial
diff-tree -r --abbrev=4 initial
diff-tree --root initial
diff-tree --root --abbrev initial
diff-tree --root -r initial
diff-tree --root -r --abbrev initial
diff-tree --root -r --abbrev=4 initial
diff-tree -p initial
diff-tree --root -p initial
diff-tree --patch-with-stat initial
diff-tree --root --patch-with-stat initial
diff-tree --patch-with-raw initial
diff-tree --root --patch-with-raw initial
diff-tree --pretty initial
diff-tree --pretty --root initial
diff-tree --pretty -p initial
diff-tree --pretty --stat initial
diff-tree --pretty --summary initial
diff-tree --pretty --stat --summary initial
diff-tree --pretty --root -p initial
diff-tree --pretty --root --stat initial
#diff-tree --pretty --root --summary initial
diff-tree --pretty --root --stat --summary initial
diff-tree --pretty --patch-with-stat initial
diff-tree --pretty --root --patch-with-stat initial
diff-tree --pretty --patch-with-raw initial
diff-tree --pretty --root --patch-with-raw initial
diff-tree --pretty=oneline initial
diff-tree --pretty=oneline --root initial
diff-tree --pretty=oneline -p initial
diff-tree --pretty=oneline --root -p initial
diff-tree --pretty=oneline --patch-with-stat initial
diff-tree --pretty=oneline --root --patch-with-stat initial
diff-tree --pretty=oneline --patch-with-raw initial
diff-tree --pretty=oneline --root --patch-with-raw initial
diff-tree --pretty side
diff-tree --pretty -p side
diff-tree --pretty --patch-with-stat side
diff-tree master
diff-tree -p master
diff-tree -p -m master
diff-tree -c master
diff-tree -c --abbrev master
diff-tree --cc master
log master
log -p master
log --root master
log --root -p master
log --patch-with-stat master
log --root --patch-with-stat master
#log --root --patch-with-stat --summary master
log -SF master
whatchanged master
whatchanged -p master
whatchanged --root master
whatchanged --root -p master
whatchanged --patch-with-stat master
whatchanged --root --patch-with-stat master
whatchanged --root --patch-with-stat --summary master
whatchanged -SF master
log --patch-with-stat master -- dir/
whatchanged --patch-with-stat master -- dir/
show initial
show --root initial
show side
show master
show --stat side
show --stat --summary side
show --patch-with-stat side
show --patch-with-raw side
show --patch-with-stat --summary side
EOF

test_done
30 changes: 30 additions & 0 deletions t/t4013/diff.diff-tree_--cc_master
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$ git diff-tree --cc master
176b998f5d647cbd77a9d8acf4531e930754d16d
diff --cc dir/sub
index cead32e,7289e35..992913c
--- a/dir/sub
+++ b/dir/sub
@@@ -1,6 -1,4 +1,8 @@@
A
B
+C
+D
+E
+F
+ 1
+ 2
diff --cc file0
index b414108,f4615da..10a8a9f
--- a/file0
+++ b/file0
@@@ -1,6 -1,6 +1,9 @@@
1
2
3
+4
+5
+6
+ A
+ B
+ C
$
2 changes: 2 additions & 0 deletions t/t4013/diff.diff-tree_--patch-with-raw_initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff-tree --patch-with-raw initial
$
2 changes: 2 additions & 0 deletions t/t4013/diff.diff-tree_--patch-with-stat_initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff-tree --patch-with-stat initial
$
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff-tree --pretty=oneline --patch-with-raw initial
$
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff-tree --pretty=oneline --patch-with-stat initial
$
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$ git diff-tree --pretty=oneline --root --patch-with-raw initial
444ac553ac7612cc88969031b02b3767fb8a353a Initial
:000000 100644 0000000000000000000000000000000000000000 35d242ba79ae89ac695e26b3d4c27a8e6f028f9e A dir/sub
:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0
:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2

diff --git a/dir/sub b/dir/sub
new file mode 100644
index 0000000..35d242b
--- /dev/null
+++ b/dir/sub
@@ -0,0 +1,2 @@
+A
+B
diff --git a/file0 b/file0
new file mode 100644
index 0000000..01e79c3
--- /dev/null
+++ b/file0
@@ -0,0 +1,3 @@
+1
+2
+3
diff --git a/file2 b/file2
new file mode 100644
index 0000000..01e79c3
--- /dev/null
+++ b/file2
@@ -0,0 +1,3 @@
+1
+2
+3
$
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
$ git diff-tree --pretty=oneline --root --patch-with-stat initial
444ac553ac7612cc88969031b02b3767fb8a353a Initial
---
dir/sub | 2 ++
file0 | 3 +++
file2 | 3 +++
3 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/dir/sub b/dir/sub
new file mode 100644
index 0000000..35d242b
--- /dev/null
+++ b/dir/sub
@@ -0,0 +1,2 @@
+A
+B
diff --git a/file0 b/file0
new file mode 100644
index 0000000..01e79c3
--- /dev/null
+++ b/file0
@@ -0,0 +1,3 @@
+1
+2
+3
diff --git a/file2 b/file2
new file mode 100644
index 0000000..01e79c3
--- /dev/null
+++ b/file2
@@ -0,0 +1,3 @@
+1
+2
+3
$
29 changes: 29 additions & 0 deletions t/t4013/diff.diff-tree_--pretty=oneline_--root_-p_initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$ git diff-tree --pretty=oneline --root -p initial
444ac553ac7612cc88969031b02b3767fb8a353a Initial
diff --git a/dir/sub b/dir/sub
new file mode 100644
index 0000000..35d242b
--- /dev/null
+++ b/dir/sub
@@ -0,0 +1,2 @@
+A
+B
diff --git a/file0 b/file0
new file mode 100644
index 0000000..01e79c3
--- /dev/null
+++ b/file0
@@ -0,0 +1,3 @@
+1
+2
+3
diff --git a/file2 b/file2
new file mode 100644
index 0000000..01e79c3
--- /dev/null
+++ b/file2
@@ -0,0 +1,3 @@
+1
+2
+3
$
6 changes: 6 additions & 0 deletions t/t4013/diff.diff-tree_--pretty=oneline_--root_initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$ git diff-tree --pretty=oneline --root initial
444ac553ac7612cc88969031b02b3767fb8a353a Initial
:000000 040000 0000000000000000000000000000000000000000 da7a33fa77d8066d6698643940ce5860fe2d7fb3 A dir
:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file0
:000000 100644 0000000000000000000000000000000000000000 01e79c32a8c99c557f0757da7cb6d65b3414466d A file2
$
2 changes: 2 additions & 0 deletions t/t4013/diff.diff-tree_--pretty=oneline_-p_initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff-tree --pretty=oneline -p initial
$
2 changes: 2 additions & 0 deletions t/t4013/diff.diff-tree_--pretty=oneline_initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff-tree --pretty=oneline initial
$
2 changes: 2 additions & 0 deletions t/t4013/diff.diff-tree_--pretty_--patch-with-raw_initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff-tree --pretty --patch-with-raw initial
$
2 changes: 2 additions & 0 deletions t/t4013/diff.diff-tree_--pretty_--patch-with-stat_initial
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ git diff-tree --pretty --patch-with-stat initial
$
Loading

0 comments on commit 3c2f75b

Please sign in to comment.