J
J
J. Snow2017-02-22 11:50:04
git
J. Snow, 2017-02-22 11:50:04

"env filter failed" when doing git filter-branch. Where is the mistake?

I'm trying to edit the meta information of a commit with the command:

git filter-branch -f --env-filter \
'[ $GIT_COMMIT = 836dea22e7ee29381569b429d3e1f3b9c62751a6 ] && echo TEST'

echo TEST is , of course, only for testing purposes.
When executed, it gives an error:
Rewrite a345a0c5bc7aee029c7feaf2fa9ab8f621a6964f (1/10)
(0 seconds passed, remaining 0 predicted)
env filter failed:
[ $GIT_COMMIT = 836dea22e7ee29381569b429d3e1f3b9c62751a6 ] && echo TEST

The terminal is standard git for Windows (mintty 2.7.3)
I tried different syntax, all to no avail:
[ $GIT_COMMIT = 836dea22e7ee29381569b429d3e1f3b9c62751a6 ]
[ "$GIT_COMMIT" = "836dea22e7ee29381569b429d3e1f3b9c62751a6" ]

[ $GIT_COMMIT -eq 836dea22e7ee29381569b429d3e1f3b9c62751a6 ]

SOLVED
The command being executed is required to return a successful execution code.
That is, you need something like this:
git filter-branch -f --env-filter '[ $GIT_COMMIT = <hash> ] && echo TEST || true'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2017-02-22
@j-snow

Trying to edit the commit meta info

one??
git rebase -i commitHash^ and so on. select edit and that's it.
I have strong suspicions that the output of env-filter will not go to your console, but to the git process in stdin. and he is not happy with your test, for example.
to be honest, I have never done such a perversion, the interactive rebase was enough for my eyes.
out found what . there are completely different letters. the $GIT_COMMIT variable is not used there. Are you sure she even exists?
// killer, as usual, a gardener.
git-filter-branch is a shell script, env-filter is simply evalized and the exit code of this eval is checked, which is equal to the exit code of the last command in it. if there is false, env-filter is considered to have failed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question