提交 ea09ea22 编写于 作者: S Shawn O. Pearce 提交者: Junio C Hamano

Don't allow contrib/workdir/git-new-workdir to trash existing dirs

Recently I found that doing a sequence like the following:

  git-new-workdir a b
  ...
  git-new-workdir a b

by accident will cause a (and now also b) to have an infinite cycle
in its refs directory.  This is caused by git-new-workdir trying
to create the "refs" symlink over again, only during the second
time it is being created within a's refs directory and is now also
pointing back at a's refs.

This causes confusion in git as suddenly branches are named things
like "refs/refs/refs/refs/refs/refs/refs/heads/foo" instead of the
more commonly accepted "refs/heads/foo".  Plenty of commands start
to see ambiguous ref names and others just take ages to compute.

git-clone has the same safety check, so git-new-workdir should
behave just like it.
Signed-off-by: NShawn O. Pearce <spearce@spearce.org>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 6b763c42
......@@ -48,6 +48,12 @@ then
"a complete repository."
fi
# don't recreate a workdir over an existing repository
if test -e "$new_workdir"
then
die "destination directory '$new_workdir' already exists."
fi
# make sure the the links use full paths
git_dir=$(cd "$git_dir"; pwd)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册