2005-05-25 23:00:04 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2005 Junio C Hamano
|
|
|
|
#
|
|
|
|
|
|
|
|
test_description='Test mode change diffs.
|
|
|
|
|
|
|
|
'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2012-05-01 17:10:12 +00:00
|
|
|
sed_script='s/\(:100644 100755\) \('"$_x40"'\) \2 /\1 X X /'
|
2005-05-25 23:00:04 +00:00
|
|
|
|
2012-05-01 17:10:12 +00:00
|
|
|
test_expect_success 'setup' '
|
|
|
|
echo frotz >rezrov &&
|
|
|
|
git update-index --add rezrov &&
|
|
|
|
tree=`git write-tree` &&
|
|
|
|
echo $tree
|
|
|
|
'
|
2005-05-25 23:00:04 +00:00
|
|
|
|
2012-05-01 17:10:12 +00:00
|
|
|
test_expect_success 'chmod' '
|
|
|
|
test_chmod +x rezrov &&
|
|
|
|
git diff-index $tree >current &&
|
|
|
|
sed -e "$sed_script" <current >check &&
|
|
|
|
echo ":100644 100755 X X M rezrov" >expected &&
|
|
|
|
test_cmp expected check
|
|
|
|
'
|
2005-05-25 23:00:04 +00:00
|
|
|
|
2012-05-01 17:10:13 +00:00
|
|
|
test_expect_success 'prepare binary file' '
|
|
|
|
git commit -m rezrov &&
|
2012-05-02 07:36:44 +00:00
|
|
|
printf "\00\01\02\03\04\05\06" >binbin &&
|
2012-05-01 17:10:13 +00:00
|
|
|
git add binbin &&
|
|
|
|
git commit -m binbin
|
|
|
|
'
|
|
|
|
|
Fix "git diff --stat" for interesting - but empty - file changes
The behavior of "git diff --stat" is rather odd for files that have
zero lines of changes: it will discount them entirely unless they were
renames.
Which means that the stat output will simply not show files that only
had "other" changes: they were created or deleted, or their mode was
changed.
Now, those changes do show up in the summary, but so do renames, so
the diffstat logic is inconsistent. Why does it show renames with zero
lines changed, but not mode changes or added files with zero lines
changed?
So change the logic to not check for "is_renamed", but for
"is_interesting" instead, where "interesting" is judged to be any
action but a pure data change (because a pure data change with zero
data changed really isn't worth showing, if we ever get one in our
diffpairs).
So if you did
chmod +x Makefile
git diff --stat
before, it would show empty (" 0 files changed"), with this it shows
Makefile | 0
1 file changed, 0 insertions(+), 0 deletions(-)
which I think is a more correct diffstat (and then with "--summary" it
shows *what* the metadata change to Makefile was - this is completely
consistent with our handling of renamed files).
Side note: the old behavior was *really* odd. With no changes at all,
"git diff --stat" output was empty. With just a chmod, it said "0
files changed". No way is our legacy behavior sane.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-10-17 17:00:37 +00:00
|
|
|
# test_expect_success '--stat output after text chmod' '
|
|
|
|
# test_chmod -x rezrov &&
|
|
|
|
# echo " 0 files changed" >expect &&
|
|
|
|
# git diff HEAD --stat >actual &&
|
|
|
|
# test_i18ncmp expect actual
|
|
|
|
# '
|
|
|
|
#
|
|
|
|
# test_expect_success '--shortstat output after text chmod' '
|
|
|
|
# git diff HEAD --shortstat >actual &&
|
|
|
|
# test_i18ncmp expect actual
|
|
|
|
# '
|
|
|
|
#
|
|
|
|
# test_expect_success '--stat output after binary chmod' '
|
|
|
|
# test_chmod +x binbin &&
|
|
|
|
# echo " 0 files changed" >expect &&
|
|
|
|
# git diff HEAD --stat >actual &&
|
|
|
|
# test_i18ncmp expect actual
|
|
|
|
# '
|
|
|
|
#
|
|
|
|
# test_expect_success '--shortstat output after binary chmod' '
|
|
|
|
# git diff HEAD --shortstat >actual &&
|
|
|
|
# test_i18ncmp expect actual
|
|
|
|
# '
|
2012-05-01 17:10:13 +00:00
|
|
|
|
2005-05-25 23:00:04 +00:00
|
|
|
test_done
|