|  | 
|  | 1 | +#!/bin/sh | 
|  | 2 | +# | 
|  | 3 | +# Copyright (c) 2013 Doug Kelly | 
|  | 4 | +# | 
|  | 5 | + | 
|  | 6 | +test_description='Test submodules with a path near PATH_MAX | 
|  | 7 | +
 | 
|  | 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) | 
|  | 9 | +' | 
|  | 10 | + | 
|  | 11 | +TEST_NO_CREATE_REPO=1 | 
|  | 12 | +. ./test-lib.sh | 
|  | 13 | + | 
|  | 14 | +longpath="" | 
|  | 15 | +for (( i=0; i<4; i++ )); do | 
|  | 16 | +	longpath="0123456789abcdefghijklmnopqrstuvwxyz$longpath" | 
|  | 17 | +done | 
|  | 18 | +# Pick a substring maximum of 90 characters | 
|  | 19 | +# This should be good, since we'll add on a lot for temp directories | 
|  | 20 | +longpath=${longpath:0:90}; export longpath | 
|  | 21 | + | 
|  | 22 | +test_expect_failure 'submodule with a long path' ' | 
|  | 23 | +	git config --global protocol.file.allow always && | 
|  | 24 | +	GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ | 
|  | 25 | +	git -c init.defaultBranch=long init --bare remote && | 
|  | 26 | +	test_create_repo bundle1 && | 
|  | 27 | +	( | 
|  | 28 | +		cd bundle1 && | 
|  | 29 | +		test_commit "shoot" && | 
|  | 30 | +		git rev-parse --verify HEAD >../expect | 
|  | 31 | +	) && | 
|  | 32 | +	mkdir home && | 
|  | 33 | +	( | 
|  | 34 | +		cd home && | 
|  | 35 | +		git clone ../remote test && | 
|  | 36 | +		cd test && | 
|  | 37 | +		git checkout -B long && | 
|  | 38 | +		git submodule add ../bundle1 $longpath && | 
|  | 39 | +		test_commit "sogood" && | 
|  | 40 | +		( | 
|  | 41 | +			cd $longpath && | 
|  | 42 | +			git rev-parse --verify HEAD >actual && | 
|  | 43 | +			test_cmp ../../../expect actual | 
|  | 44 | +		) && | 
|  | 45 | +		git push origin long | 
|  | 46 | +	) && | 
|  | 47 | +	mkdir home2 && | 
|  | 48 | +	( | 
|  | 49 | +		cd home2 && | 
|  | 50 | +		git clone ../remote test && | 
|  | 51 | +		cd test && | 
|  | 52 | +		git checkout long && | 
|  | 53 | +		git submodule update --init && | 
|  | 54 | +		( | 
|  | 55 | +			cd $longpath && | 
|  | 56 | +			git rev-parse --verify HEAD >actual && | 
|  | 57 | +			test_cmp ../../../expect actual | 
|  | 58 | +		) | 
|  | 59 | +	) | 
|  | 60 | +' | 
|  | 61 | + | 
|  | 62 | +test_expect_failure 'recursive submodule with a long path' ' | 
|  | 63 | +	GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \ | 
|  | 64 | +	git -c init.defaultBranch=long init --bare super && | 
|  | 65 | +	test_create_repo child && | 
|  | 66 | +	( | 
|  | 67 | +		cd child && | 
|  | 68 | +		test_commit "shoot" && | 
|  | 69 | +		git rev-parse --verify HEAD >../expect | 
|  | 70 | +	) && | 
|  | 71 | +	test_create_repo parent && | 
|  | 72 | +	( | 
|  | 73 | +		cd parent && | 
|  | 74 | +		git submodule add ../child $longpath && | 
|  | 75 | +		test_commit "aim" | 
|  | 76 | +	) && | 
|  | 77 | +	mkdir home3 && | 
|  | 78 | +	( | 
|  | 79 | +		cd home3 && | 
|  | 80 | +		git clone ../super test && | 
|  | 81 | +		cd test && | 
|  | 82 | +		git checkout -B long && | 
|  | 83 | +		git submodule add ../parent foo && | 
|  | 84 | +		git submodule update --init --recursive && | 
|  | 85 | +		test_commit "sogood" && | 
|  | 86 | +		( | 
|  | 87 | +			cd foo/$longpath && | 
|  | 88 | +			git rev-parse --verify HEAD >actual && | 
|  | 89 | +			test_cmp ../../../../expect actual | 
|  | 90 | +		) && | 
|  | 91 | +		git push origin long | 
|  | 92 | +	) && | 
|  | 93 | +	mkdir home4 && | 
|  | 94 | +	( | 
|  | 95 | +		cd home4 && | 
|  | 96 | +		git clone ../super test --recursive && | 
|  | 97 | +		( | 
|  | 98 | +			cd test/foo/$longpath && | 
|  | 99 | +			git rev-parse --verify HEAD >actual && | 
|  | 100 | +			test_cmp ../../../../expect actual | 
|  | 101 | +		) | 
|  | 102 | +	) | 
|  | 103 | +' | 
|  | 104 | +unset longpath | 
|  | 105 | + | 
|  | 106 | +test_done | 
0 commit comments