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

[Question] git-commit: --template from cmd output

From
ASAvid Seeker <avidseeker7@protonmail.com>
Date
Aug 7, 2024, 01:34 UTC
Message-ID
<exd_wMoR3eM-2oo-XbhCudo6nHa1cgm9cBIpSNvj5EFHBPeqveBW-44rILPLINIB5fxxrBLCpApjFYI55ckzEYNZr9qibkFcHnMI8FLQOj8=@protonmail.com>

I'm trying to customize the commit message instructions showing up in text editor after `git commit`. Checking the docs, I found these flags of interest:

- commit.verbose: useful flag to see the diff of changes done.
- commit.status: for toggling whether to show status or not.
- commit.template: this is what I was looking for, but when I checked the doc,
  it turned out to be a useless.

IMO, all of these flags are redundant and should be combined in one flag done in the Unix way of doing one thing and doing it well, which is displaying commit message comments within the editor.

The way to do it is by having commit.template as a script:

commit.template = "echo $COMMENTED_INSTRUCTIONS; git diff" # commit --verbose commit.template = "echo $COMMENTED_INSTRUCTIONS; git status" # commit --status commit.template = "" # commit --no-status commit.template = "cat path/to/commit-msg-template" # original commit --template

Where COMMENTED_INSTRUCTIONS are the lorem ipsum printed every time git commit is issued: # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit.

Of course, to maintain compatibility, these options would stay, but my suggestion is to have a way for commit.template to read from command output instead of a file.

-- Avid Seeker
Message 1 of 1 in “[Question] git-commit: --template from cmd output”
  1. Avid SeekerAug 7, 2024

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.