Skip to content

Commit

Permalink
_git_check_output_lines() now hardcodes Git binary
Browse files Browse the repository at this point in the history
No need to give the Git binary name as the first command line element
in `["git", ...]`.
  • Loading branch information
akaihola committed Nov 1, 2020
1 parent 1fcf35f commit 93c027b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/darker/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def git_get_content_at_revision(path: Path, revision: str, cwd: Path) -> List[st
"""
if revision == WORKTREE:
return (cwd / path).read_text("utf-8").splitlines()
cmd = ["git", "show", f"{revision}:./{path}"]
cmd = ["show", f"{revision}:./{path}"]
logger.debug("[%s]$ %s", cwd, " ".join(cmd))
try:
return _git_check_output_lines(cmd, cwd, exit_on_error=False)
Expand Down Expand Up @@ -110,7 +110,7 @@ def _git_check_output_lines(
"""Log command line, run Git, split stdout to lines, exit with 123 on error"""
logger.debug("[%s]$ %s", cwd, " ".join(cmd))
try:
return check_output(cmd, cwd=str(cwd)).decode("utf-8").splitlines()
return check_output(["git"] + cmd, cwd=str(cwd)).decode("utf-8").splitlines()
except CalledProcessError as exc_info:
if exc_info.returncode == 128 and exit_on_error:
# Bad revision or another Git failure. Follow Black's example and return the
Expand Down Expand Up @@ -139,12 +139,11 @@ def git_get_modified_files(
str_paths = [str(path) for path in relative_paths]
if revrange.use_common_ancestor:
rev2 = "HEAD" if revrange.rev2 == WORKTREE else revrange.rev2
merge_base_cmd = ["git", "merge-base", revrange.rev1, rev2]
merge_base_cmd = ["merge-base", revrange.rev1, rev2]
rev1 = _git_check_output_lines(merge_base_cmd, cwd)[0]
else:
rev1 = revrange.rev1
diff_cmd = [
"git",
"diff",
"--name-only",
"--relative",
Expand All @@ -158,7 +157,6 @@ def git_get_modified_files(
lines = _git_check_output_lines(diff_cmd, cwd)
if revrange.rev2 == WORKTREE:
ls_files_cmd = [
"git",
"ls-files",
"--others",
"--exclude-standard",
Expand Down

0 comments on commit 93c027b

Please sign in to comment.