diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-01-07 12:45:37 +0800 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2021-01-07 12:54:56 +0800 |
commit | 21e21d04bb216a1d7dc42b97bf6dc64864bb5968 (patch) | |
tree | 5e4864f5f363b7133f273df21d858e1e251c7312 /git | |
parent | 3dd71d3edbf3930cce953736e026ac3c90dd2e59 (diff) | |
download | gitpython-fix-1103.tar.gz |
First attempt to fix failing test of #1103fix-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.
Diffstat (limited to 'git')
-rw-r--r-- | git/index/base.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/git/index/base.py b/git/index/base.py index 62ac9389..b1056814 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -1028,6 +1028,9 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): 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: @@ -1035,9 +1038,6 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): # 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: "): @@ -1130,7 +1130,13 @@ class IndexFile(LazyMixin, diff.Diffable, Serializable): 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 |