diff --git a/stgit/commands/pull.py b/stgit/commands/pull.py index 9355b846..d6d0edb9 100644 --- a/stgit/commands/pull.py +++ b/stgit/commands/pull.py @@ -101,6 +101,7 @@ def func(parser, options, args): 'stgit.pull-policy' ) + remote_name = None if policy == 'rebase': # parent is local if len(args) == 1: @@ -119,6 +120,12 @@ def func(parser, options, args): else: remote_name = stack.parent_remote + if policy in ['pull', 'fetch-rebase'] and remote_name is None: + parser.error( + 'There is no tracking information for the current branch.\n' + 'Please specify which branch you want to merge with.' + ) + if stack.protected: raise CmdException('This branch is protected. Pulls are not permitted') diff --git a/t/t1210-pull-check-upstream.sh b/t/t1210-pull-check-upstream.sh new file mode 100755 index 00000000..7cc1d909 --- /dev/null +++ b/t/t1210-pull-check-upstream.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +test_description='Check that pulling works when no upstream is configured' + +. ./test-lib.sh + +# Need a repo to clone +test_create_repo upstream + +test_expect_success \ + 'Setup upstream repo, clone it, and add patches to the clone' \ + ' + (cd upstream && stg init) && + stg clone upstream clone + (cd clone && git config pull.rebase false) + ' + +test_expect_success \ + 'Test that pull works' \ + ' + (cd clone && + git checkout master && + stg pull + ) + ' + +test_expect_success \ + 'Test that pull without upstream setup produces friendly error' \ + ' + (cd clone && + stg branch --create without-upstream && + ( stg pull 2>&1 | grep "There is no tracking information for the current branch." ) || ( stg pull 2>&1 && false ) + ) + ' + +test_done