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

interactive rebase "reword" runs pre-commit hook but ignores non-zero exit status

From
NKNeal Kreitzinger <neal@rsss.com>
Date
Sep 9, 2010, 00:26 UTC
Message-ID
<i699mo$8jd$1@dough.gmane.org>

I've isolated what seems to be a loophole in interactive rebase by rebasing a branch for the sole purpose of rewording some commits:

(I just finished performing a rebase for the sole purpose of squashing several commits into 2 commits) (Now I want to reword those 2 commits)

$ git --version = 1.7.1
$ git rebase -i --onto BranchA~2 BranchA~2 BranchA
(change "pick" to "reword" in rebase-stack editor)
reword Abbrsha1 some-commit-message
reword Bbbrsha1 some-other-commit-message
# Rebase Cbbrsha1..Dbbrsha1 onto Cbbrsha1
(save changes in editor)
".git/rebase-merge/git-rebase-todo" 15L, 580C written
(shows output from pre-commit hook and the corresponding non-zero exit)
Start of pre-commit hook...
checking for something I don't like...
ERROR: I found something I don't like!
Commit Aborted!
Start of pre-commit hook...
checking for something I don't like...
ERROR: I found something I don't like!
Commit Aborted!
Successfully rebased and updated refs/heads/BranchA.
$ _

In this case, the thing that caused the pre-commit to error-out was that the format of a report that it runs was changed. So in this case, I will rebase -i and "edit" the commits and git-add the new report format so the pre-commit doesn't complain. However, I originally tried to do the reword and squash in a single rebase and it gave the same errors, but performed the squashes. Is this the intended behavior? On the one hand, you shouldn't be changing content in a "reword", but on the other hand if you're going to run the pre-commit hook then shouldn't you abort the rebase if the pre-commit hook exits with non-zero status?

I admit that a workflow in which content changes on a reword may not be a valid scenario that you should care about in your rebase exception handling, but shouldn't you care that the pre-commit hook exited with non-zero status regardless of the reason why it exited with non-zero status? Just a question.

v/r, Neal

Message 1 of 1 in “interactive rebase "reword" runs pre-commit hook but ignores non-zero exit status”
  1. Neal KreitzingerSep 9, 2010

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.