@@ -77,7 +77,6 @@ def git_get_content_at_revision(path: Path, revision: str, cwd: Path) -> TextDoc
77
77
abspath = cwd / path
78
78
return TextDocument .from_file (abspath )
79
79
cmd = ["show" , f"{ revision } :./{ path .as_posix ()} " ]
80
- logger .debug ("[%s]$ %s" , cwd , " " .join (cmd ))
81
80
try :
82
81
return TextDocument .from_lines (
83
82
_git_check_output_lines (cmd , cwd , exit_on_error = False ),
@@ -177,7 +176,7 @@ def _git_check_output_lines(
177
176
cmd : List [str ], cwd : Path , exit_on_error : bool = True
178
177
) -> List [str ]:
179
178
"""Log command line, run Git, split stdout to lines, exit with 123 on error"""
180
- logger .debug ("[%s]$ %s" , cwd , " " .join (cmd ))
179
+ logger .debug ("[%s]$ git %s" , cwd , " " .join (cmd ))
181
180
try :
182
181
return check_output (
183
182
["git" ] + cmd ,
@@ -200,36 +199,39 @@ def _git_check_output_lines(
200
199
sys .exit (123 )
201
200
202
201
203
- def _git_exists_in_revision (path : Path , rev2 : str ) -> bool :
202
+ def _git_exists_in_revision (path : Path , rev2 : str , cwd : Path ) -> bool :
204
203
"""Return ``True`` if the given path exists in the given Git revision
205
204
206
205
:param path: The path of the file or directory to check
207
206
:param rev2: The Git revision to look at
207
+ :param cwd: The Git repository root
208
208
:return: ``True`` if the file or directory exists at the revision, or ``False`` if
209
209
it doesn't.
210
210
211
211
"""
212
212
# Surprise: On Windows, `git cat-file` doesn't work with backslash directory
213
213
# separators in paths. We need to use Posix paths and forward slashes instead.
214
214
cmd = ["git" , "cat-file" , "-e" , f"{ rev2 } :{ path .as_posix ()} " ]
215
- result = run (cmd , check = False , stderr = DEVNULL , env = {"LC_ALL" : "C" })
215
+ logger .debug ("[%s]$ %s" , cwd , " " .join (cmd ))
216
+ result = run (cmd , cwd = str (cwd ), check = False , stderr = DEVNULL , env = {"LC_ALL" : "C" })
216
217
return result .returncode == 0
217
218
218
219
219
- def get_missing_at_revision (paths : Iterable [Path ], rev2 : str ) -> Set [Path ]:
220
+ def get_missing_at_revision (paths : Iterable [Path ], rev2 : str , cwd : Path ) -> Set [Path ]:
220
221
"""Return paths missing in the given revision
221
222
222
223
In case of ``WORKTREE``, just check if the files exist on the filesystem instead of
223
224
asking Git.
224
225
225
226
:param paths: Paths to check
226
227
:param rev2: The Git revision to look at, or ``WORKTREE`` for the working tree
228
+ :param cwd: The Git repository root
227
229
:return: The set of file or directory paths which are missing in the revision
228
230
229
231
"""
230
232
if rev2 == WORKTREE :
231
233
return {path for path in paths if not path .exists ()}
232
- return {path for path in paths if not _git_exists_in_revision (path , rev2 )}
234
+ return {path for path in paths if not _git_exists_in_revision (path , rev2 , cwd )}
233
235
234
236
235
237
def _git_diff_name_only (
0 commit comments