Thread (97 messages) 97 messages, 6 authors, 2021-02-06

Re: [RFC PATCH 3/9] rebase -i: comment out squash!/fixup! subjects from squash message

flat view

From: Christian Couder <hidden>
Date: 2021-01-15 08:46:05

Hi Charvi,

On Fri, Jan 15, 2021 at 9:35 AM Charvi Mendiratta [off-list ref] wrote:
On Thu, 14 Jan 2021 at 15:59, Phillip Wood [off-list ref] wrote:
quoted
On 14/01/2021 08:27, Charvi Mendiratta wrote:
quoted
On Thu, 14 Jan 2021 at 00:31, Taylor Blau [off-list ref] wrote:
quoted
On Fri, Jan 08, 2021 at 02:53:41PM +0530, Charvi Mendiratta wrote:
quoted
From: Phillip Wood <redacted>
quoted
quoted
quoted
quoted
+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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help