Commit 37c629a3 authored by chase@chromium.org's avatar chase@chromium.org

Call git diff --name-status with a relative path.

On a new Linux box, during git cl dcommit I observed
the error:

  fatal: invalid diff option/value: -r

This was caused by the git cl presubmit hooks running:

  git diff --name-status -r refs/remotes/origin/trunk.. /path/to/src

By passing a relative path (given by git rev-parse
--show-cdup) instead of an absolute path for
/path/to/src, git diff --name-status does not print an
error and returns the expected list of changed files.

Also fix some broken scm and gclient_scm unit tests.

BUG=none
TEST=git presubmit hooks work from main working
directory
Review URL: http://codereview.chromium.org/438012

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@32999 0039d316-1c4b-4281-b951-d872f2087c98
parent cf69b459
......@@ -24,7 +24,10 @@ class ChangeOptions:
self.default_presubmit = None
self.may_prompt = None
root = os.path.abspath(Backquote(['git', 'rev-parse', '--show-cdup']))
root = Backquote(['git', 'rev-parse', '--show-cdup'])
if not root:
root = "."
absroot = os.path.abspath(root)
if not root:
raise Exception("Could not get root directory.")
log = Backquote(['git', 'show', '--name-only',
......@@ -37,7 +40,7 @@ class ChangeOptions:
files = scm.GIT.CaptureStatus([root], upstream_branch)
issue = Backquote(['git', 'cl', 'status', '--field=id'])
patchset = None
self.change = presubmit_support.GitChange(name, description, root, files,
self.change = presubmit_support.GitChange(name, description, absroot, files,
issue, patchset)
......
......@@ -66,7 +66,7 @@ class SVNWrapperTestCase(BaseTestCase):
members = [
'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo',
'CaptureStatus', 'DiffItem', 'FullUrlForRelativeUrl', 'GetEmail',
'GetFileProperty', 'IsMoved', 'ReadEntries', 'ReadSimpleAuth', 'Run',
'GetFileProperty', 'IsMoved', 'ReadSimpleAuth', 'Run',
'RunAndFilterOutput', 'RunAndGetFileList',
'RunCommand', 'cleanup', 'diff', 'export', 'pack', 'relpath', 'revert',
'revinfo', 'runhooks', 'scm_name', 'status', 'update', 'url',
......
......@@ -140,8 +140,7 @@ class SVNTestCase(BaseSCMTestCase):
members = [
'COMMAND', 'Capture', 'CaptureHeadRevision', 'CaptureInfo',
'CaptureStatus', 'DiffItem', 'GetEmail', 'GetFileProperty', 'IsMoved',
'ReadEntries', 'ReadSimpleAuth', 'Run', 'RunAndFilterOutput',
'RunAndGetFileList',
'ReadSimpleAuth', 'Run', 'RunAndFilterOutput', 'RunAndGetFileList',
]
# If this test fails, you should add the relevant test.
self.compareMembers(scm.SVN, members)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment