Skip to content

First attempt to fix failing test of #1103 #1104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
First attempt to fix failing test of #1103
However, the test asserts on the provided context to be correct,
which is hard to do in this branch while it's easy to doubt the value
of this.

Lastly, there seems to be no way to ignore errors in `git` without
muting all output, which is in fact parsed.

Maybe it's possible to ignore errors while parsing the new kind of
error message.
  • Loading branch information
Byron committed Jan 7, 2021
commit 21e21d04bb216a1d7dc42b97bf6dc64864bb5968
14 changes: 10 additions & 4 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1028,16 +1028,16 @@ def checkout(self, paths=None, force=False, fprogress=lambda *args: None, **kwar
if force:
args.append("--force")

failed_files = []
failed_reasons = []
unknown_lines = []
def handle_stderr(proc, iter_checked_out_files):
stderr = proc.stderr.read()
if not stderr:
return
# line contents:
stderr = stderr.decode(defenc)
# git-checkout-index: this already exists
failed_files = []
failed_reasons = []
unknown_lines = []
endings = (' already exists', ' is not in the cache', ' does not exist at stage', ' is unmerged')
for line in stderr.splitlines():
if not line.startswith("git checkout-index: ") and not line.startswith("git-checkout-index: "):
Expand Down Expand Up @@ -1130,7 +1130,13 @@ def handle_stderr(proc, iter_checked_out_files):
checked_out_files.append(co_path)
# END path is a file
# END for each path
self._flush_stdin_and_wait(proc, ignore_stdout=True)
try:
self._flush_stdin_and_wait(proc, ignore_stdout=True)
except GitCommandError:
# Without parsing stdout we don't know what failed.
raise CheckoutError(
"Some files could not be checked out from the index, probably because they didn't exist.",
failed_files, [], failed_reasons)

handle_stderr(proc, checked_out_files)
return checked_out_files
Expand Down