Skip to content

catfile: Fix reading revisions with newlines

Patrick Steinhardt requested to merge pks-catfile-requests-with-newlines into master

By default, the batched modes of git-cat-file(1) read newline terminated revisions from its stdin. While this works alright in almost all cases, this starts to break once the request contains a newline itself. This can for example happen when processing revisions with path components in the case where the path itself contains a newline. The consequence is twofold:

- The request will be truncated at the newline, so we will ask for
  the wrong revision.

- Given that our catfile processes are cached, we'll accidentally
  end up adding multiple requests to the request queue, but only
  process one of these. And as we don't mark the process as dirty
  now it will be returned to the cache, but the process is poisoned
  now and will return the wrong result on the next invocation.

Fix these issues by using git-cat-file(1)'s -z mode, which causes it to assume that the input is NUL instead of newline terrminated.

Closes #5097 (closed)

Merge request reports