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

Unified Diff: git_cl.py

Issue 661413005: Make 'git cl patch' work when not on a named branch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 6 years, 2 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: git_cl.py
diff --git a/git_cl.py b/git_cl.py
index 4c5f9634c36a91d8c1690e00460286294aceec5d..bd65e12b02e4b30162e46c54f72bd25ecbb453b6 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -525,7 +525,11 @@ class Changelist(object):
def GetBranch(self):
"""Returns the short branch name, e.g. 'master'."""
if not self.branch:
- self.branchref = RunGit(['symbolic-ref', 'HEAD']).strip()
+ branchref = RunGit(['symbolic-ref', 'HEAD'],
+ stderr=subprocess2.VOID, error_ok=True).strip()
+ if not branchref:
+ return None
+ self.branchref = branchref
pgervais 2014/10/20 20:45:57 Please define self.branchref in __init__.
szager1 2014/10/20 22:29:52 It already is.
self.branch = ShortBranchName(self.branchref)
return self.branch
@@ -696,8 +700,10 @@ or verify this branch is set up to track another (via the --track argument to
# If we're on a branch then get the server potentially associated
# with that branch.
if self.GetIssue():
- self.rietveld_server = gclient_utils.UpgradeToHttps(RunGit(
- ['config', self._RietveldServer()], error_ok=True).strip())
+ rietveld_server_config = self._RietveldServer()
+ if rietveld_server_config:
+ self.rietveld_server = gclient_utils.UpgradeToHttps(RunGit(
+ ['config', rietveld_server_config], error_ok=True).strip())
if not self.rietveld_server:
self.rietveld_server = settings.GetDefaultServerUrl()
return self.rietveld_server
@@ -942,7 +948,10 @@ or verify this branch is set up to track another (via the --track argument to
def _RietveldServer(self):
"""Returns the git setting that stores this change's rietveld server."""
- return 'branch.%s.rietveldserver' % self.GetBranch()
+ branch = self.GetBranch()
+ if branch:
+ return 'branch.%s.rietveldserver' % branch
+ return None
def GetCodereviewSettingsInteractively():
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698