git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Junio C Hamano <gitster@pobox.com>,
	Christian Couder <christian.couder@gmail.com>,
	Hariom Verma <hariom18599@gmail.com>,
	Karthik Nayak <karthik.188@gmail.com>,
	ZheNing Hu <adlternative@gmail.com>
Subject: [PATCH 0/3] [GSOC][RFC] ref-filter: add contents:raw atom
Date: Sun, 23 May 2021 09:53:29 +0000	[thread overview]
Message-ID: <pull.959.git.1621763612.gitgitgadget@gmail.com> (raw)

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

             reply	other threads:[~2021-05-23  9:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-23  9:53 ZheNing Hu via GitGitGadget [this message]
2021-05-23  9:53 ` [PATCH 1/3] [GSOC] quote: add *.quote_buf_with_size functions ZheNing Hu via GitGitGadget
2021-05-23  9:53 ` [PATCH 2/3] [GSOC] ref-filter: support %(contents) for blob, tree ZheNing Hu via GitGitGadget
2021-05-25  5:03   ` Junio C Hamano
2021-05-25  5:47     ` Junio C Hamano
2021-05-25  9:28       ` ZheNing Hu
2021-05-25 17:11         ` Junio C Hamano
2021-05-26  7:48           ` ZheNing Hu
2021-05-23  9:53 ` [PATCH 3/3] [GSOC] ref-filter: add contents:raw atom ZheNing Hu via GitGitGadget
2021-05-24  1:09 ` [PATCH 0/3] [GSOC][RFC] " Junio C Hamano
2021-05-24  2:41   ` Felipe Contreras
2021-05-24  5:22     ` Bagas Sanjaya
2021-05-24 15:21       ` Junio C Hamano
2021-05-24 13:09   ` ZheNing Hu
2021-05-26  0:56   ` Junio C Hamano
2021-05-26  6:45     ` ZheNing Hu
2021-05-26  7:06       ` Junio C Hamano
2021-05-26  9:17         ` ZheNing Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.959.git.1621763612.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=adlternative@gmail.com \
    --cc=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hariom18599@gmail.com \
    --cc=karthik.188@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).