git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [GSoC] Git Blog 1
@ 2021-05-23 10:53 ZheNing Hu
  2021-05-24 20:47 ` Christian Couder
  0 siblings, 1 reply; 3+ messages in thread
From: ZheNing Hu @ 2021-05-23 10:53 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Christian Couder, Hariom verma

My first week blog finished:
The web version is here:
https://adlternative.github.io/GSOC-Git-Blog-1/

-----

## Week1: Git Adventure Begin

Use Git to submit Git patches to the Git community.
Does it sound magical? I fell very lucky to be selected
by the Git community this year and start my Git Adventure
in GSoC.

I am no stranger to Git usage, and before the start of GSoC,
I have learned some Git source code content, but I only saw
the tip of the iceberg of Git source code, there are still many
things that I need to explore.

### What happened this week
- In [[GSoC] Hello
Git](https://lore.kernel.org/git/CAOLTT8SHE-ok3D+oLNSWFi7KPU==VQnTMDmC4YxUyNBJKmBD8A@mail.gmail.com/),
Christian and JiangXin interacted with me.
- I checked Olga's patch at Christian's prompt and learned a way
to make `cat-file --batch` use `ref-filter` logic: Use `format_ref_array_item()`
in `batch_object_write()`, this is indeed a good entry point. But
before implementing this function, we must make `ref-filter`
support the function of printing the original data of the object
(as `cat-file --batch` does). I decided to reuse the atom
`%(content:raw)` in ref-filter to implement this function.

### The difficulties I met
In [[PATCH] [GSOC] ref-filter: add contents:raw
atom](https://lore.kernel.org/git/pull.958.git.1621500593126.gitgitgadget@gmail.com/),
I submitted a patch, which support atom `%(content:raw)`
for `ref-filter`.

Unfortunately, this patch has a big problem:
I ignored the breakage on the test. This led me to
discover a bigger problem:

If our references points to a blob or a tree, and  these objects may
be binary files, this means that we cannot use functions related
to `strcmp()`,`strlen()` or `strbuf_addstr()`. The possible '\0' will
cause the output to be truncated. We have to think of a way to make
`ref-filter` can accept the output of these binary content.

So I searched for all the codes in `ref-filter.c` that buffer might be
truncated by '\0' and use the appropriate method to replace them.

Just like replacing `strcmp()` with `memcmp()`, We can use `strbuf_add()`
instead of `strbuf_addstr()`,
At the same time I also wrote the equivalent `*._quote_buf_with_size()`
to replace `*._quote_buf()`.

I just submit it to the mailing list right now:
[[GSOC][RFC] ref-filter: add contents:raw atom]
(https://lore.kernel.org/git/pull.959.git.1621763612.gitgitgadget@gmail.com/)

I don’t know if this is the right approach at the moment, let
us slowly wait for the suggestions of mentors and reviewers... ;-)

Thanks!
--
ZheNing Hu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [GSoC] Git Blog 1
  2021-05-23 10:53 [GSoC] Git Blog 1 ZheNing Hu
@ 2021-05-24 20:47 ` Christian Couder
  2021-05-26  9:22   ` ZheNing Hu
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Couder @ 2021-05-24 20:47 UTC (permalink / raw)
  To: ZheNing Hu; +Cc: Git List, Junio C Hamano, Hariom verma

On Sun, May 23, 2021 at 12:53 PM ZheNing Hu <adlternative@gmail.com> wrote:
>
> My first week blog finished:
> The web version is here:
> https://adlternative.github.io/GSOC-Git-Blog-1/

Great!

See some comments below, but you don't need to update your blog post
for each comment. Some are just remarks that might help you.

> -----
>
> ## Week1: Git Adventure Begin
>
> Use Git to submit Git patches to the Git community.
> Does it sound magical? I fell very lucky to be selected

s/fell/feel/

> by the Git community this year and start my Git Adventure
> in GSoC.
>
> I am no stranger to Git usage, and before the start of GSoC,
> I have learned some Git source code content, but I only saw
> the tip of the iceberg of Git source code, there are still many
> things that I need to explore.
>
> ### What happened this week
> - In [[GSoC] Hello
> Git](https://lore.kernel.org/git/CAOLTT8SHE-ok3D+oLNSWFi7KPU==VQnTMDmC4YxUyNBJKmBD8A@mail.gmail.com/),
> Christian and JiangXin interacted with me.
> - I checked Olga's patch at Christian's prompt and learned a way
> to make `cat-file --batch` use `ref-filter` logic: Use `format_ref_array_item()`
> in `batch_object_write()`, this is indeed a good entry point. But
> before implementing this function, we must make `ref-filter`
> support the function of printing the original data of the object
> (as `cat-file --batch` does). I decided to reuse the atom

In your blog post it looks like a space is missing after "object" as
we see "object(as".

> `%(content:raw)` in ref-filter to implement this function.

The above could be understood as saying that `%(content:raw)` already
exists, which is not really true. Maybe you could say something like
"I decided to add the ":raw" option to the existing `%(content)` atom
in ref-filter.c to implement this function."

> ### The difficulties I met
> In [[PATCH] [GSOC] ref-filter: add contents:raw
> atom](https://lore.kernel.org/git/pull.958.git.1621500593126.gitgitgadget@gmail.com/),
> I submitted a patch, which support atom `%(content:raw)`

s/support/supports/

or

s/support/adds support for/

> for `ref-filter`.
>
> Unfortunately, this patch has a big problem:
> I ignored the breakage on the test. This led me to

Maybe: s/the breakage on the test/a test breakage/

> discover a bigger problem:
>
> If our references points to a blob or a tree, and  these objects may
> be binary files,

The raw content of a tree indeed contains the binary contents of the
hashes it references, while other objects like commit and tags contain
hashes in the hexadecimal format.

> this means that we cannot use functions related
> to `strcmp()`,`strlen()` or `strbuf_addstr()`. The possible '\0' will
> cause the output to be truncated. We have to think of a way to make
> `ref-filter` can accept the output of these binary content.

The strbuf API has functions to deal with binary content.

> So I searched for all the codes in `ref-filter.c` that buffer might be
> truncated by '\0' and use the appropriate method to replace them.
>
> Just like replacing `strcmp()` with `memcmp()`, We can use `strbuf_add()`
> instead of `strbuf_addstr()`,
> At the same time I also wrote the equivalent `*._quote_buf_with_size()`
> to replace `*._quote_buf()`.

Nice!

> I just submit it to the mailing list right now:
> [[GSOC][RFC] ref-filter: add contents:raw atom]
> (https://lore.kernel.org/git/pull.959.git.1621763612.gitgitgadget@gmail.com/)

By the way a better title for your patch might be "[GSOC][RFC]
ref-filter: add ':raw' option to %(contents) atom"

> I don’t know if this is the right approach at the moment, let
> us slowly wait for the suggestions of mentors and reviewers... ;-)

Thanks,
Christian.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [GSoC] Git Blog 1
  2021-05-24 20:47 ` Christian Couder
