File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1120,16 +1120,25 @@ command-setup() {
11201120
11211121 check-and-normalize-subdir
11221122 encode-subdir
1123+ gitrepo=" $subdir /.gitrepo"
11231124
11241125 if ! $force_wanted ; then
11251126 o " Check for worktree with branch subrepo/$subdir "
1126- local _worktree=$( git worktree list | grep " \[subrepo/$subdir \]" )
1127+ local _worktree=$( git worktree list | grep " \[subrepo/$subdir \]" | cut -d ' ' -f1 )
11271128 if [[ $command =~ ^(commit)$ && -z $_worktree ]]; then
11281129 error " There is no worktree available, use the branch command first"
11291130 elif [[ ! $command =~ ^(branch| clean| commit| push)$ && -n $_worktree ]]; then
1130- error " There is already a worktree with branch subrepo/$subdir .
1131+ if [[ -e $gitrepo ]]; then
1132+ error " There is already a worktree with branch subrepo/$subdir .
11311133Use the --force flag to override this check or perform a subrepo clean
11321134to remove the worktree."
1135+ else
1136+ error " There is already a worktree with branch subrepo/$subdir .
1137+ Use the --force flag to override this check or remove the worktree with
1138+ 1. rm -rf $_worktree
1139+ 2. git worktree prune
1140+ "
1141+ fi
11331142 fi
11341143 fi
11351144
@@ -1140,7 +1149,6 @@ to remove the worktree."
11401149 refs_subrepo_push=" refs/subrepo/$subref /push"
11411150
11421151 # Read/parse the .gitrepo file (unless clone/init; doesn't exist yet)
1143- gitrepo=" $subdir /.gitrepo"
11441152 if [[ ! $command =~ ^(clone| init)$ ]]; then
11451153 read-gitrepo-file
11461154 fi
You can’t perform that action at this time.
0 commit comments