mirror of
https://github.com/git/git
synced 2024-08-25 10:45:59 +00:00
checkout: work from a subdirectory
When switching branches from a subdirectory, checkout rewritten in C extracted the toplevel of the tree in there. This should fix it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b0030db331
commit
6010d2d957
|
@ -237,7 +237,6 @@ static int merge_working_tree(struct checkout_opts *opts,
|
|||
topts.dir = xcalloc(1, sizeof(*topts.dir));
|
||||
topts.dir->show_ignored = 1;
|
||||
topts.dir->exclude_per_dir = ".gitignore";
|
||||
topts.prefix = prefix;
|
||||
tree = parse_tree_indirect(old->commit->object.sha1);
|
||||
init_tree_desc(&trees[0], tree->buffer, tree->size);
|
||||
tree = parse_tree_indirect(new->commit->object.sha1);
|
||||
|
|
|
@ -263,4 +263,38 @@ test_expect_success 'checkout with ambiguous tag/branch names' '
|
|||
|
||||
'
|
||||
|
||||
test_expect_success 'switch branches while in subdirectory' '
|
||||
|
||||
git reset --hard &&
|
||||
git checkout master &&
|
||||
|
||||
mkdir subs &&
|
||||
(
|
||||
cd subs &&
|
||||
git checkout side
|
||||
) &&
|
||||
! test -f subs/one &&
|
||||
rm -fr subs
|
||||
|
||||
'
|
||||
|
||||
test_expect_success 'checkout specific path while in subdirectory' '
|
||||
|
||||
git reset --hard &&
|
||||
git checkout side &&
|
||||
mkdir subs &&
|
||||
>subs/bero &&
|
||||
git add subs/bero &&
|
||||
git commit -m "add subs/bero" &&
|
||||
|
||||
git checkout master &&
|
||||
mkdir -p subs &&
|
||||
(
|
||||
cd subs &&
|
||||
git checkout side -- bero
|
||||
) &&
|
||||
test -f subs/bero
|
||||
|
||||
'
|
||||
|
||||
test_done
|
||||
|
|
Loading…
Reference in a new issue