@ 2021-05-26  9:22   ` ZheNing Hu
  0 siblings, 0 replies; 3+ messages in thread
From: ZheNing Hu @ 2021-05-26  9:22 UTC (permalink / raw)
  To: Christian Couder; +Cc: Git List, Junio C Hamano, Hariom verma

Christian Couder <christian.couder@gmail.com> 于2021年5月25日周二 上午4:47写道:
>
> On Sun, May 23, 2021 at 12:53 PM ZheNing Hu <adlternative@gmail.com> wrote:
> >
> > My first week blog finished:
> > The web version is here:
> > https://adlternative.github.io/GSOC-Git-Blog-1/
>
> Great!
>
> See some comments below, but you don't need to update your blog post
> for each comment. Some are just remarks that might help you.
>
> > -----
> >
> > ## Week1: Git Adventure Begin
> >
> > Use Git to submit Git patches to the Git community.
> > Does it sound magical? I fell very lucky to be selected
>
> s/fell/feel/
>
> > by the Git community this year and start my Git Adventure
> > in GSoC.
> >
> > I am no stranger to Git usage, and before the start of GSoC,
> > I have learned some Git source code content, but I only saw
> > the tip of the iceberg of Git source code, there are still many
> > things that I need to explore.
> >
> > ### What happened this week
> > - In [[GSoC] Hello
> > Git](https://lore.kernel.org/git/CAOLTT8SHE-ok3D+oLNSWFi7KPU==VQnTMDmC4YxUyNBJKmBD8A@mail.gmail.com/),
> > Christian and JiangXin interacted with me.
> > - I checked Olga's patch at Christian's prompt and learned a way
> > to make `cat-file --batch` use `ref-filter` logic: Use `format_ref_array_item()`
> > in `batch_object_write()`, this is indeed a good entry point. But
> > before implementing this function, we must make `ref-filter`
> > support the function of printing the original data of the object
> > (as `cat-file --batch` does). I decided to reuse the atom
>
> In your blog post it looks like a space is missing after "object" as
> we see "object(as".
>
> > `%(content:raw)` in ref-filter to implement this function.
>
> The above could be understood as saying that `%(content:raw)` already
> exists, which is not really true. Maybe you could say something like
> "I decided to add the ":raw" option to the existing `%(content)` atom
> in ref-filter.c to implement this function."
>
> > ### The difficulties I met
> > In [[PATCH] [GSOC] ref-filter: add contents:raw
> > atom](https://lore.kernel.org/git/pull.958.git.1621500593126.gitgitgadget@gmail.com/),
> > I submitted a patch, which support atom `%(content:raw)`
>
> s/support/supports/
>
> or
>
> s/support/adds support for/
>
> > for `ref-filter`.
> >
> > Unfortunately, this patch has a big problem:
> > I ignored the breakage on the test. This led me to
>
> Maybe: s/the breakage on the test/a test breakage/
>

Thanks for these grammatical corrections. I will apply them
to my blog (very easy)

> > discover a bigger problem:
> >
> > If our references points to a blob or a tree, and  these objects may
> > be binary files,
>
> The raw content of a tree indeed contains the binary contents of the
> hashes it references, while other objects like commit and tags contain
> hashes in the hexadecimal format.
>
> > this means that we cannot use functions related
> > to `strcmp()`,`strlen()` or `strbuf_addstr()`. The possible '\0' will
> > cause the output to be truncated. We have to think of a way to make
> > `ref-filter` can accept the output of these binary content.
>
> The strbuf API has functions to deal with binary content.
>

Yes it is.

> > So I searched for all the codes in `ref-filter.c` that buffer might be
> > truncated by '\0' and use the appropriate method to replace them.
> >
> > Just like replacing `strcmp()` with `memcmp()`, We can use `strbuf_add()`
> > instead of `strbuf_addstr()`,
> > At the same time I also wrote the equivalent `*._quote_buf_with_size()`
> > to replace `*._quote_buf()`.
>
> Nice!
>
> > I just submit it to the mailing list right now:
> > [[GSOC][RFC] ref-filter: add contents:raw atom]
> > (https://lore.kernel.org/git/pull.959.git.1621763612.gitgitgadget@gmail.com/)
>
> By the way a better title for your patch might be "[GSOC][RFC]
> ref-filter: add ':raw' option to %(contents) atom"
>

Good suggestion.

> > I don’t know if this is the right approach at the moment, let
> > us slowly wait for the suggestions of mentors and reviewers... ;-)
>
> Thanks,
> Christian.

Thanks.
--
ZheNing Hu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-26  9:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-23 10:53 [GSoC] Git Blog 1 ZheNing Hu
2021-05-24 20:47 ` Christian Couder
2021-05-26  9:22   ` ZheNing Hu

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).