From 89e5c438057fabb17c8ecf06b9e2240395cfd121 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 2 May 2019 09:10:26 -0700 Subject: [PATCH] filter-repo: include additional worktrees in sanity startup check Signed-off-by: Elijah Newren --- git-filter-repo | 5 +++++ t/t9390-filter-repo.sh | 6 ++++++ 2 files changed, 11 insertions(+) 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 &&