diff --git a/git-filter-repo b/git-filter-repo index aaa4609..a0ad4f7 100755 --- a/git-filter-repo +++ b/git-filter-repo @@ -2779,6 +2779,11 @@ class RepoFilter(object): abort(_('%s does not match %s') % (decode(refname), decode(origin_ref))) + # Make sure there is only one worktree + output = subprocess.check_output('git worktree list'.split()) + if len(output.splitlines()) > 1: + abort(_('you have multiple worktrees')) + @staticmethod def tweak_blob(args, blob): if args.replace_text: diff --git a/t/t9390-filter-repo.sh b/t/t9390-filter-repo.sh index 8a674ab..3fd3f5e 100755 --- a/t/t9390-filter-repo.sh +++ b/t/t9390-filter-repo.sh @@ -703,6 +703,12 @@ test_expect_success 'startup sanity checks' ' test_i18ngrep "you have untracked changes" err && rm err && + git worktree add ../other-worktree HEAD && + test_must_fail git filter-repo --path numbers 2>../err && + test_i18ngrep "you have multiple worktrees" ../err && + rm -rf ../err && + git worktree remove ../other-worktree && + git update-ref -d refs/remotes/origin/master && test_must_fail git filter-repo --path numbers 2>../err && test_i18ngrep "refs/heads/master exists, but refs/remotes/origin/master not found" ../err &&