Re: [PATCH v2 2/2] [GSOC] ref-filter: add %(raw) atom
- From
ZheNing Hu <adlternative@gmail.com>
- Date
- May 31, 2021, 14:35 UTC
- Message-ID
- <CAOLTT8REM7tF6ojdmnsJt7-RE6a8oX4RFXVcL215YnYTx6b62w@mail.gmail.com>
- In-Reply-To
- <xmqqh7ij20l8.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2021年5月31日周一 上午8:44写道:
Show 18 quoted lines
> > "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes: > > > Beyond, `--format=%(raw)` cannot be used with `--python`, `--shell`, > > `--tcl`, `--perl` because if our binary raw data is passed to a variable > > in the host language, the host languages may cause escape errors. > > "may cause escape errors" just says you are not escaping correctly > in your code (implying that this patch is not good enough and with > more effort we should be able to fix it to allow binaries), but the > problem is the host languages may not support binaries > (specifically, anything with a NUL in it) at all, which is > fundamentally unfixable, in which case, rejecting is the only > sensible choice. > > ... because the host language may not support a NUL in the variables > of its string type. >
I agree. But host language not only support NUL but also some Non-ASCII character and Non-UTF-8 code:
$ git hash-object a.out -w | xargs git update-ref refs/myblobs/aoutblob $ git for-each-ref --format="name=%(raw)" refs/myblobs/aoutblob --python | python2 File "<stdin>", line 1 SyntaxError: Non-ASCII character '\x8b' in file <stdin> on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
$ git for-each-ref --format="name=%(raw)" refs/myblobs/aoutblob --python |python3 SyntaxError: Non-UTF-8 code starting with '\x8b' in file <stdin> on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Show 8 quoted lines
> > +The raw data in a object is `raw`, For commit and tag objects, `raw` contain > > s/contain/contains/, but more importantly, as we are not introducing > %(header), I do not see why we want to talk about its details. For > commits and tags, just like for trees and blobs, 'raw' is the raw > data in the object, so beyond "The raw data of a object is %(raw)", > I do not think there is anything to talk about. >
Ok, I will delete this part.
Show 10 quoted lines
> > + const char *s = buf->buf;
> > + size_t cur_len = 0;
> > +
> > + while ((cur_len != buf->len) && (isspace(*s) || *s == '\0')) {
> > s++;
> > + cur_len++;
>
> Is NUL treated the same as a whitespace letter for the purpose of
> determining if a line is empty? WHY?
>Well, there seems to be no correction here. But is it true that memory like "\0abc" is considered empty?
Thanks. -- ZheNing Hu