Re: [RFC PATCH 3/9] rebase -i: comment out squash!/fixup! subjects from squash message
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Jan 15, 2021, 08:44 UTC
- Message-ID
- <CAP8UFD3_RPrFQELiBp=QFgheQa8RhDYcwgLmG9Eb4fFKH4p+FA@mail.gmail.com>
- In-Reply-To
- <CAPSFM5co06fdo=vqTMeHLtYyP37qucGVRtOiFsZBwiR1UOsm8Q@mail.gmail.com>
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:
Show 5 quoted lines
> > 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>
Show 27 quoted lines
> > >>> +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.
Best, Christian.