2006-06-27 00:46:52 +04:00
|
|
|
#!/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 &&
|
2007-07-03 19:01:06 +04:00
|
|
|
mkdir dir2 &&
|
2006-06-27 00:46:52 +04: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 06:51:12 +04:00
|
|
|
git commit -m "Second${LF}${LF}This is the second commit." &&
|
2006-06-27 00:46:52 +04: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 09:48:06 +03:00
|
|
|
mkdir dir3 &&
|
|
|
|
cp dir/sub dir3/sub &&
|
2018-03-24 10:44:31 +03:00
|
|
|
test-tool chmtime +1 dir3/sub &&
|
2009-02-18 09:48:06 +03:00
|
|
|
|
2007-01-29 03:16:53 +03:00
|
|
|
git config log.showroot false &&
|
2006-07-11 23:01:54 +04:00
|
|
|
git commit --amend &&
|
2011-04-11 02:48:50 +04:00
|
|
|
|
|
|
|
GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
|
|
|
|
GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
|
|
|
|
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
|
|
|
|
git checkout -b rearrange initial &&
|
|
|
|
for i in B A; do echo $i; done >dir/sub &&
|
|
|
|
git add dir/sub &&
|
|
|
|
git commit -m "Rearranged lines in dir/sub" &&
|
|
|
|
git checkout master &&
|
|
|
|
|
2017-09-28 01:51:26 +03:00
|
|
|
GIT_AUTHOR_DATE="2006-06-26 00:06:00 +0000" &&
|
|
|
|
GIT_COMMITTER_DATE="2006-06-26 00:06:00 +0000" &&
|
|
|
|
export GIT_AUTHOR_DATE GIT_COMMITTER_DATE &&
|
|
|
|
git checkout -b mode initial &&
|
|
|
|
git update-index --chmod=+x file0 &&
|
|
|
|
git commit -m "update mode" &&
|
|
|
|
git checkout -f master &&
|
|
|
|
|
2019-01-24 15:35:40 +03:00
|
|
|
# Same merge as master, but with parents reversed. Hide it in a
|
|
|
|
# pseudo-ref to avoid impacting tests with --all.
|
|
|
|
commit=$(echo reverse |
|
|
|
|
git commit-tree -p master^2 -p master^1 master^{tree}) &&
|
|
|
|
git update-ref REVERSE $commit &&
|
|
|
|
|
2016-02-25 11:59:21 +03:00
|
|
|
git config diff.renames false &&
|
|
|
|
|
2006-06-27 00:46:52 +04:00
|
|
|
git show-branch
|
|
|
|
'
|
|
|
|
|
|
|
|
: <<\EOF
|
|
|
|
! [initial] Initial
|
|
|
|
* [master] Merge branch 'side'
|
2011-04-11 02:48:50 +04:00
|
|
|
! [rearrange] Rearranged lines in dir/sub
|
|
|
|
! [side] Side
|
|
|
|
----
|
|
|
|
+ [rearrange] Rearranged lines in dir/sub
|
|
|
|
- [master] Merge branch 'side'
|
|
|
|
* + [side] Side
|
|
|
|
* [master^] Third
|
|
|
|
* [master~2] Second
|
|
|
|
+*++ [initial] Initial
|
2006-06-27 00:46:52 +04:00
|
|
|
EOF
|
|
|
|
|
2020-02-07 03:52:40 +03:00
|
|
|
process_diffs () {
|
|
|
|
_x04="[0-9a-f][0-9a-f][0-9a-f][0-9a-f]" &&
|
|
|
|
_x07="$_x05[0-9a-f][0-9a-f]" &&
|
|
|
|
sed -e "s/$OID_REGEX/$ZERO_OID/g" \
|
|
|
|
-e "s/From $_x40 /From $ZERO_OID /" \
|
|
|
|
-e "s/from $_x40)/from $ZERO_OID)/" \
|
|
|
|
-e "s/commit $_x40\$/commit $ZERO_OID/" \
|
|
|
|
-e "s/commit $_x40 (/commit $ZERO_OID (/" \
|
|
|
|
-e "s/$_x40 $_x40 $_x40/$ZERO_OID $ZERO_OID $ZERO_OID/" \
|
|
|
|
-e "s/$_x40 $_x40 /$ZERO_OID $ZERO_OID /" \
|
|
|
|
-e "s/^$_x40 $_x40$/$ZERO_OID $ZERO_OID/" \
|
|
|
|
-e "s/^$_x40 /$ZERO_OID /" \
|
|
|
|
-e "s/^$_x40$/$ZERO_OID/" \
|
|
|
|
-e "s/$_x07\.\.$_x07/fffffff..fffffff/g" \
|
|
|
|
-e "s/$_x07,$_x07\.\.$_x07/fffffff,fffffff..fffffff/g" \
|
|
|
|
-e "s/$_x07 $_x07 $_x07/fffffff fffffff fffffff/g" \
|
|
|
|
-e "s/$_x07 $_x07 /fffffff fffffff /g" \
|
|
|
|
-e "s/Merge: $_x07 $_x07/Merge: fffffff fffffff/g" \
|
|
|
|
-e "s/$_x07\.\.\./fffffff.../g" \
|
|
|
|
-e "s/ $_x04\.\.\./ ffff.../g" \
|
|
|
|
-e "s/ $_x04/ ffff/g" \
|
|
|
|
"$1"
|
|
|
|
}
|
|
|
|
|
2014-04-30 20:22:59 +04:00
|
|
|
V=$(git version | sed -e 's/^git version //' -e 's/\./\\./g')
|
2017-12-04 00:27:41 +03:00
|
|
|
while read magic cmd
|
2006-06-27 00:46:52 +04:00
|
|
|
do
|
2017-12-04 00:27:41 +03:00
|
|
|
case "$magic" in
|
|
|
|
'' | '#'*)
|
|
|
|
continue ;;
|
|
|
|
:*)
|
|
|
|
magic=${magic#:}
|
|
|
|
label="$magic-$cmd"
|
|
|
|
case "$magic" in
|
|
|
|
noellipses) ;;
|
|
|
|
*)
|
tests: send "bug in the test script" errors to the script's stderr
Some of the functions in our test library check that they were invoked
properly with conditions like this:
test "$#" = 2 ||
error "bug in the test script: not 2 parameters to test-expect-success"
If this particular condition is triggered, then 'error' will abort the
whole test script with a bold red error message [1] right away.
However, under certain circumstances the test script will be aborted
completely silently, namely if:
- a similar condition in a test helper function like
'test_line_count' is triggered,
- which is invoked from the test script's "main" shell [2],
- and the test script is run manually (i.e. './t1234-foo.sh' as
opposed to 'make t1234-foo.sh' or 'make test') [3]
- and without the '--verbose' option,
because the error message is printed from within 'test_eval_', where
standard output is redirected either to /dev/null or to a log file.
The only indication that something is wrong is that not all tests in
the script are executed and at the end of the test script's output
there is no "# passed all N tests" message, which are subtle and can
easily go unnoticed, as I had to experience myself.
Send these "bug in the test script" error messages directly to the
test scripts standard error and thus to the terminal, so those bugs
will be much harder to overlook. Instead of updating all ~20 such
'error' calls with a redirection, let's add a BUG() function to
'test-lib.sh', wrapping an 'error' call with the proper redirection
and also including the common prefix of those error messages, and
convert all those call sites [4] to use this new BUG() function
instead.
[1] That particular error message from 'test_expect_success' is
printed in color only when running with or without '--verbose';
with '--tee' or '--verbose-log' the error is printed without
color, but it is printed to the terminal nonetheless.
[2] If such a condition is triggered in a subshell of a test, then
'error' won't be able to abort the whole test script, but only the
subshell, which in turn causes the test to fail in the usual way,
indicating loudly and clearly that something is wrong.
[3] Well, 'error' aborts the test script the same way when run
manually or by 'make' or 'prove', but both 'make' and 'prove' pay
attention to the test script's exit status, and even a silently
aborted test script would then trigger those tools' usual
noticable error messages.
[4] Strictly speaking, not all those 'error' calls need that
redirection to send their output to the terminal, see e.g.
'test_expect_success' in the opening example, but I think it's
better to be consistent.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2018-11-19 16:13:26 +03:00
|
|
|
BUG "unknown magic $magic" ;;
|
2017-12-04 00:27:41 +03:00
|
|
|
esac ;;
|
|
|
|
*)
|
|
|
|
cmd="$magic $cmd" magic=
|
|
|
|
label="$cmd" ;;
|
2006-06-27 00:46:52 +04:00
|
|
|
esac
|
2017-12-04 00:27:41 +03:00
|
|
|
test=$(echo "$label" | sed -e 's|[/ ][/ ]*|_|g')
|
2014-04-30 20:22:59 +04:00
|
|
|
pfx=$(printf "%04d" $test_count)
|
2008-08-08 13:26:28 +04:00
|
|
|
expect="$TEST_DIRECTORY/t4013/diff.$test"
|
2006-06-27 00:46:52 +04:00
|
|
|
actual="$pfx-diff.$test"
|
|
|
|
|
2018-08-28 22:38:26 +03:00
|
|
|
test_expect_success "git $cmd # magic is ${magic:-(not used)}" '
|
2006-06-27 00:46:52 +04:00
|
|
|
{
|
2017-12-04 00:27:41 +03:00
|
|
|
echo "$ git $cmd"
|
|
|
|
case "$magic" in
|
|
|
|
"")
|
|
|
|
GIT_PRINT_SHA1_ELLIPSIS=yes git $cmd ;;
|
|
|
|
noellipses)
|
|
|
|
git $cmd ;;
|
|
|
|
esac |
|
2006-08-13 05:04:07 +04:00
|
|
|
sed -e "s/^\\(-*\\)$V\\(-*\\)\$/\\1g-i-t--v-e-r-s-i-o-n\2/" \
|
2007-03-05 03:08:04 +03:00
|
|
|
-e "s/^\\(.*mixed; boundary=\"-*\\)$V\\(-*\\)\"\$/\\1g-i-t--v-e-r-s-i-o-n\2\"/"
|
2006-06-27 00:46:52 +04:00
|
|
|
echo "\$"
|
|
|
|
} >"$actual" &&
|
|
|
|
if test -f "$expect"
|
|
|
|
then
|
2020-02-07 03:52:40 +03:00
|
|
|
process_diffs "$actual" >actual &&
|
|
|
|
process_diffs "$expect" >expect &&
|
2012-03-13 09:05:54 +04:00
|
|
|
case $cmd in
|
|
|
|
*format-patch* | *-stat*)
|
2020-02-07 03:52:40 +03:00
|
|
|
test_i18ncmp expect actual;;
|
2012-03-13 09:05:54 +04:00
|
|
|
*)
|
2020-02-07 03:52:40 +03:00
|
|
|
test_cmp expect actual;;
|
2012-03-13 09:05:54 +04:00
|
|
|
esac &&
|
2020-02-07 03:52:40 +03:00
|
|
|
rm -f "$actual" actual expect
|
2006-06-27 00:46:52 +04:00
|
|
|
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
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff-tree --root --abbrev initial
|
2006-06-27 00:46:52 +04:00
|
|
|
diff-tree --root -r initial
|
|
|
|
diff-tree --root -r --abbrev initial
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff-tree --root -r --abbrev initial
|
2006-06-27 00:46:52 +04:00
|
|
|
diff-tree --root -r --abbrev=4 initial
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff-tree --root -r --abbrev=4 initial
|
2006-06-27 00:46:52 +04:00
|
|
|
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 23:00:12 +04: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-27 00:46:52 +04: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 23:00:12 +04:00
|
|
|
# improved by Timo's patch
|
2006-06-27 00:46:52 +04: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
|
|
|
|
|
2017-09-28 01:51:26 +03:00
|
|
|
diff-tree initial mode
|
|
|
|
diff-tree --stat initial mode
|
|
|
|
diff-tree --summary initial mode
|
|
|
|
|
2006-06-27 00:46:52 +04:00
|
|
|
diff-tree master
|
|
|
|
diff-tree -p master
|
|
|
|
diff-tree -p -m master
|
|
|
|
diff-tree -c master
|
|
|
|
diff-tree -c --abbrev master
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff-tree -c --abbrev master
|
2006-06-27 00:46:52 +04:00
|
|
|
diff-tree --cc master
|
2006-06-27 10:29:11 +04: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
|
2019-01-24 15:34:51 +03:00
|
|
|
diff-tree --cc --shortstat master
|
2019-01-24 15:35:40 +03:00
|
|
|
diff-tree --cc --summary REVERSE
|
2006-06-29 23:00:12 +04:00
|
|
|
# improved by Timo's patch
|
|
|
|
diff-tree --cc --patch-with-stat master
|
|
|
|
# improved by Timo's patch
|
2006-06-27 10:29:11 +04:00
|
|
|
diff-tree --cc --patch-with-stat --summary master
|
|
|
|
# this is correct
|
|
|
|
diff-tree --cc --patch-with-stat --summary side
|
2006-06-27 00:46:52 +04: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 10:29:11 +04:00
|
|
|
log --root --patch-with-stat --summary master
|
2006-06-29 23:00:12 +04:00
|
|
|
# improved by Timo's patch
|
2006-06-27 10:29:11 +04:00
|
|
|
log --root -c --patch-with-stat --summary master
|
2006-06-29 23:00:12 +04:00
|
|
|
# improved by Timo's patch
|
2006-06-27 10:29:11 +04:00
|
|
|
log --root --cc --patch-with-stat --summary master
|
2010-03-09 08:11:40 +03:00
|
|
|
log -p --first-parent master
|
|
|
|
log -m -p --first-parent master
|
|
|
|
log -m -p master
|
2006-06-27 00:46:52 +04:00
|
|
|
log -SF master
|
2010-08-05 12:22:52 +04:00
|
|
|
log -S F master
|
2006-06-27 10:29:11 +04:00
|
|
|
log -SF -p master
|
2011-03-09 23:52:15 +03:00
|
|
|
log -SF master --max-count=0
|
|
|
|
log -SF master --max-count=1
|
|
|
|
log -SF master --max-count=2
|
2010-09-01 01:27:41 +04:00
|
|
|
log -GF master
|
|
|
|
log -GF -p master
|
|
|
|
log -GF -p --pickaxe-all master
|
2009-02-19 14:13:40 +03:00
|
|
|
log --decorate --all
|
2009-08-15 18:23:12 +04:00
|
|
|
log --decorate=full --all
|
2006-06-27 00:46:52 +04:00
|
|
|
|
2009-02-19 14:13:41 +03:00
|
|
|
rev-list --parents HEAD
|
|
|
|
rev-list --children HEAD
|
2006-06-27 00:46:52 +04:00
|
|
|
|
|
|
|
whatchanged master
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses whatchanged master
|
2006-06-27 00:46:52 +04:00
|
|
|
whatchanged -p master
|
|
|
|
whatchanged --root master
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses whatchanged --root master
|
2006-06-27 00:46:52 +04:00
|
|
|
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 23:00:12 +04:00
|
|
|
# improved by Timo's patch
|
2006-06-27 10:29:11 +04:00
|
|
|
whatchanged --root -c --patch-with-stat --summary master
|
2006-06-29 23:00:12 +04:00
|
|
|
# improved by Timo's patch
|
2006-06-27 10:29:11 +04:00
|
|
|
whatchanged --root --cc --patch-with-stat --summary master
|
2006-06-27 00:46:52 +04:00
|
|
|
whatchanged -SF master
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses whatchanged -SF master
|
2006-06-27 10:29:11 +04:00
|
|
|
whatchanged -SF -p master
|
2006-06-27 00:46:52 +04:00
|
|
|
|
|
|
|
log --patch-with-stat master -- dir/
|
|
|
|
whatchanged --patch-with-stat master -- dir/
|
2006-06-27 10:29:11 +04:00
|
|
|
log --patch-with-stat --summary master -- dir/
|
|
|
|
whatchanged --patch-with-stat --summary master -- dir/
|
2006-06-27 00:46:52 +04:00
|
|
|
|
|
|
|
show initial
|
|
|
|
show --root initial
|
|
|
|
show side
|
|
|
|
show master
|
2010-03-09 10:27:25 +03:00
|
|
|
show -c master
|
2010-03-09 11:22:54 +03:00
|
|
|
show -m master
|
|
|
|
show --first-parent master
|
2006-06-27 00:46:52 +04:00
|
|
|
show --stat side
|
|
|
|
show --stat --summary side
|
|
|
|
show --patch-with-stat side
|
|
|
|
show --patch-with-raw side
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses show --patch-with-raw side
|
2006-06-27 00:46:52 +04:00
|
|
|
show --patch-with-stat --summary side
|
|
|
|
|
2006-06-29 11:01:07 +04:00
|
|
|
format-patch --stdout initial..side
|
|
|
|
format-patch --stdout initial..master^
|
|
|
|
format-patch --stdout initial..master
|
2008-10-03 00:55:39 +04:00
|
|
|
format-patch --stdout --no-numbered initial..master
|
|
|
|
format-patch --stdout --numbered initial..master
|
2006-06-29 11:01:07 +04:00
|
|
|
format-patch --attach --stdout initial..side
|
2009-03-23 05:14:05 +03:00
|
|
|
format-patch --attach --stdout --suffix=.diff initial..side
|
2006-06-29 11:01:07 +04:00
|
|
|
format-patch --attach --stdout initial..master^
|
|
|
|
format-patch --attach --stdout initial..master
|
2007-03-04 02:12:06 +03:00
|
|
|
format-patch --inline --stdout initial..side
|
|
|
|
format-patch --inline --stdout initial..master^
|
2009-03-23 05:14:06 +03:00
|
|
|
format-patch --inline --stdout --numbered-files initial..master
|
2008-10-03 00:55:39 +04:00
|
|
|
format-patch --inline --stdout initial..master
|
2007-04-12 03:58:08 +04:00
|
|
|
format-patch --inline --stdout --subject-prefix=TESTCASE initial..master
|
2007-07-02 04:48:59 +04:00
|
|
|
config format.subjectprefix DIFFERENT_PREFIX
|
|
|
|
format-patch --inline --stdout initial..master^^
|
2008-02-19 06:56:13 +03:00
|
|
|
format-patch --stdout --cover-letter -n initial..master^
|
2006-06-29 11:01:07 +04:00
|
|
|
|
2006-07-02 09:02:17 +04:00
|
|
|
diff --abbrev initial..side
|
2019-05-29 12:11:15 +03:00
|
|
|
diff -U initial..side
|
|
|
|
diff -U1 initial..side
|
2006-07-02 09:02:17 +04:00
|
|
|
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
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff --patch-with-raw initial..side
|
2006-07-02 09:02:17 +04:00
|
|
|
diff --patch-with-stat -r initial..side
|
|
|
|
diff --patch-with-raw -r initial..side
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff --patch-with-raw -r initial..side
|
2007-07-03 19:01:06 +04:00
|
|
|
diff --name-status dir2 dir
|
2008-05-24 09:28:56 +04:00
|
|
|
diff --no-index --name-status dir2 dir
|
2009-01-06 21:53:32 +03:00
|
|
|
diff --no-index --name-status -- dir2 dir
|
2009-02-18 09:48:06 +03:00
|
|
|
diff --no-index dir dir3
|
2008-10-11 05:56:15 +04:00
|
|
|
diff master master^ side
|
2016-09-01 02:27:20 +03:00
|
|
|
# Can't use spaces...
|
|
|
|
diff --line-prefix=abc master master^ side
|
2009-02-19 14:13:37 +03:00
|
|
|
diff --dirstat master~1 master~2
|
2011-04-11 02:48:50 +04:00
|
|
|
diff --dirstat initial rearrange
|
2011-04-11 02:48:51 +04:00
|
|
|
diff --dirstat-by-file initial rearrange
|
2019-01-24 15:36:47 +03:00
|
|
|
diff --dirstat --cc master~1 master
|
diff: handle --no-abbrev in no-index case
There are two different places where the --no-abbrev option is parsed,
and two different places where SHA-1s are abbreviated. We normally parse
--no-abbrev with setup_revisions(), but in the no-index case, "git diff"
calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
--no-abbrev until now. (It did handle --abbrev, however.) We normally
abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666 ("diff:
handle sha1 abbreviations outside of repository, 2016-10-20) recently
introduced a special case when you run "git diff" outside of a
repository.
setup_revisions() does also call diff_opt_parse(), but not for --abbrev
or --no-abbrev, which it handles itself. setup_revisions() sets
rev_info->abbrev, and later copies that to diff_options->abbrev. It
handles --no-abbrev by setting abbrev to zero. (This change doesn't
touch that.)
Setting abbrev to zero was broken in the outside-of-a-repository special
case, which until now resulted in a truly zero-length SHA-1, rather than
taking zero to mean do not abbreviate. The only way to trigger this bug,
however, was by running "git diff --raw" without either the --abbrev or
--no-abbrev options, because 1) without --raw it doesn't respect abbrev
(which is bizarre, but has been that way forever), 2) we silently clamp
--abbrev=0 to MINIMUM_ABBREV, and 3) --no-abbrev wasn't handled until
now.
The outside-of-a-repository case is one of three no-index cases. The
other two are when one of the files you're comparing is outside of the
repository you're in, and the --no-index option.
Signed-off-by: Jack Bates <jack@nottheoilrig.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-12-06 19:56:14 +03:00
|
|
|
# No-index --abbrev and --no-abbrev
|
|
|
|
diff --raw initial
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff --raw initial
|
diff: handle --no-abbrev in no-index case
There are two different places where the --no-abbrev option is parsed,
and two different places where SHA-1s are abbreviated. We normally parse
--no-abbrev with setup_revisions(), but in the no-index case, "git diff"
calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
--no-abbrev until now. (It did handle --abbrev, however.) We normally
abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666 ("diff:
handle sha1 abbreviations outside of repository, 2016-10-20) recently
introduced a special case when you run "git diff" outside of a
repository.
setup_revisions() does also call diff_opt_parse(), but not for --abbrev
or --no-abbrev, which it handles itself. setup_revisions() sets
rev_info->abbrev, and later copies that to diff_options->abbrev. It
handles --no-abbrev by setting abbrev to zero. (This change doesn't
touch that.)
Setting abbrev to zero was broken in the outside-of-a-repository special
case, which until now resulted in a truly zero-length SHA-1, rather than
taking zero to mean do not abbreviate. The only way to trigger this bug,
however, was by running "git diff --raw" without either the --abbrev or
--no-abbrev options, because 1) without --raw it doesn't respect abbrev
(which is bizarre, but has been that way forever), 2) we silently clamp
--abbrev=0 to MINIMUM_ABBREV, and 3) --no-abbrev wasn't handled until
now.
The outside-of-a-repository case is one of three no-index cases. The
other two are when one of the files you're comparing is outside of the
repository you're in, and the --no-index option.
Signed-off-by: Jack Bates <jack@nottheoilrig.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-12-06 19:56:14 +03:00
|
|
|
diff --raw --abbrev=4 initial
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff --raw --abbrev=4 initial
|
diff: handle --no-abbrev in no-index case
There are two different places where the --no-abbrev option is parsed,
and two different places where SHA-1s are abbreviated. We normally parse
--no-abbrev with setup_revisions(), but in the no-index case, "git diff"
calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
--no-abbrev until now. (It did handle --abbrev, however.) We normally
abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666 ("diff:
handle sha1 abbreviations outside of repository, 2016-10-20) recently
introduced a special case when you run "git diff" outside of a
repository.
setup_revisions() does also call diff_opt_parse(), but not for --abbrev
or --no-abbrev, which it handles itself. setup_revisions() sets
rev_info->abbrev, and later copies that to diff_options->abbrev. It
handles --no-abbrev by setting abbrev to zero. (This change doesn't
touch that.)
Setting abbrev to zero was broken in the outside-of-a-repository special
case, which until now resulted in a truly zero-length SHA-1, rather than
taking zero to mean do not abbreviate. The only way to trigger this bug,
however, was by running "git diff --raw" without either the --abbrev or
--no-abbrev options, because 1) without --raw it doesn't respect abbrev
(which is bizarre, but has been that way forever), 2) we silently clamp
--abbrev=0 to MINIMUM_ABBREV, and 3) --no-abbrev wasn't handled until
now.
The outside-of-a-repository case is one of three no-index cases. The
other two are when one of the files you're comparing is outside of the
repository you're in, and the --no-index option.
Signed-off-by: Jack Bates <jack@nottheoilrig.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-12-06 19:56:14 +03:00
|
|
|
diff --raw --no-abbrev initial
|
|
|
|
diff --no-index --raw dir2 dir
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff --no-index --raw dir2 dir
|
diff: handle --no-abbrev in no-index case
There are two different places where the --no-abbrev option is parsed,
and two different places where SHA-1s are abbreviated. We normally parse
--no-abbrev with setup_revisions(), but in the no-index case, "git diff"
calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
--no-abbrev until now. (It did handle --abbrev, however.) We normally
abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666 ("diff:
handle sha1 abbreviations outside of repository, 2016-10-20) recently
introduced a special case when you run "git diff" outside of a
repository.
setup_revisions() does also call diff_opt_parse(), but not for --abbrev
or --no-abbrev, which it handles itself. setup_revisions() sets
rev_info->abbrev, and later copies that to diff_options->abbrev. It
handles --no-abbrev by setting abbrev to zero. (This change doesn't
touch that.)
Setting abbrev to zero was broken in the outside-of-a-repository special
case, which until now resulted in a truly zero-length SHA-1, rather than
taking zero to mean do not abbreviate. The only way to trigger this bug,
however, was by running "git diff --raw" without either the --abbrev or
--no-abbrev options, because 1) without --raw it doesn't respect abbrev
(which is bizarre, but has been that way forever), 2) we silently clamp
--abbrev=0 to MINIMUM_ABBREV, and 3) --no-abbrev wasn't handled until
now.
The outside-of-a-repository case is one of three no-index cases. The
other two are when one of the files you're comparing is outside of the
repository you're in, and the --no-index option.
Signed-off-by: Jack Bates <jack@nottheoilrig.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-12-06 19:56:14 +03:00
|
|
|
diff --no-index --raw --abbrev=4 dir2 dir
|
2017-12-04 00:27:43 +03:00
|
|
|
:noellipses diff --no-index --raw --abbrev=4 dir2 dir
|
diff: handle --no-abbrev in no-index case
There are two different places where the --no-abbrev option is parsed,
and two different places where SHA-1s are abbreviated. We normally parse
--no-abbrev with setup_revisions(), but in the no-index case, "git diff"
calls diff_opt_parse() directly, and diff_opt_parse() didn't handle
--no-abbrev until now. (It did handle --abbrev, however.) We normally
abbreviate SHA-1s with find_unique_abbrev(), but commit 4f03666 ("diff:
handle sha1 abbreviations outside of repository, 2016-10-20) recently
introduced a special case when you run "git diff" outside of a
repository.
setup_revisions() does also call diff_opt_parse(), but not for --abbrev
or --no-abbrev, which it handles itself. setup_revisions() sets
rev_info->abbrev, and later copies that to diff_options->abbrev. It
handles --no-abbrev by setting abbrev to zero. (This change doesn't
touch that.)
Setting abbrev to zero was broken in the outside-of-a-repository special
case, which until now resulted in a truly zero-length SHA-1, rather than
taking zero to mean do not abbreviate. The only way to trigger this bug,
however, was by running "git diff --raw" without either the --abbrev or
--no-abbrev options, because 1) without --raw it doesn't respect abbrev
(which is bizarre, but has been that way forever), 2) we silently clamp
--abbrev=0 to MINIMUM_ABBREV, and 3) --no-abbrev wasn't handled until
now.
The outside-of-a-repository case is one of three no-index cases. The
other two are when one of the files you're comparing is outside of the
repository you're in, and the --no-index option.
Signed-off-by: Jack Bates <jack@nottheoilrig.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-12-06 19:56:14 +03:00
|
|
|
diff --no-index --raw --no-abbrev dir2 dir
|
2018-02-24 17:09:59 +03:00
|
|
|
|
|
|
|
diff-tree --pretty --root --stat --compact-summary initial
|
|
|
|
diff-tree --pretty -R --root --stat --compact-summary initial
|
|
|
|
diff-tree --stat --compact-summary initial mode
|
|
|
|
diff-tree -R --stat --compact-summary initial mode
|
2006-06-27 00:46:52 +04:00
|
|
|
EOF
|
|
|
|
|
2010-08-05 12:22:52 +04:00
|
|
|
test_expect_success 'log -S requires an argument' '
|
|
|
|
test_must_fail git log -S
|
|
|
|
'
|
|
|
|
|
2011-02-03 09:23:34 +03:00
|
|
|
test_expect_success 'diff --cached on unborn branch' '
|
|
|
|
echo ref: refs/heads/unborn >.git/HEAD &&
|
|
|
|
git diff --cached >result &&
|
2020-02-07 03:52:40 +03:00
|
|
|
process_diffs result >actual &&
|
|
|
|
process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached" >expected &&
|
|
|
|
test_cmp expected actual
|
2011-02-03 09:23:34 +03:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'diff --cached -- file on unborn branch' '
|
|
|
|
git diff --cached -- file0 >result &&
|
2020-02-07 03:52:40 +03:00
|
|
|
process_diffs result >actual &&
|
|
|
|
process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached_--_file0" >expected &&
|
|
|
|
test_cmp expected actual
|
2011-02-03 09:23:34 +03:00
|
|
|
'
|
2016-09-01 02:27:20 +03:00
|
|
|
test_expect_success 'diff --line-prefix with spaces' '
|
|
|
|
git diff --line-prefix="| | | " --cached -- file0 >result &&
|
2020-02-07 03:52:40 +03:00
|
|
|
process_diffs result >actual &&
|
|
|
|
process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--line-prefix_--cached_--_file0" >expected &&
|
|
|
|
test_cmp expected actual
|
2016-09-01 02:27:20 +03:00
|
|
|
'
|
2011-02-03 09:23:34 +03:00
|
|
|
|
2014-07-28 22:01:57 +04:00
|
|
|
test_expect_success 'diff-tree --stdin with log formatting' '
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
Side
|
|
|
|
Third
|
|
|
|
Second
|
|
|
|
EOF
|
|
|
|
git rev-list master | git diff-tree --stdin --format=%s -s >actual &&
|
|
|
|
test_cmp expect actual
|
|
|
|
'
|
|
|
|
|
2006-06-27 00:46:52 +04:00
|
|
|
test_done
|