@matheusbsbs / matheus-bagliano / commits / 6010d2d957
Fork 0

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>

Junio C Hamano committed Feb 20, 2008 at 15:54 UTC 6010d2d957fb05838cd3ab887ac261752ff8ff87
2 files changed +34 -1
builtin-checkout.c
-1
@@ -237,7 +237,6 @@ static int merge_working_tree(struct checkout_opts *opts,
237 topts.dir = xcalloc(1, sizeof(*topts.dir));
238 topts.dir->show_ignored = 1;
239 topts.dir->exclude_per_dir = ".gitignore";
240 - topts.prefix = prefix;
240 tree = parse_tree_indirect(old->commit->object.sha1);
241 init_tree_desc(&trees[0], tree->buffer, tree->size);
242 tree = parse_tree_indirect(new->commit->object.sha1);
t/t7201-co.sh
+34
@@ -263,4 +263,38 @@ test_expect_success 'checkout with ambiguous tag/branch names' '
263
264 '
265
266 +test_expect_success 'switch branches while in subdirectory' '
267 +
268 + git reset --hard &&
269 + git checkout master &&
270 +
271 + mkdir subs &&
272 + (
273 + cd subs &&
274 + git checkout side
275 + ) &&
276 + ! test -f subs/one &&
277 + rm -fr subs
278 +
279 +'
280 +
281 +test_expect_success 'checkout specific path while in subdirectory' '
282 +
283 + git reset --hard &&
284 + git checkout side &&
285 + mkdir subs &&
286 + >subs/bero &&
287 + git add subs/bero &&
288 + git commit -m "add subs/bero" &&
289 +
290 + git checkout master &&
291 + mkdir -p subs &&
292 + (
293 + cd subs &&
294 + git checkout side -- bero
295 + ) &&
296 + test -f subs/bero
297 +
298 +'
299 +
300 test_done