{"thread":{"id":"62689","subject":"git-log --format missing trailing newline character","startedAt":"2024-12-23T20:29:02Z","lastAt":"2024-12-26T17:06:28Z","messageCount":7,"participants":["Alejandro Colomar","Kristoffer Haugsbakk","Andreas Schwab","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"509530","messageId":"cw7vyas4yw2q4lqiskbvil7mpkx5l5qilj25vnqzkrp5nuezrx@d6tsavm3ajzw","threadId":"62689","inReplyTo":null,"subject":"git-log --format missing trailing newline character","fromName":"Alejandro Colomar","fromEmail":"alx@kernel.org","sentAt":"2024-12-23T20:28:59Z","receivedAt":"2024-12-23T20:29:02Z","isPatch":false,"sender":{"key":"alx@kernel.org","avatar":null},"body":"Hi!\n\nI'm having trouble scripting around git-log(1), due to a missing newline\ncharacter at the end of the file.\n\n\t$ git -v\n\tgit version 2.45.2\n\t$ git log --format=format:'%H' HEAD^^^..HEAD | wc -l\n\t2\n\t$ git log --format=format:'%H' HEAD^^^..HEAD\n\t2ff431ab1b46a25088fe40baf1faf35ea9fac722\n\te75e6c4504022ae52d877926e63c908d9572088a\n\t178442837d39560a789a8044a8eb90fde3ad7cd7\n\nWould you mind fixing this bug?  POSIX requires that text files end in a\nnewline character, precisely for being able to use UNIX tools to process\noutput from arbitrary commands.\n\n\nHave a lovely night!\nAlex\n\n-- \n<https://www.alejandro-colomar.es/>\n"},{"id":"509531","messageId":"d813a3dd-68c2-4cbe-92a0-cfd1ece77e9b@app.fastmail.com","threadId":"62689","inReplyTo":"cw7vyas4yw2q4lqiskbvil7mpkx5l5qilj25vnqzkrp5nuezrx@d6tsavm3ajzw","subject":"Re: git-log --format missing trailing newline character","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-12-23T20:36:48Z","receivedAt":"2024-12-23T20:37:09Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Mon, Dec 23, 2024, at 21:28, Alejandro Colomar wrote:\n> Hi!\n>\n> I'm having trouble scripting around git-log(1), due to a missing newline\n> character at the end of the file.\n>\n> \t$ git -v\n> \tgit version 2.45.2\n> \t$ git log --format=format:'%H' HEAD^^^..HEAD | wc -l\n> \t2\n> \t$ git log --format=format:'%H' HEAD^^^..HEAD\n> \t2ff431ab1b46a25088fe40baf1faf35ea9fac722\n> \te75e6c4504022ae52d877926e63c908d9572088a\n> \t178442837d39560a789a8044a8eb90fde3ad7cd7\n>\n> Would you mind fixing this bug?  POSIX requires that text files end in a\n> newline character, precisely for being able to use UNIX tools to process\n> output from arbitrary commands.\n\nIs the format here simplified relative to your use case?  Or do you just\nwant to process commits as one-hash-per-line?  I would use\ngit-rev-list(1) instead in that case.\n\n-- \nKristoffer Haugsbakk\n\n"},{"id":"509532","messageId":"5aib7c6x5m6e4muutjuoqp3f4lvpeh3hz5qkwpayi2usm7b6yi@af2oucx5j4w5","threadId":"62689","inReplyTo":"d813a3dd-68c2-4cbe-92a0-cfd1ece77e9b@app.fastmail.com","subject":"Re: git-log --format missing trailing newline character","fromName":"Alejandro Colomar","fromEmail":"alx@kernel.org","sentAt":"2024-12-23T20:49:40Z","receivedAt":"2024-12-23T20:49:43Z","isPatch":false,"sender":{"key":"alx@kernel.org","avatar":null},"body":"Hi Kristoffer,\n\nOn Mon, Dec 23, 2024 at 09:36:48PM GMT, Kristoffer Haugsbakk wrote:\n> On Mon, Dec 23, 2024, at 21:28, Alejandro Colomar wrote:\n> > Hi!\n> >\n> > I'm having trouble scripting around git-log(1), due to a missing newline\n> > character at the end of the file.\n> >\n> > \t$ git -v\n> > \tgit version 2.45.2\n> > \t$ git log --format=format:'%H' HEAD^^^..HEAD | wc -l\n> > \t2\n> > \t$ git log --format=format:'%H' HEAD^^^..HEAD\n> > \t2ff431ab1b46a25088fe40baf1faf35ea9fac722\n> > \te75e6c4504022ae52d877926e63c908d9572088a\n> > \t178442837d39560a789a8044a8eb90fde3ad7cd7\n> >\n> > Would you mind fixing this bug?  POSIX requires that text files end in a\n> > newline character, precisely for being able to use UNIX tools to process\n> > output from arbitrary commands.\n> \n> Is the format here simplified relative to your use case?  Or do you just\n> want to process commits as one-hash-per-line?\n\nI want to process commits as one-hash-per-line, yes.\n\nThe entire pipeline I have is this:\n\n\tgit rev-list \"$old..HEAD\" \\\n\t| sed 's,.*,https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib\\&id=&,';\n\nwhich I run in <hooks/post-update> in my server for printing URIs to all\nof the newly pushed commits.  I use that for easily pasting them to the\nconfirmation email I write to contributors when I apply and push one of\ntheir patches.\n\n>  I would use\n> git-rev-list(1) instead in that case.\n\nHmmm, thanks!  I knew there had to be some git-rev-something for this,\nbut couldn't find it!  :)\n\nI had workarounded it by doing\n\n\tgit log --oneline --abbrev=40 | cut -f1 -d' '\n\nHowever, git-rev-list(1) is better, of course, so I'll use it.\n\nAnyway, it feels awkward that git-log(1) skips the last newline whith\n--format=format.  Should that be fixed?\n\n\nHave a lovely night!\nAlex\n\n> \n> -- \n> Kristoffer Haugsbakk\n> \n\n-- \n<https://www.alejandro-colomar.es/>\n"},{"id":"509533","messageId":"8734ieyumd.fsf@igel.home","threadId":"62689","inReplyTo":"5aib7c6x5m6e4muutjuoqp3f4lvpeh3hz5qkwpayi2usm7b6yi@af2oucx5j4w5","subject":"Re: git-log --format missing trailing newline character","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2024-12-23T21:09:14Z","receivedAt":"2024-12-23T21:16:11Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"On Dez 23 2024, Alejandro Colomar wrote:\n\n> Anyway, it feels awkward that git-log(1) skips the last newline whith\n> --format=format.  Should that be fixed?\n\nIf you want terminator semantics, use tformat: instead of format:.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1\n\"And now for something completely different.\"\n"},{"id":"509534","messageId":"elrdfos3fkzjdmhvyxbshsbt6nw723mr3m7blw7ghghnresxi6@vvj7u6jwlgur","threadId":"62689","inReplyTo":"8734ieyumd.fsf@igel.home","subject":"Re: git-log --format missing trailing newline character","fromName":"Alejandro Colomar","fromEmail":"alx@kernel.org","sentAt":"2024-12-23T21:23:31Z","receivedAt":"2024-12-23T21:23:34Z","isPatch":false,"sender":{"key":"alx@kernel.org","avatar":null},"body":"Hi Andreas,\n\nOn Mon, Dec 23, 2024 at 10:09:14PM GMT, Andreas Schwab wrote:\n> On Dez 23 2024, Alejandro Colomar wrote:\n> \n> > Anyway, it feels awkward that git-log(1) skips the last newline whith\n> > --format=format.  Should that be fixed?\n> \n> If you want terminator semantics, use tformat: instead of format:.\n\nThanks!\n\nHave a lovely night!\nAlex\n\n-- \n<https://www.alejandro-colomar.es/>\n"},{"id":"509566","messageId":"xmqq4j2qzb6d.fsf@gitster.g","threadId":"62689","inReplyTo":"elrdfos3fkzjdmhvyxbshsbt6nw723mr3m7blw7ghghnresxi6@vvj7u6jwlgur","subject":"Re: git-log --format missing trailing newline character","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-12-26T16:00:42Z","receivedAt":"2024-12-26T16:00:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Alejandro Colomar <alx@kernel.org> writes:\n\n> Hi Andreas,\n>\n> On Mon, Dec 23, 2024 at 10:09:14PM GMT, Andreas Schwab wrote:\n>> On Dez 23 2024, Alejandro Colomar wrote:\n>> \n>> > Anyway, it feels awkward that git-log(1) skips the last newline whith\n>> > --format=format.  Should that be fixed?\n>> \n>> If you want terminator semantics, use tformat: instead of format:.\n\nOr, \"--format=%H\" should do the right thing, as that is a mere\nshort-hand for \"--pretty=tformat:%H\".\n"},{"id":"509570","messageId":"jwatyfdnn65ot2s3i4uhrseh5kbkudsqv2a6bzmz2xncdzly6v@7gi4gmajls3g","threadId":"62689","inReplyTo":"xmqq4j2qzb6d.fsf@gitster.g","subject":"Re: git-log --format missing trailing newline character","fromName":"Alejandro Colomar","fromEmail":"alx@kernel.org","sentAt":"2024-12-26T17:06:25Z","receivedAt":"2024-12-26T17:06:28Z","isPatch":false,"sender":{"key":"alx@kernel.org","avatar":null},"body":"Hi Junio,\n\nOn Thu, Dec 26, 2024 at 08:00:42AM -0800, Junio C Hamano wrote:\n> Alejandro Colomar <alx@kernel.org> writes:\n> \n> > Hi Andreas,\n> >\n> > On Mon, Dec 23, 2024 at 10:09:14PM GMT, Andreas Schwab wrote:\n> >> On Dez 23 2024, Alejandro Colomar wrote:\n> >> \n> >> > Anyway, it feels awkward that git-log(1) skips the last newline whith\n> >> > --format=format.  Should that be fixed?\n> >> \n> >> If you want terminator semantics, use tformat: instead of format:.\n> \n> Or, \"--format=%H\" should do the right thing, as that is a mere\n> short-hand for \"--pretty=tformat:%H\".\n\nHmmm.  So many times having read that part of the manual, and I had\nnever noticed that.  I had never seen that tformat existed, and even\nless that the default was it (when there's %placeholder string).  I had\nalways read 'format' instead of 'tformat'.  :)\n\nThanks!\n\n-- \n<https://www.alejandro-colomar.es/>\n"}]}