test: Differentiate ability for gnu utils to handle symlinks from git
[git/mingw/4msysgit.git] / t / t7410-submodule-long-path.sh
blob59b3d347db528f9cf4afd2e949a0066db76e4dc0
1 #!/bin/sh
3 # Copyright (c) 2013 Doug Kelly
6 test_description='Test submodules with a path near PATH_MAX
8 This test verifies that "git submodule" initialization, update and clones work, including with recursive submodules and paths approaching PATH_MAX (260 characters on Windows)
11 TEST_NO_CREATE_REPO=1
12 . ./test-lib.sh
14 # cloning a submodule calls is_git_directory("$path/../.git/modules/$path"),
15 # which effectively limits the maximum length to PATH_MAX / 2 minus some
16 # overhead; start with 3 * 36 = 108 chars (test 2 fails if >= 110)
17 longpath36=0123456789abcdefghijklmnopqrstuvwxyz
18 longpath180=$longpath36$longpath36$longpath36$longpath36$longpath36
20 # the git database must fit within PATH_MAX, which limits the submodule name
21 # to PATH_MAX - len(pwd) - ~90 (= len("/objects//") + 40-byte sha1 + some
22 # overhead from the test case)
23 pwd=$(pwd)
24 pwdlen=$(echo "$pwd" | wc -c)
25 longpath=$(echo $longpath180 | cut -c 1-$((170-$pwdlen)))
27 test_expect_success 'submodule with a long path' '
28 git init --bare remote &&
29 test_create_repo bundle1 &&
31 cd bundle1 &&
32 test_commit "shoot" &&
33 git rev-parse --verify HEAD >../expect
34 ) &&
35 mkdir home &&
37 cd home &&
38 git clone ../remote test &&
39 cd test &&
40 git submodule add ../bundle1 $longpath &&
41 test_commit "sogood" &&
43 cd $longpath &&
44 git rev-parse --verify HEAD >actual &&
45 test_cmp ../../../expect actual
46 ) &&
47 git push origin master
48 ) &&
49 mkdir home2 &&
51 cd home2 &&
52 git clone ../remote test &&
53 cd test &&
54 git checkout master &&
55 git submodule update --init &&
57 cd $longpath &&
58 git rev-parse --verify HEAD >actual &&
59 test_cmp ../../../expect actual
64 test_expect_success 'recursive submodule with a long path' '
65 git init --bare super &&
66 test_create_repo child &&
68 cd child &&
69 test_commit "shoot" &&
70 git rev-parse --verify HEAD >../expect
71 ) &&
72 test_create_repo parent &&
74 cd parent &&
75 git submodule add ../child $longpath &&
76 test_commit "aim"
77 ) &&
78 mkdir home3 &&
80 cd home3 &&
81 git clone ../super test &&
82 cd test &&
83 git submodule add ../parent foo &&
84 git submodule update --init --recursive
85 test_commit "sogood" &&
87 cd foo/$longpath &&
88 git rev-parse --verify HEAD >actual &&
89 test_cmp ../../../../expect actual
90 ) &&
91 git push origin master
92 ) &&
93 mkdir home4 &&
95 cd home4 &&
96 git clone ../super test --recursive &&
98 cd test/foo/$longpath &&
99 git rev-parse --verify HEAD >actual &&
100 test_cmp ../../../../expect actual
105 test_done