Skip to content

Commit d13a06e

Browse files
committed
Add additional check whether local branch exists when detecting local/outgoing changes
1 parent 0c8bafd commit d13a06e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

mbed/mbed.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,13 +745,18 @@ def outgoing():
745745
if not branch:
746746
# Default to "master" in detached mode
747747
branch = "master"
748+
# Check if local branch exists. If not, then just carry on
749+
try:
750+
pquery([git_cmd, 'rev-parse', '%s' % branch])
751+
except ProcessException:
752+
return 0
753+
# Check if remote branch exists. If not, then it's a new branch
748754
try:
749-
# Check if remote branch exists
750755
if not pquery([git_cmd, 'rev-parse', '%s/%s' % (remote, branch)]):
751756
return 1
752757
except ProcessException:
753758
return 1
754-
# Check for outgoing commits for the same remote branch
759+
# Check for outgoing commits for the same remote branch only if it exists locally and remotely
755760
return 1 if pquery([git_cmd, 'log', '%s/%s..%s' % (remote, branch, branch)]) else 0
756761

757762
# Checks whether current working tree is detached

0 commit comments

Comments
 (0)