2006-06-26 22:46:52 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2006 Junio C Hamano
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Various diff formatting options'
|
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2006-07-14 04:51:12 +02:00
|
|
|
LF='
|
|
|
|
'
|
|
|
|
|
2006-06-26 22:46:52 +02:00
|
|
|
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 &&
|
2007-07-03 17:01:06 +02:00
|
|
|
mkdir dir2 &&
|
2006-06-26 22:46:52 +02:00
|
|
|
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 &&
|
2006-07-14 04:51:12 +02:00
|
|
|
git commit -m "Second${LF}${LF}This is the second commit." &&
|
2006-06-26 22:46:52 +02:00
|
|
|
|
|
|
|
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 &&
|
|
|
|
|
2009-02-18 07:48:06 +01:00
|
|
|
mkdir dir3 &&
|
|
|
|
cp dir/sub dir3/sub &&
|
|
|
|
test-chmtime +1 dir3/sub &&
|
|
|
|
|
2007-01-29 01:16:53 +01:00
|
|
|
git config log.showroot false &&
|
2006-07-11 21:01:54 +02:00
|
|
|
git commit --amend &&
|
2006-06-26 22:46:52 +02:00
|
|
|
git show-branch
|
|
|
|
'
|
|
|
|
|
|
|
|
: <<\EOF
|
|
|
|
! [initial] Initial
|
|
|
|
* [master] Merge branch 'side'
|
|
|
|
! [side] Side
|
|
|
|
---
|
|
|
|
- [master] Merge branch 'side'
|
|
|
|
*+ [side] Side
|
|
|
|
* [master^] Second
|
|
|
|
+*+ [initial] Initial
|
|
|
|
EOF
|
|
|
|
|
2006-08-13 03:04:07 +02:00
|
|
|
V=`git version | sed -e 's/^git version //' -e 's/\./\\./g'`
|
2006-06-26 22:46:52 +02:00
|
|
|
while read cmd
|
|
|
|
do
|
|
|
|
case "$cmd" in
|
|
|
|
'' | '#'*) continue ;;
|
|
|
|
esac
|
|
|
|
test=`echo "$cmd" | sed -e 's|[/ ][/ ]*|_|g'`
|
2009-02-05 21:20:56 +01:00
|
|
|
pfx=`printf "%04d" $test_count`
|
2008-08-08 11:26:28 +02:00
|
|
|
expect="$TEST_DIRECTORY/t4013/diff.$test"
|
2006-06-26 22:46:52 +02:00
|
|
|
actual="$pfx-diff.$test"
|
|
|
|
|
|
|
|
test_expect_success "git $cmd" '
|
|
|
|
{
|
|
|
|
echo "\$ git $cmd"
|
2006-08-13 03:04:07 +02:00
|
|
|
git $cmd |
|
|
|
|
sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
|
2007-03-05 01:08:04 +01:00
|
|
|
-e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
|
2006-06-26 22:46:52 +02:00
|
|
|
echo "\$"
|
|
|
|
} >"$actual" &&
|
|
|
|
if test -f "$expect"
|
|
|
|
then
|
2008-05-24 07:28:56 +02:00
|
|
|
test_cmp "$expect" "$actual" &&
|
2006-06-26 22:46:52 +02:00
|
|
|
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
|
2006-06-29 21:00:12 +02:00
|
|
|
# improved by Timo's patch
|
|
|
|
diff-tree --pretty --root --summary initial
|
|
|
|
# improved by Timo's patch
|
|
|
|
diff-tree --pretty --root --summary -r initial
|
2006-06-26 22:46:52 +02:00
|
|
|
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
|
2006-06-29 21:00:12 +02:00
|
|
|
# improved by Timo's patch
|
2006-06-26 22:46:52 +02:00
|
|
|
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
|
2006-06-27 08:29:11 +02:00
|
|
|
# stat only should show the diffstat with the first parent
|
|
|
|
diff-tree -c --stat master
|
|
|
|
diff-tree --cc --stat master
|
|
|
|
diff-tree -c --stat --summary master
|
|
|
|
diff-tree --cc --stat --summary master
|
|
|
|
# stat summary should show the diffstat and summary with the first parent
|
|
|
|
diff-tree -c --stat --summary side
|
|
|
|
diff-tree --cc --stat --summary side
|
2006-06-29 21:00:12 +02:00
|
|
|
# improved by Timo's patch
|
|
|
|
diff-tree --cc --patch-with-stat master
|
|
|
|
# improved by Timo's patch
|
2006-06-27 08:29:11 +02:00
|
|
|
diff-tree --cc --patch-with-stat --summary master
|
|
|
|
# this is correct
|
|
|
|
diff-tree --cc --patch-with-stat --summary side
|
2006-06-26 22:46:52 +02:00
|
|
|
|
|
|
|
log master
|
|
|
|
log -p master
|
|
|
|
log --root master
|
|
|
|
log --root -p master
|
|
|
|
log --patch-with-stat master
|
|
|
|
log --root --patch-with-stat master
|
2006-06-27 08:29:11 +02:00
|
|
|
log --root --patch-with-stat --summary master
|
2006-06-29 21:00:12 +02:00
|
|
|
# improved by Timo's patch
|
2006-06-27 08:29:11 +02:00
|
|
|
log --root -c --patch-with-stat --summary master
|
2006-06-29 21:00:12 +02:00
|
|
|
# improved by Timo's patch
|
2006-06-27 08:29:11 +02:00
|
|
|
log --root --cc --patch-with-stat --summary master
|
2006-06-26 22:46:52 +02:00
|
|
|
log -SF master
|
2006-06-27 08:29:11 +02:00
|
|
|
log -SF -p master
|
2009-02-19 12:13:40 +01:00
|
|
|
log --decorate --all
|
2009-08-15 16:23:12 +02:00
|
|
|
log --decorate=full --all
|
2006-06-26 22:46:52 +02:00
|
|
|
|
2009-02-19 12:13:41 +01:00
|
|
|
rev-list --parents HEAD
|
|
|
|
rev-list --children HEAD
|
2006-06-26 22:46:52 +02:00
|
|
|
|
|
|
|
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
|
2006-06-29 21:00:12 +02:00
|
|
|
# improved by Timo's patch
|
2006-06-27 08:29:11 +02:00
|
|
|
whatchanged --root -c --patch-with-stat --summary master
|
2006-06-29 21:00:12 +02:00
|
|
|
# improved by Timo's patch
|
2006-06-27 08:29:11 +02:00
|
|
|
whatchanged --root --cc --patch-with-stat --summary master
|
2006-06-26 22:46:52 +02:00
|
|
|
whatchanged -SF master
|
2006-06-27 08:29:11 +02:00
|
|
|
whatchanged -SF -p master
|
2006-06-26 22:46:52 +02:00
|
|
|
|
|
|
|
log --patch-with-stat master -- dir/
|
|
|
|
whatchanged --patch-with-stat master -- dir/
|
2006-06-27 08:29:11 +02:00
|
|
|
log --patch-with-stat --summary master -- dir/
|
|
|
|
whatchanged --patch-with-stat --summary master -- dir/
|
2006-06-26 22:46:52 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2006-06-29 09:01:07 +02:00
|
|
|
format-patch --stdout initial..side
|
|
|
|
format-patch --stdout initial..master^
|
|
|
|
format-patch --stdout initial..master
|
2008-10-02 22:55:39 +02:00
|
|
|
format-patch --stdout --no-numbered initial..master
|
|
|
|
format-patch --stdout --numbered initial..master
|
2006-06-29 09:01:07 +02:00
|
|
|
format-patch --attach --stdout initial..side
|
2009-03-23 03:14:05 +01:00
|
|
|
format-patch --attach --stdout --suffix=.diff initial..side
|
2006-06-29 09:01:07 +02:00
|
|
|
format-patch --attach --stdout initial..master^
|
|
|
|
format-patch --attach --stdout initial..master
|
2007-03-04 00:12:06 +01:00
|
|
|
format-patch --inline --stdout initial..side
|
|
|
|
format-patch --inline --stdout initial..master^
|
2009-03-23 03:14:06 +01:00
|
|
|
format-patch --inline --stdout --numbered-files initial..master
|
2008-10-02 22:55:39 +02:00
|
|
|
format-patch --inline --stdout initial..master
|
2007-04-12 01:58:08 +02:00
|
|
|
format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
|
2007-07-02 02:48:59 +02:00
|
|
|
config format.subjectprefix DIFFERENT_PREFIX
|
|
|
|
format-patch --inline --stdout initial..master^^
|
2008-02-19 04:56:13 +01:00
|
|
|
format-patch --stdout --cover-letter -n initial..master^
|
2006-06-29 09:01:07 +02:00
|
|
|
|
2006-07-02 07:02:17 +02:00
|
|
|
diff --abbrev initial..side
|
|
|
|
diff -r initial..side
|
|
|
|
diff --stat initial..side
|
|
|
|
diff -r --stat initial..side
|
|
|
|
diff initial..side
|
|
|
|
diff --patch-with-stat initial..side
|
|
|
|
diff --patch-with-raw initial..side
|
|
|
|
diff --patch-with-stat -r initial..side
|
|
|
|
diff --patch-with-raw -r initial..side
|
2007-07-03 17:01:06 +02:00
|
|
|
diff --name-status dir2 dir
|
2008-05-24 07:28:56 +02:00
|
|
|
diff --no-index --name-status dir2 dir
|
2009-01-06 19:53:32 +01:00
|
|
|
diff --no-index --name-status -- dir2 dir
|
2009-02-18 07:48:06 +01:00
|
|
|
diff --no-index dir dir3
|
2008-10-11 03:56:15 +02:00
|
|
|
diff master master^ side
|
2009-02-19 12:13:37 +01:00
|
|
|
diff --dirstat master~1 master~2
|
2006-06-26 22:46:52 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_done
|