Re: [PATCH] [GSOC] ref-filter: add contents:raw atom
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- May 21, 2021, 13:39 UTC
- Message-ID
- <CAOLTT8TVn-SPdsX+0BrrrWzhq3in6DDFxDY_i4fEhkd-dW6nqg@mail.gmail.com>
- In-Reply-To
- <CAOLTT8Q9meKiHG=TvwsW49dwWtzBNnkfT03+dQrvKDLGuLiOFg@mail.gmail.com>
ZheNing Hu <adlternative@gmail.com> 于2021年5月21日周五 下午9:12写道:
Show 26 quoted lines
> > > Now we want to use for-each-ref to print a ref point to a tree: > > git for-each-ref --format="%(contents:raw)" refs/mytrees/first > > will output: > > 100644 one > > but > > git cat-file tree refs/mytrees/first > > will output: > > 100644 onem�cֈ��q�D�֧hJ)E-100644 two.t���0�+��VjC��eV�ӈq > > which is the compressed data, it may contains '\0'. > > Whne we use `append_atom()` to add the contents of the tree object > to the buffer, notice that it uses `strbuf_addstr()`, the underlying call > is `strlen()`, which truncates the data we added. Can we have any good > remedies? For example, record the length of "v->s" by "v->s_size" and > use `strbuf_addstr(&state->stack->output, v->s, v->s_size)`? >
This is not a good method, because `quote_formatting()` in `append_atom()` will also cause this truncation problem.
-- ZheNing Hu