git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/1] Extract only the message body from git commit.

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 22, 2026, 20:53 UTC
Message-ID
<xmqqtspqn3v1.fsf@gitster.g>
In-Reply-To
<20260722083836.744338-2-hardikxk@gmail.com>
hardikxk <hardikxk@gmail.com> writes:
> Subject: Re: [PATCH 1/1] Extract only the message body from git commit.
Please see Documentation/SubmittingPatches[[describe-changes]].
> The patch fixes the `extractLogMessageFromGitCommit` function to skip all the metada of the commit object and only return back the message body.
Line-wrap overly long lines like this one.
> Previously the function would return the entire data of the objects
> including authors tree and SHAs. This patch fixes that to skip over all
> that and just return the body of the log message.

Please see Documentation/SubmittingPatches[[meaningful-message]]. The observation on how the current code behaves should not be described as "Previously X did Y". Just say "X does Y" instead. There are other rules on how to write proposed commit log messages explained there.

> Signed-off-by: hardikxk <hardikxk@gmail.com>
Please see Documentation/SubmittingPatches[[real-name]].
> ---
>  git-p4.py | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
Thanks.
Show 26 quoted lines
> diff --git a/git-p4.py b/git-p4.py
> index c0ca7be..589efcd 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -1003,12 +1003,18 @@ def branchExists(ref):
>  def extractLogMessageFromGitCommit(commit):
>      logMessage = ""
>  
> -    # fixme: title is first line of commit, not 1st paragraph.
> +    foundNewLine = False
>      foundTitle = False
>      for log in read_pipe_lines(["git", "cat-file", "commit", commit]):
> -        if not foundTitle:
> +        if not foundNewLine:
> +            # skip anything that is not the commit message
>              if len(log) == 1:
> -                foundTitle = True
> +                foundNewLine = True
> +            continue
> +
> +        # everything from here is the commit message
> +        if not foundTitle:
> +            foundTitle = True
>              continue
>  
>          logMessage += log
Previous: Hardik KumarNext: Hardik Kumar
Message 5 of 7 in “Extract only the message log body from git commit.”
  1. 0/1 Extract only the message log body from git commit.hardikxk, Jul 22, 2026
  2. 1/1 Extract only the message body from git commit.hardikxk, Jul 22, 2026
  3. Pablo SabaterJul 22, 2026
  4. Hardik KumarJul 22, 2026
  5. Junio C HamanoJul 22, 2026
  6. Hardik KumarJul 23, 2026
  7. Pablo SabaterJul 22, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.