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

"Pablo Sabater" <[email protected]>
Newsgroups org.kernel.vger.git
Message-ID <[email protected]>
On Wed Jul 22, 2026 at 10:38 AM CEST, hardikxk wrote:
> The patch fixes the `extractLogMessageFromGitCommit` function to skip all the metada of the commit object and only return back the message body.

nit: wrap this long line to a max of ~72 columns.
nit: s/metada/metadata/

>
> 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.

nit: I think this can be written more clearly. Let's use present tense
and state things affirmatively:

  extractLogMessageFromGitCommit() returns the entire object data,
  including authors, tree and SHAs.
  Make it return only the log message body.

Don't take this suggestion literally, as we find below that this log
does not match reality.

You may find Documentation/CodingGuidelines and
Documentation/SubmittingPatches interesting.

>
> Signed-off-by: hardikxk <[email protected]>
> ---
>  git-p4.py | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> 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

Reading the code, this doesn't seem to do what the log says it does.
Testing it against what it did before this patch:

First we need to do a bit of investigation, but we end up finding
that the commit that introduced this '# fixme' was:

  b016d39756 (Robustness fixes for pipes, 2007-05-23)

I couldn't find a thread about this commit.

*Note that the output does not have line breaks; I'm adding them for
readability*.

previously:

'Extract only the message body from git commit.\n\nThe patch fixes the
`extractLogMessageFromGitCommit` function to skip all the metada of the
commit object and only return back the message body.\n\nPreviously the
function would return the entire data of the objects\nincluding authors
tree and SHAs. This patch fixes that to skip over all\nthat and just
return the body of the log message.\n\nSigned-off-by: hardikxk <[email protected]>\n'

after the patch:

'\nThe patch fixes the `extractLogMessageFromGitCommit` function to skip
all the metada of the commit object and only return back the message
body.\n\nPreviously the function would return the entire data of the
objects\nincluding authors tree and SHAs. This patch fixes that to skip
over all\nthat and just return the body of the log message.
\n\nSigned-off-by: hardikxk <[email protected]>\n'

We can see that the previous output only shows the commit log, title
+ body. There were no SHAs, tree, etc., the opposite of what this
patch's log claimed.

What this patch actually does is drop the commit subject.

Is this what the '# fixme' meant? I'm making assumptions here, since I
couldn't find a thread to be sure why it was added, but I think it is
either about the loop stopping at the blank line rather than at the title
itself, or a warning that a title is just one line and not a paragraph.

Either way, this patch does not address the '# fixme' correctly.

Before continuing, I think we should try to understand what the '# fixme'
meant in the first place.

Regards,
Pablo.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.