checkout: support checking out into a new working directory

"git checkout --to" sets up a new working directory with a .git file
pointing to $GIT_DIR/worktrees/<id>. It then executes "git checkout"
again on the new worktree with the same arguments except "--to" is
taken out. The second checkout execution, which is not contaminated
with any info from the current repository, will actually check out and
everything that normal "git checkout" does.

Helped-by: Marc Branchaud <marcnarc@xiplink.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2014-11-30 15:24:47 +07:00
committed by Junio C Hamano
parent 91aacda85a
commit 529fef20cf
6 changed files with 212 additions and 4 deletions

2
path.c
View File

@ -92,7 +92,7 @@ static void replace_dir(struct strbuf *buf, int len, const char *newdir)
static const char *common_list[] = {
"/branches", "/hooks", "/info", "/logs", "/lost-found", "/modules",
"/objects", "/refs", "/remotes", "/rr-cache", "/svn",
"/objects", "/refs", "/remotes", "/worktrees", "/rr-cache", "/svn",
"config", "gc.pid", "packed-refs", "shallow",
NULL
};