From 1853f66efd16a0e0e6ad14cc75f2287a7fa19521 Mon Sep 17 00:00:00 2001 From: Aaron Gable Date: Mon, 12 Feb 2018 15:45:56 -0800 Subject: [PATCH] gclient: diff against hash in DEPS When someone runs "gclient diff", they expect to be diffing their local state against the state of a clean gclient checkout. Up until now, "gclient diff" has been doing... not that. It's been assuming that the sha1 in DEPS is approximately the head of the remote's master branch, finding the merge-base between the local content and that remote master, and diffing against that merge-base. This makes basically no sense in the context of gclient. With gclient, we already know exactly what should be checked out: it's whatever is in DEPS. This CL updates the behavior of "gclient diff" to do the right thing. Bug: 731701 Change-Id: I23a43cbc0d6bc7772495097ff615d4d070f5ad19 Reviewed-on: https://chromium-review.googlesource.com/914717 Reviewed-by: Andrii Shyshkalov Commit-Queue: Aaron Gable --- gclient_scm.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gclient_scm.py b/gclient_scm.py index d4837c8f95..12ea7b6252 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -252,11 +252,10 @@ class GitWrapper(SCMWrapper): ).split() def diff(self, options, _args, _file_list): - try: - merge_base = [self._Capture(['merge-base', 'HEAD', self.remote])] - except subprocess2.CalledProcessError: - merge_base = [] - self._Run(['-c', 'core.quotePath=false', 'diff'] + merge_base, options) + _, revision = gclient_utils.SplitUrlRevision(self.url) + if not revision: + revision = 'refs/remotes/%s/master' % self.remote + self._Run(['-c', 'core.quotePath=false', 'diff', revision], options) def pack(self, _options, _args, _file_list): """Generates a patch file which can be applied to the root of the