Skip to content

Commit 8fa0ee3

Browse files
spearcegitster
authored andcommitted
Suggest unsetting core.bare when using new-workdir on a bare repository
If core.bare is set to true in the config file of a repository that the user is trying to create a working directory from we should abort and suggest to the user that they remove the option first. If we leave the core.bare=true setting in the config file then working tree operations will get confused when they attempt to execute in the new workdir, as it shares its config file with the bare repository. The working tree operations will assume that the workdir is bare and abort, which is not what the user wants. If we changed core.bare to be false then working tree operations will function in the workdir but other operations may fail in the bare repository, as it claims to not be bare. If we remove core.bare from the config then Git can fallback on the legacy guessing behavior. This allows operations in the bare repository to work as though it were bare, while operations in the workdirs to act as though they are not bare. Signed-off-by: Shawn O. Pearce <spearce@spearce.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e301bfe commit 8fa0ee3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

contrib/workdir/git-new-workdir

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ case "$git_dir" in
3333
;;
3434
esac
3535

36+
# don't link to a configured bare repository
37+
isbare=$(git --git-dir="$git_dir" config --bool --get core.bare)
38+
if test ztrue = z$isbare
39+
then
40+
die "\"$git_dir\" has core.bare set to true," \
41+
" remove from \"$git_dir/config\" to use $0"
42+
fi
43+
3644
# don't link to a workdir
3745
if test -L "$git_dir/config"
3846
then

0 commit comments

Comments
 (0)