Merge branch 'nd/combined-test-helper'
[git.git] / t / t9124-git-svn-dcommit-auto-props.sh
blob9f7231d5b7dae28b55316e9e24968f4e5fe06664
1 #!/bin/sh
3 # Copyright (c) 2008 Brad King
5 test_description='git svn dcommit honors auto-props'
7 . ./lib-git-svn.sh
9 generate_auto_props() {
10 cat << EOF
11 [miscellany]
12 enable-auto-props=$1
13 [auto-props]
14 *.sh = svn:mime-type=application/x-shellscript; svn:eol-style=LF
15 *.txt = svn:mime-type=text/plain; svn:eol-style = native
16 EOF
19 test_expect_success 'initialize git svn' '
20 mkdir import &&
22 cd import &&
23 echo foo >foo &&
24 svn_cmd import -m "import for git svn" . "$svnrepo"
25 ) &&
26 rm -rf import &&
27 git svn init "$svnrepo" &&
28 git svn fetch
31 test_expect_success 'enable auto-props config' '
32 mkdir user &&
33 generate_auto_props yes >user/config
36 test_expect_success 'add files matching auto-props' '
37 write_script exec1.sh </dev/null &&
38 echo "hello" >hello.txt &&
39 echo bar >bar &&
40 git add exec1.sh hello.txt bar &&
41 git commit -m "files for enabled auto-props" &&
42 git svn dcommit --config-dir=user
45 test_expect_success 'disable auto-props config' '
46 generate_auto_props no >user/config
49 test_expect_success 'add files matching disabled auto-props' '
50 write_script exec2.sh </dev/null &&
51 echo "world" >world.txt &&
52 echo zot >zot &&
53 git add exec2.sh world.txt zot &&
54 git commit -m "files for disabled auto-props" &&
55 git svn dcommit --config-dir=user
58 test_expect_success 'check resulting svn repository' '
60 mkdir work &&
61 cd work &&
62 svn_cmd co "$svnrepo" &&
63 cd svnrepo &&
65 # Check properties from first commit.
66 if test_have_prereq POSIXPERM
67 then
68 test "x$(svn_cmd propget svn:executable exec1.sh)" = "x*"
69 fi &&
70 test "x$(svn_cmd propget svn:mime-type exec1.sh)" = \
71 "xapplication/x-shellscript" &&
72 test "x$(svn_cmd propget svn:mime-type hello.txt)" = "xtext/plain" &&
73 test "x$(svn_cmd propget svn:eol-style hello.txt)" = "xnative" &&
74 test "x$(svn_cmd propget svn:mime-type bar)" = "x" &&
76 # Check properties from second commit.
77 if test_have_prereq POSIXPERM
78 then
79 test "x$(svn_cmd propget svn:executable exec2.sh)" = "x*"
80 fi &&
81 test "x$(svn_cmd propget svn:mime-type exec2.sh)" = "x" &&
82 test "x$(svn_cmd propget svn:mime-type world.txt)" = "x" &&
83 test "x$(svn_cmd propget svn:eol-style world.txt)" = "x" &&
84 test "x$(svn_cmd propget svn:mime-type zot)" = "x"
88 test_expect_success 'check renamed file' '
89 test -d user &&
90 generate_auto_props yes > user/config &&
91 git mv foo foo.sh &&
92 git commit -m "foo => foo.sh" &&
93 git svn dcommit --config-dir=user &&
95 cd work/svnrepo &&
96 svn_cmd up &&
97 test ! -e foo &&
98 test -e foo.sh &&
99 test "x$(svn_cmd propget svn:mime-type foo.sh)" = \
100 "xapplication/x-shellscript" &&
101 test "x$(svn_cmd propget svn:eol-style foo.sh)" = "xLF"
105 test_done