Re: [RFC PATCH 3/9] rebase -i: comment out squash!/fixup! subjects from squash message
- From
Charvi Mendiratta <charvi077@gmail.com>
- Date
- Jan 15, 2021, 11:12 UTC
- Message-ID
- <CAPSFM5eiV-Kd3T7Ug9838UJVXKNPZ7x+C5UdRybu6wR0=sw4Ug@mail.gmail.com>
- In-Reply-To
- <CAP8UFD3_RPrFQELiBp=QFgheQa8RhDYcwgLmG9Eb4fFKH4p+FA@mail.gmail.com>
Hi Christian,
On Fri, 15 Jan 2021 at 14:15, Christian Couder <christian.couder@gmail.com> wrote:
Show 46 quoted lines
>
> Hi Charvi,
>
> On Fri, Jan 15, 2021 at 9:35 AM Charvi Mendiratta <charvi077@gmail.com> wrote:
>
> > On Thu, 14 Jan 2021 at 15:59, Phillip Wood <phillip.wood123@gmail.com> wrote:
>
> > > On 14/01/2021 08:27, Charvi Mendiratta wrote:
> > > > On Thu, 14 Jan 2021 at 00:31, Taylor Blau <me@ttaylorr.com> wrote:
> > > >>
> > > >> On Fri, Jan 08, 2021 at 02:53:41PM +0530, Charvi Mendiratta wrote:
> > > >>> From: Phillip Wood <phillip.wood@dunelm.org.uk>
>
> > > >>> +static size_t subject_length(const char *body)
> > > >>> +{
> > > >>> + size_t i, len = 0;
> > > >>> + char c;
> > > >>> + int blank_line = 1;
> > > >>> + for (i = 0, c = body[i]; c; c = body[++i]) {
> > > >>> + if (c == '\n') {
> > > >>> + if (blank_line)
> > > >>> + return len;
> > > >>> + len = i + 1;
> > > >>> + blank_line = 1;
> > > >>> + } else if (!isspace(c)) {
> > > >>> + blank_line = 0;
> > > >>> + }
> > > >>> + }
> > > >>> + return blank_line ? len : i;
> > > >>> +}
> > > >>
> > > >> OK, so this gets the length of the subject in "body", which is defined
> > > >> as the run of characters before a newline and then a space character.
> > >
> > > The length of the subject is the run of characters before a line
> > > containing only whitespace, "hello\n there" would return 13 "hello\n
> > > \nthere" would return 5. Looking again at my code there must be a way of
> > > writing that function that is easier to follow.
> >
> > Okay. I will look into it once, thanks for explaining.
>
> You may want to look at other places in the code where we deal with
> the subject. For example there is find_commit_subject() in commit.c
> and find_trailer_start() in trailer.c that might have interesting code
> for our purpose.
>Thanks for the pointer, I will look at it.
Thanks and Regards, Charvi
> Best, > Christian.