filter-repo: include additional worktrees in sanity startup check

Signed-off-by: Elijah Newren <newren@gmail.com>
This commit is contained in:
Elijah Newren 2019-05-02 09:10:26 -07:00
parent aa63db17bc
commit 89e5c43805
2 changed files with 11 additions and 0 deletions

View File

@ -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:

View File

@ -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 &&