Skip to content

Commit f813e71

Browse files
committed
bug(stacked-git#83): fix stg pull when no upstream is configured
1 parent b4eba25 commit f813e71

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

stgit/commands/pull.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def func(parser, options, args):
101101
'stgit.pull-policy'
102102
)
103103

104+
remote_name = None
104105
if policy == 'rebase':
105106
# parent is local
106107
if len(args) == 1:
@@ -119,6 +120,13 @@ def func(parser, options, args):
119120
else:
120121
remote_name = stack.parent_remote
121122

123+
if remote_name is None:
124+
parser.error(
125+
'There is no tracking information for the current branch.\n'
126+
'Please specify which branch you want to merge with.'
127+
)
128+
129+
122130
if stack.protected:
123131
raise CmdException('This branch is protected. Pulls are not permitted')
124132

t/t1210-pull.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
#
3+
# Copyright (c) 2006 Yann Dirson
4+
#
5+
6+
test_description='test
7+
8+
'
9+
10+
. ./test-lib.sh
11+
12+
# Need a repo to clone
13+
test_create_repo upstream
14+
15+
test_expect_success \
16+
'Setup upstream repo, clone it, and add patches to the clone' \
17+
'
18+
(cd upstream && stg init) &&
19+
stg clone upstream clone
20+
(cd clone && git config pull.rebase false)
21+
'
22+
23+
test_expect_success \
24+
'Test that pull works' \
25+
'
26+
(cd clone &&
27+
git checkout master &&
28+
stg pull
29+
)
30+
'
31+
32+
test_expect_success \
33+
'Test that pull without upstream setup produces friendly error' \
34+
'
35+
(cd clone &&
36+
stg branch --create without-upstream &&
37+
( stg pull 2>&1 | ( ! grep -q "Traceback" ) ) || ! stg pull 2>&1
38+
)
39+
'
40+
41+
test_done

0 commit comments

Comments
 (0)