Skip to content

bug(#83): fix stg pull when no upstream is configured #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions stgit/commands/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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')

Expand Down
36 changes: 36 additions & 0 deletions t/t1210-pull-check-upstream.sh
Original file line number Diff line number Diff line change
@@ -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