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)
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)
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 &&
32 test_commit "shoot" &&
33 git rev-parse --verify HEAD >../expect
38 git clone ../remote test &&
40 git submodule add ../bundle1 $longpath &&
41 test_commit "sogood" &&
44 git rev-parse --verify HEAD >actual &&
45 test_cmp ../../../expect actual
47 git push origin master
52 git clone ../remote test &&
54 git checkout master &&
55 git submodule update --init &&
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 &&
69 test_commit "shoot" &&
70 git rev-parse --verify HEAD >../expect
72 test_create_repo parent &&
75 git submodule add ../child $longpath &&
81 git clone ../super test &&
83 git submodule add ../parent foo &&
84 git submodule update --init --recursive
85 test_commit "sogood" &&
88 git rev-parse --verify HEAD >actual &&
89 test_cmp ../../../../expect actual
91 git push origin master
96 git clone ../super test --recursive &&
98 cd test/foo/$longpath &&
99 git rev-parse --verify HEAD >actual &&
100 test_cmp ../../../../expect actual