Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Unified Diff: git_reparent_branch.py

Issue 1498163002: Add better error messages to git_reparent_branch. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: fix test Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/git_rebase_update_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_reparent_branch.py
diff --git a/git_reparent_branch.py b/git_reparent_branch.py
index be44bc6cbfe516b8a02cbc5621be50694e292260..f9b04421b366e35fb315e0202ede03dd20e012d0 100755
--- a/git_reparent_branch.py
+++ b/git_reparent_branch.py
@@ -31,6 +31,7 @@ def main(args):
# TODO(iannucci): Allow specification of the branch-to-reparent
branch = current_branch()
+
if opts.root:
new_parent = root_ref
elif opts.lkgr:
@@ -46,6 +47,16 @@ def main(args):
if new_parent == cur_parent:
parser.error('Cannot reparent a branch to its existing parent')
+ if not cur_parent:
+ msg = (
+ "Unable to determine %s@{upstream}.\n\nThis can happen if you didn't use "
+ "`git new-branch` to create the branch and haven't used "
+ "`git branch --set-upstream-to` to assign it one.\n\nPlease assign an "
+ "upstream branch and then run this command again."
+ )
+ print >> sys.stderr, msg % branch
+ return 1
+
mbase = get_or_create_merge_base(branch, cur_parent)
all_tags = tags()
« no previous file with comments | « no previous file | tests/git_rebase_update_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698