From 63857b15fa05eabb43f281e3fe50698b385eaec2 Mon Sep 17 00:00:00 2001 From: Paul Date: Sun, 12 Aug 2018 14:41:26 -0700 Subject: [PATCH] added fullpath to fix path concat issue with files when not in git root (#6331) ### Problem As described in #6301 , when the git root and the build root is not the same, `changed` functionalities can be messed up because `git` returns path relative to the working directory, which produces bad paths when it is [concatenated with the git root](https://github.com/pantsbuild/pants/blob/c9f3af460a7504e082931a4b5a668b66f0cd4ed0/src/python/pants/scm/git.py#L161). ### Solution By adding the `--full-name` tag to [`git ls-files`](https://github.com/pantsbuild/pants/blob/c9f3af460a7504e082931a4b5a668b66f0cd4ed0/src/python/pants/scm/git.py#L178), the file concatenation is done properly ### Result Doing `./pants list --changed...` will concatenate file names correctly when it is not run from the git root. --- src/python/pants/scm/git.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/pants/scm/git.py b/src/python/pants/scm/git.py index cfd9ec277d7..ed3e552ee19 100644 --- a/src/python/pants/scm/git.py +++ b/src/python/pants/scm/git.py @@ -173,7 +173,7 @@ def changed_files(self, from_commit=None, include_untracked=False, relative_to=N raise_type=Scm.LocalException) files.update(committed_changes.split()) if include_untracked: - untracked_cmd = ['ls-files', '--other', '--exclude-standard'] + rel_suffix + untracked_cmd = ['ls-files', '--other', '--exclude-standard', '--full-name'] + rel_suffix untracked = self._check_output(untracked_cmd, raise_type=Scm.LocalException) files.update(untracked.split())