Re: git-log --format missing trailing newline character

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Kristoffer,

On Mon, Dec 23, 2024 at 09:36:48PM GMT, Kristoffer Haugsbakk wrote:
> On Mon, Dec 23, 2024, at 21:28, Alejandro Colomar wrote:
> > Hi!
> >
> > I'm having trouble scripting around git-log(1), due to a missing newline
> > character at the end of the file.
> >
> > 	$ git -v
> > 	git version 2.45.2
> > 	$ git log --format=format:'%H' HEAD^^^..HEAD | wc -l
> > 	2
> > 	$ git log --format=format:'%H' HEAD^^^..HEAD
> > 	2ff431ab1b46a25088fe40baf1faf35ea9fac722
> > 	e75e6c4504022ae52d877926e63c908d9572088a
> > 	178442837d39560a789a8044a8eb90fde3ad7cd7
> >
> > Would you mind fixing this bug?  POSIX requires that text files end in a
> > newline character, precisely for being able to use UNIX tools to process
> > output from arbitrary commands.
> 
> Is the format here simplified relative to your use case?  Or do you just
> want to process commits as one-hash-per-line?

I want to process commits as one-hash-per-line, yes.

The entire pipeline I have is this:

	git rev-list "$old..HEAD" \
	| sed 's,.*,https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib\&id=&;,';

which I run in <hooks/post-update> in my server for printing URIs to all
of the newly pushed commits.  I use that for easily pasting them to the
confirmation email I write to contributors when I apply and push one of
their patches.

>  I would use
> git-rev-list(1) instead in that case.

Hmmm, thanks!  I knew there had to be some git-rev-something for this,
but couldn't find it!  :)

I had workarounded it by doing

	git log --oneline --abbrev=40 | cut -f1 -d' '

However, git-rev-list(1) is better, of course, so I'll use it.

Anyway, it feels awkward that git-log(1) skips the last newline whith
--format=format.  Should that be fixed?


Have a lovely night!
Alex

> 
> -- 
> Kristoffer Haugsbakk
> 

-- 
<https://www.alejandro-colomar.es/>

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux