Merge branch 'pb/no-recursive-reset-hard-in-worktree-add'
"git worktree add" internally calls "reset --hard" that should not descend into submodules, even when submodule.recurse configuration is set, but it was affected. This has been corrected. * pb/no-recursive-reset-hard-in-worktree-add: worktree: teach "add" to ignore submodule.recurse configmaint
						commit
						05fc6471e3
					
				|  | @ -376,7 +376,7 @@ static int add_worktree(const char *path, const char *refname, | ||||||
| 	if (opts->checkout) { | 	if (opts->checkout) { | ||||||
| 		cp.argv = NULL; | 		cp.argv = NULL; | ||||||
| 		argv_array_clear(&cp.args); | 		argv_array_clear(&cp.args); | ||||||
| 		argv_array_pushl(&cp.args, "reset", "--hard", NULL); | 		argv_array_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL); | ||||||
| 		if (opts->quiet) | 		if (opts->quiet) | ||||||
| 			argv_array_push(&cp.args, "--quiet"); | 			argv_array_push(&cp.args, "--quiet"); | ||||||
| 		cp.env = child_env.argv; | 		cp.env = child_env.argv; | ||||||
|  |  | ||||||
|  | @ -587,4 +587,28 @@ test_expect_success '"add" should not fail because of another bad worktree' ' | ||||||
| 	) | 	) | ||||||
| ' | ' | ||||||
|  |  | ||||||
|  | test_expect_success '"add" with uninitialized submodule, with submodule.recurse unset' ' | ||||||
|  | 	test_create_repo submodule && | ||||||
|  | 	test_commit -C submodule first && | ||||||
|  | 	test_create_repo project && | ||||||
|  | 	git -C project submodule add ../submodule && | ||||||
|  | 	git -C project add submodule && | ||||||
|  | 	test_tick && | ||||||
|  | 	git -C project commit -m add_sub && | ||||||
|  | 	git clone project project-clone && | ||||||
|  | 	git -C project-clone worktree add ../project-2 | ||||||
|  | ' | ||||||
|  | test_expect_success '"add" with uninitialized submodule, with submodule.recurse set' ' | ||||||
|  | 	git -C project-clone -c submodule.recurse worktree add ../project-3 | ||||||
|  | ' | ||||||
|  |  | ||||||
|  | test_expect_success '"add" with initialized submodule, with submodule.recurse unset' ' | ||||||
|  | 	git -C project-clone submodule update --init && | ||||||
|  | 	git -C project-clone worktree add ../project-4 | ||||||
|  | ' | ||||||
|  |  | ||||||
|  | test_expect_success '"add" with initialized submodule, with submodule.recurse set' ' | ||||||
|  | 	git -C project-clone -c submodule.recurse worktree add ../project-5 | ||||||
|  | ' | ||||||
|  |  | ||||||
| test_done | test_done | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano