commit - 8c35ff140a39c592c937c6ddbf5e723e95a6fbfa
commit + dffd0deb2bcfd6ec499f8c026c01afd41369b3a6
blob - 4c4531a4ae60dadd0d142ce72c1daa296710eefb
blob + 40f48b0786ea4b80be8d254a65d81296572408a1
--- regress/cmdline/diff.sh
+++ regress/cmdline/diff.sh
ret="$?"
if [ "$ret" != "0" ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ fi
+ test_done "$testroot" "$ret"
+}
+
+test_diff_binary_files() {
+ local testroot=`test_init diff_binary_files`
+ local head_rev=`git_show_head $testroot/repo`
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ test_done "$testroot" "$ret"
+ return 1
+ fi
+
+ printf '\377\377\0\0\377\377\0\0' > $testroot/wt/foo
+ (cd $testroot/wt && got add foo >/dev/null)
+
+ echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
+ echo 'blob - /dev/null' >> $testroot/stdout.expected
+ echo 'file + foo' >> $testroot/stdout.expected
+ echo '--- foo' >> $testroot/stdout.expected
+ echo '+++ foo' >> $testroot/stdout.expected
+ echo '@@ -0,0 +1 @@' >> $testroot/stdout.expected
+ printf '+\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
+ echo '\\ No newline at end of file' >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got diff > $testroot/stdout)
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -a -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$ret"
+ return 1
fi
+
+ (cd $testroot/wt && got commit -m 'add binary file' > /dev/null)
+ local head_rev=`git_show_head $testroot/repo`
+
+ printf '\377\200\0\0\377\200\0\0' > $testroot/wt/foo
+
+ echo "diff $head_rev $testroot/wt" > $testroot/stdout.expected
+ echo -n 'blob - ' >> $testroot/stdout.expected
+ got tree -r $testroot/repo -i | grep 'foo$' | cut -d' ' -f 1 \
+ >> $testroot/stdout.expected
+ echo 'file + foo' >> $testroot/stdout.expected
+ echo '--- foo' >> $testroot/stdout.expected
+ echo '+++ foo' >> $testroot/stdout.expected
+ echo '@@ -1 +1 @@' >> $testroot/stdout.expected
+ printf '-\377\377\0\0\377\377\0\0\n' >> $testroot/stdout.expected
+ echo '\\ No newline at end of file' >> $testroot/stdout.expected
+ printf '+\377\200\0\0\377\200\0\0\n' >> $testroot/stdout.expected
+ echo '\\ No newline at end of file' >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got diff > $testroot/stdout)
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret="$?"
+ if [ "$ret" != "0" ]; then
+ diff -a -u $testroot/stdout.expected $testroot/stdout
+ fi
test_done "$testroot" "$ret"
}
run_test test_diff_submodule_of_same_repo
run_test test_diff_symlinks_in_work_tree
run_test test_diff_symlinks_in_repo
+run_test test_diff_binary_files