Skip to contentSkip to conversation

filter-branch documentation: non-zero exit status in command abort the filter

PATCH In review Caio Marcelo de Oliveira Filho 2 participants 2 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 filter-branch documentation: non-zero exit status in command abort the filter

Since commit 8c1ce0f46b85d40f215084eed7313896300082df filter-branch fails when a <command> has a non-zero exit status. This commit makes it clear in the documentation and also fixes the parent-filter example, that was incorrectly returning non-zero when the commit being tested wasn't the one to be rewritten.

---
 Documentation/git-filter-branch.txt |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
Documentation/git-filter-branch.txt +6 -4
index e22dfa5..9cb01ca 100644
@@ -56,7 +56,9 @@ notable exception of the commit filter, for technical reasons).
 Prior to that, the $GIT_COMMIT environment variable will be set to contain
 the id of the commit being rewritten.  Also, GIT_AUTHOR_NAME,
 GIT_AUTHOR_EMAIL, GIT_AUTHOR_DATE, GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL,
-and GIT_COMMITTER_DATE are set according to the current commit.
+and GIT_COMMITTER_DATE are set according to the current commit. If any
+evaluation of <command> returns a non-zero exit status, the whole operation
+will be aborted.
 
 A 'map' function is available that takes an "original sha1 id" argument
 and outputs a "rewritten sha1 id" if the commit has been already
@@ -195,10 +197,10 @@ the initial commit - add graftcommit as a parent).  Note that this assumes
 history with a single root (that is, no merge without common ancestors
 happened).  If this is not the case, use:
 
---------------------------------------------------------------------------
+----------------------------------------------------------------------------
 git filter-branch --parent-filter \
-	'cat; test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>"' HEAD
---------------------------------------------------------------------------
+	'test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>" || cat' HEAD
+----------------------------------------------------------------------------
 
 or even simpler:
 
Signature · 1 line
1.5.4.3.221.g350ae
#1 lore raw

Hi,

Quoted 5 lines · Caio Marcelo de Oliveira Filho

Since commit 8c1ce0f46b85d40f215084eed7313896300082df filter-branch fails when a <command> has a non-zero exit status. This commit makes it clear in the documentation and also fixes the parent-filter example, that was incorrectly returning non-zero when the commit being tested wasn't the one to be rewritten.

I thought that we had that already in the man page, but you're right: we did not.

Documentation/git-filter-branch.txt the initial commit - add graftcommit as a parent). Note that this assumes · line 203

Quoted 7 lines

---------------------------------------------------------------------------
+----------------------------------------------------------------------------
git filter-branch --parent-filter \

Documentation/git-filter-branch.txt +2 -2
-	'cat; test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>"' HEAD
---------------------------------------------------------------------------
+	'test $GIT_COMMIT = <commit-id> && echo "-p <graft-id>" || cat' HEAD
+----------------------------------------------------------------------------

Yes, makes sense.

Ciao,
Dscho