diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t1300-repo-config.sh | 31 | ||||
-rwxr-xr-x | t/t4012-diff-binary.sh | 85 | ||||
-rwxr-xr-x | t/t5700-clone-reference.sh | 78 | ||||
-rw-r--r-- | t/test4012.png | bin | 0 -> 5660 bytes |
4 files changed, 194 insertions, 0 deletions
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 1bf728fb0..7090ea92c 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -278,5 +278,36 @@ git-repo-config > output 2>&1 test_expect_success 'no arguments, but no crash' \ "test $? = 129 && grep usage output" +cat > .git/config << EOF +[a.b] + c = d +EOF + +git-repo-config a.x y + +cat > expect << EOF +[a.b] + c = d +[a] + x = y +EOF + +test_expect_success 'new section is partial match of another' 'cmp .git/config expect' + +git-repo-config b.x y +git-repo-config a.b c + +cat > expect << EOF +[a.b] + c = d +[a] + x = y + b = c +[b] + x = y +EOF + +test_expect_success 'new variable inserts into proper section' 'cmp .git/config expect' + test_done diff --git a/t/t4012-diff-binary.sh b/t/t4012-diff-binary.sh new file mode 100755 index 000000000..bdd95c0d3 --- /dev/null +++ b/t/t4012-diff-binary.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# +# Copyright (c) 2006 Junio C Hamano +# + +test_description='Binary diff and apply +' + +. ./test-lib.sh + +test_expect_success 'prepare repository' \ + 'echo AIT >a && echo BIT >b && echo CIT >c && echo DIT >d && + git-update-index --add a b c d && + echo git >a && + cat ../test4012.png >b && + echo git >c && + cat b b >d' + +test_expect_success 'diff without --binary' \ + 'git-diff | git-apply --stat --summary >current && + cmp current - <<\EOF + a | 2 +- + b | Bin + c | 2 +- + d | Bin + 4 files changed, 2 insertions(+), 2 deletions(-) +EOF' + +test_expect_success 'diff with --binary' \ + 'git-diff --binary | git-apply --stat --summary >current && + cmp current - <<\EOF + a | 2 +- + b | Bin + c | 2 +- + d | Bin + 4 files changed, 2 insertions(+), 2 deletions(-) +EOF' + +# apply needs to be able to skip the binary material correctly +# in order to report the line number of a corrupt patch. +test_expect_success 'apply detecting corrupt patch correctly' \ + 'git-diff | sed -e 's/-CIT/xCIT/' >broken && + if git-apply --stat --summary broken 2>detected + then + echo unhappy - should have detected an error + (exit 1) + else + echo happy + fi && + detected=`cat detected` && + detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` && + detected=`sed -ne "${detected}p" broken` && + test "$detected" = xCIT' + +test_expect_success 'apply detecting corrupt patch correctly' \ + 'git-diff --binary | sed -e 's/-CIT/xCIT/' >broken && + if git-apply --stat --summary broken 2>detected + then + echo unhappy - should have detected an error + (exit 1) + else + echo happy + fi && + detected=`cat detected` && + detected=`expr "$detected" : "fatal.*at line \\([0-9]*\\)\$"` && + detected=`sed -ne "${detected}p" broken` && + test "$detected" = xCIT' + +test_expect_success 'initial commit' 'git-commit -a -m initial' + +# Try removal (b), modification (d), and creation (e). +test_expect_success 'diff-index with --binary' \ + 'echo AIT >a && mv b e && echo CIT >c && cat e >d && + git-update-index --add --remove a b c d e && + tree0=`git-write-tree` && + git-diff --cached --binary >current && + git-apply --stat --summary current' + +test_expect_success 'apply binary patch' \ + 'git-reset --hard && + git-apply --binary --index <current && + tree1=`git-write-tree` && + test "$tree1" = "$tree0"' + +test_done diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh new file mode 100755 index 000000000..916ee15ba --- /dev/null +++ b/t/t5700-clone-reference.sh @@ -0,0 +1,78 @@ +#!/bin/sh +# +# Copyright (C) 2006 Martin Waitz <tali@admingilde.org> +# + +test_description='test clone --reference' +. ./test-lib.sh + +base_dir=`pwd` + +test_expect_success 'preparing first repository' \ +'test_create_repo A && cd A && +echo first > file1 && +git add file1 && +git commit -m initial' + +cd "$base_dir" + +test_expect_success 'preparing second repository' \ +'git clone A B && cd B && +echo second > file2 && +git add file2 && +git commit -m addition && +git repack -a -d && +git prune' + +cd "$base_dir" + +test_expect_success 'cloning with reference' \ +'git clone -l -s --reference B A C' + +cd "$base_dir" + +test_expect_success 'existance of info/alternates' \ +'test `wc -l <C/.git/objects/info/alternates` = 2' + +cd "$base_dir" + +test_expect_success 'pulling from reference' \ +'cd C && +git pull ../B' + +cd "$base_dir" + +test_expect_success 'that reference gets used' \ +'cd C && +echo "0 objects, 0 kilobytes" > expected && +git count-objects > current && +diff expected current' + +cd "$base_dir" + +test_expect_success 'updating origin' \ +'cd A && +echo third > file3 && +git add file3 && +git commit -m update && +git repack -a -d && +git prune' + +cd "$base_dir" + +test_expect_success 'pulling changes from origin' \ +'cd C && +git pull origin' + +cd "$base_dir" + +# the 2 local objects are commit and tree from the merge +test_expect_success 'that alternate to origin gets used' \ +'cd C && +echo "2 objects" > expected && +git count-objects | cut -d, -f1 > current && +diff expected current' + +cd "$base_dir" + +test_done diff --git a/t/test4012.png b/t/test4012.png Binary files differnew file mode 100644 index 000000000..7b181d15c --- /dev/null +++ b/t/test4012.png |