git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/3] [GSOC][RFC] ref-filter: add contents:raw atom

From
ZheNing Hu via GitGitGadget <gitgitgadget@gmail.com>
Date
May 23, 2021, 09:53 UTC
Message-ID
<pull.959.git.1621763612.gitgitgadget@gmail.com>

In (a2f3241: [GSOC] ref-filter: add contents:raw atom) I did not notice the breakage that occurred during the test, In the later remediation, I found a very serious problem: The output object data of "git cat-file tree foo" or "git cat-file blob foo" may contain '\0'. However, most of the logic in ref-filter depends on the atomic output not containing'\0'.

Therefore, we must carry out a series of repairs to ref-filter so that it can support output of data containing '\0'.

In first patch, I add *.quote_buf_with_size() functions, this can deal with data with containing'\0'.

In second patch, I add the member s_size in struct atom_value, and protects the output of the atom from being truncated at '\0', and successfully supported the %(contents) of blob and tree.

In third patch, I added the%(contents:raw) atom, It can print the original content of an object.

What needs to be reconsidered:
For a binary object blob, tree,
git for-each-ref --format="%(contents)" --python refs/mytrees/first

will output a string processed by python_quote_buf_with_size(), which contains'\0'. But the binary files seem to be useless after quoting. Should we allow these binary files to be output in the default way with strbuf_add()? If so, we can remove the first patch.

ZheNing Hu (3):
  [GSOC] quote: add *.quote_buf_with_size functions
  [GSOC] ref-filter: support %(contents) for blob, tree
  [GSOC] ref-filter: add contents:raw atom
 Documentation/git-for-each-ref.txt |  19 ++-
 quote.c                            | 116 +++++++++++++++
 quote.h                            |   4 +
 ref-filter.c                       | 229 +++++++++++++++++++++--------
 t/t6300-for-each-ref.sh            | 214 ++++++++++++++++++++++++++-
 5 files changed, 511 insertions(+), 71 deletions(-)
base-commit: 97eea85a0a1ec66d356567808a1e4ca2367e0ce7
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-959%2Fadlternative%2Fref-filter-contents-raw-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-959/adlternative/ref-filter-contents-raw-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/959
-- 
gitgitgadget
Next: ZheNing Hu via GitGitGadget
Message 1 of 18 in “[GSOC][RFC] ref-filter: add contents:raw atom”
  1. 0/3 [GSOC][RFC] ref-filter: add contents:raw atomZheNing Hu via GitGitGadget, May 23, 2021
  2. 1/3 [GSOC] quote: add *.quote_buf_with_size functionsZheNing Hu via GitGitGadget, May 23, 2021
  3. 2/3 [GSOC] ref-filter: support %(contents) for blob, treeZheNing Hu via GitGitGadget, May 23, 2021
  4. Junio C HamanoMay 25, 2021
  5. Junio C HamanoMay 25, 2021
  6. ZheNing HuMay 25, 2021
  7. Junio C HamanoMay 25, 2021
  8. ZheNing HuMay 26, 2021
  9. 3/3 [GSOC] ref-filter: add contents:raw atomZheNing Hu via GitGitGadget, May 23, 2021
  10. Junio C HamanoMay 24, 2021
  11. Felipe ContrerasMay 24, 2021
  12. Bagas SanjayaMay 24, 2021
  13. Junio C HamanoMay 24, 2021
  14. ZheNing HuMay 24, 2021
  15. Junio C HamanoMay 26, 2021
  16. ZheNing HuMay 26, 2021
  17. Junio C HamanoMay 26, 2021
  18. ZheNing HuMay 26, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.