git-cl-patch: fail if patching from a different repo
I don't know of any use-case where someone would want to
use git-cl-patch to pull a (e.g.) chromium change into
their (e.g.) v8 checkout.
Bug: 803918
Change-Id: Id53f1cc3ab97e623d0098bb366a573b18b54e91a
Reviewed-on: https://chromium-review.googlesource.com/876930
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 39a4636..b604bb1 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -2820,7 +2820,15 @@
DieWithError('Couldn\'t find patchset %i in change %i' %
(parsed_issue_arg.patchset, self.GetIssue()))
+ remote_url = self._changelist.GetRemoteUrl()
+ if remote_url.endswith('.git'):
+ remote_url = remote_url[:-len('.git')]
fetch_info = revision_info['fetch']['http']
+
+ if remote_url != fetch_info['url']:
+ DieWithError('Trying to patch a change from %s but this repo appears '
+ 'to be %s.' % (fetch_info['url'], remote_url))
+
RunGit(['fetch', fetch_info['url'], fetch_info['ref']])
if force: