* How to get the original raw commit message without removing extra leading/trailing line breaks
@ 2022-03-28 5:42 PMEase
2022-03-28 5:53 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: PMEase @ 2022-03-28 5:42 UTC (permalink / raw)
To: git
Hi Folks,
I am using command "git show --format=raw <commit hash>" to get raw commit object in order to verify the GPG signature in my program to customize public key loading. However in the raw commit object, extra line breaks before and after the commit message is removed, which cause the signature verification failure as git generates the signature without removing those line breaks.
So is there any way to get the exact, original commit message? I also tried format option %B in no vail.
Thanks for your time.
Robin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to get the original raw commit message without removing extra leading/trailing line breaks
2022-03-28 5:42 How to get the original raw commit message without removing extra leading/trailing line breaks PMEase
@ 2022-03-28 5:53 ` Junio C Hamano
2022-03-28 6:01 ` PMEase
2022-03-28 6:11 ` PMEase
0 siblings, 2 replies; 5+ messages in thread
From: Junio C Hamano @ 2022-03-28 5:53 UTC (permalink / raw)
To: PMEase; +Cc: git
PMEase <robin@pmease.com> writes:
[jc: wrapped overly long lines]
> I am using command "git show --format=raw <commit hash>" to get
> raw commit object in order to verify the GPG signature in my
> program to customize public key loading. However in the raw commit
> object, extra line breaks before and after the commit message is
> removed, which cause the signature verification failure as git
> generates the signature without removing those line breaks.
"git show --format=raw <commit object name>" will not give "raw
commit object" to begin with. It indents the message by four
spaces.
"git cat-file commit <commit object name>" is what you want, I
think.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to get the original raw commit message without removing extra leading/trailing line breaks
2022-03-28 5:53 ` Junio C Hamano
@ 2022-03-28 6:01 ` PMEase
2022-03-28 6:11 ` Junio C Hamano
2022-03-28 6:11 ` PMEase
1 sibling, 1 reply; 5+ messages in thread
From: PMEase @ 2022-03-28 6:01 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Hi Junio,
Thanks for your response. "git cat-file" prints the commit message without leading space on each line, however extra leading/trailing line breaks of the commit message is still removed.
> On Mar 28, 2022, at 1:53 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> PMEase <robin@pmease.com> writes:
>
> [jc: wrapped overly long lines]
>
>> I am using command "git show --format=raw <commit hash>" to get
>> raw commit object in order to verify the GPG signature in my
>> program to customize public key loading. However in the raw commit
>> object, extra line breaks before and after the commit message is
>> removed, which cause the signature verification failure as git
>> generates the signature without removing those line breaks.
>
> "git show --format=raw <commit object name>" will not give "raw
> commit object" to begin with. It indents the message by four
> spaces.
>
> "git cat-file commit <commit object name>" is what you want, I
> think.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to get the original raw commit message without removing extra leading/trailing line breaks
2022-03-28 5:53 ` Junio C Hamano
2022-03-28 6:01 ` PMEase
@ 2022-03-28 6:11 ` PMEase
1 sibling, 0 replies; 5+ messages in thread
From: PMEase @ 2022-03-28 6:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
It also converts \r\n to \n and remove all spaces in a blank line. This is reasonable for a readable commit message, but makes it impossible to verify signature in my program...
> On Mar 28, 2022, at 1:53 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> PMEase <robin@pmease.com> writes:
>
> [jc: wrapped overly long lines]
>
>> I am using command "git show --format=raw <commit hash>" to get
>> raw commit object in order to verify the GPG signature in my
>> program to customize public key loading. However in the raw commit
>> object, extra line breaks before and after the commit message is
>> removed, which cause the signature verification failure as git
>> generates the signature without removing those line breaks.
>
> "git show --format=raw <commit object name>" will not give "raw
> commit object" to begin with. It indents the message by four
> spaces.
>
> "git cat-file commit <commit object name>" is what you want, I
> think.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How to get the original raw commit message without removing extra leading/trailing line breaks
2022-03-28 6:01 ` PMEase
@ 2022-03-28 6:11 ` Junio C Hamano
0 siblings, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2022-03-28 6:11 UTC (permalink / raw)
To: PMEase; +Cc: git
PMEase <robin@pmease.com> writes:
>> On Mar 28, 2022, at 1:53 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>
>> PMEase <robin@pmease.com> writes:
>>
>> [jc: wrapped overly long lines]
>>
>>> I am using command "git show --format=raw <commit hash>" to get
>>> raw commit object in order to verify the GPG signature in my
>>> program to customize public key loading. However in the raw commit
>>> object, extra line breaks before and after the commit message is
>>> removed, which cause the signature verification failure as git
>>> generates the signature without removing those line breaks.
>>
>> "git show --format=raw <commit object name>" will not give "raw
>> commit object" to begin with. It indents the message by four
>> spaces.
>>
>> "git cat-file commit <commit object name>" is what you want, I
>> think.
[jc: wrapped overly long lines, moved response at the end to correct
top-posting]
> Thanks for your response. "git cat-file" prints the commit message
> without leading space on each line, however extra leading/trailing
> line breaks of the commit message is still removed.
I think you are creating your commit incorrectly. If a line is
missing in what cat-file prints, then the line is *NOT* in the
commit. If I try the following:
----- >8 --------- >8 --------- >8 --------- >8 -----
C=$(
cat <<\EOF | git commit-tree -p HEAD HEAD^{tree}
This "first line" deliberately is on the second line.
And after the "last line" of the log message, this commit
has extra blank lines at the end.
EOF
)
echo "begin"; git cat-file commit "$C"; echo "end"
----- 8< --------- 8< --------- 8< --------- 8< -----
I get:
begin
tree 5365fd773adaac0f84c4f07532eec8809f3f6f0e
parent abf474a5dd901f28013c52155411a48fd4c09922
author Junio C Hamano <gitster@pobox.com> 1648447791 -0700
committer Junio C Hamano <gitster@pobox.com> 1648447791 -0700
This "first line" deliberately is on the second line.
And after the "last line" of the log message, this commit
has extra blank lines at the end.
end
which is very much what I expect to see.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-03-28 6:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-28 5:42 How to get the original raw commit message without removing extra leading/trailing line breaks PMEase
2022-03-28 5:53 ` Junio C Hamano
2022-03-28 6:01 ` PMEase
2022-03-28 6:11 ` Junio C Hamano
2022-03-28 6:11 ` PMEase
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox