Skip to content

Commit 21e21d0

Browse files
committed
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.
1 parent 3dd71d3 commit 21e21d0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎git/index/base.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1028,16 +1028,16 @@ def checkout(self, paths=None, force=False, fprogress=lambda *args: None, **kwar
10281028
if force:
10291029
args.append("--force")
10301030

1031+
failed_files = []
1032+
failed_reasons = []
1033+
unknown_lines = []
10311034
def handle_stderr(proc, iter_checked_out_files):
10321035
stderr = proc.stderr.read()
10331036
if not stderr:
10341037
return
10351038
# line contents:
10361039
stderr = stderr.decode(defenc)
10371040
# git-checkout-index: this already exists
1038-
failed_files = []
1039-
failed_reasons = []
1040-
unknown_lines = []
10411041
endings = (' already exists', ' is not in the cache', ' does not exist at stage', ' is unmerged')
10421042
for line in stderr.splitlines():
10431043
if not line.startswith("git checkout-index: ") and not line.startswith("git-checkout-index: "):
@@ -1130,7 +1130,13 @@ def handle_stderr(proc, iter_checked_out_files):
11301130
checked_out_files.append(co_path)
11311131
# END path is a file
11321132
# END for each path
1133-
self._flush_stdin_and_wait(proc, ignore_stdout=True)
1133+
try:
1134+
self._flush_stdin_and_wait(proc, ignore_stdout=True)
1135+
except GitCommandError:
1136+
# Without parsing stdout we don't know what failed.
1137+
raise CheckoutError(
1138+
"Some files could not be checked out from the index, probably because they didn't exist.",
1139+
failed_files, [], failed_reasons)
11341140

11351141
handle_stderr(proc, checked_out_files)
11361142
return checked_out_files

0 commit comments

Comments
 (0)