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 <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
changes/17/914717/5
Aaron Gable 7 years ago committed by Commit Bot
parent a148b5ee55
commit 1853f66efd

@ -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

Loading…
Cancel
Save