brauliobo/gitconfig

change-commits "eval: [[: not found"

Closed this issue · 7 comments

I am working on Debian unstable.
I copied just the line 'change-commits' from .gitconfig into my global .gitconfig.
$ git change-commits GIT_AUTHOR_EMAIL "old-email" "new-email"
Rewrite 7a7955a95de2df8cf021770fc230c9e35c2ca477 (1/20)/usr/lib/git-core/git-filter-branch: 1: eval: [[: not found
...
Rewrite 45df8d993b38ae7dedc69fb413a5bfdd4a9b4407 (20/20)/usr/lib/git-core/git-filter-branch: 1: eval: [[: not found

After a bit of testing, I found that the default shell seems to be dash (/bin/sh -> /bin/dash).
Changing this to /bin/bash ... and voila: change-commits works.

Could you amend change-config so that it also works with dash ?

@rockdaboot gonna check this soon

@rockdaboot can't really reproduce this as I've never used dash. (the strange thing is that /bin/sh already points to /bin/dash on my system). It seems git filter-branch uses the current shell which in my case is zsh.

I'm afraid I can't help as I have no experience with dash. If you can please submit a patch and I'll test and apply.

I changed the line to ... if [ \"$echo $VAR\" = \"$OLD\" ]; ... which worked ok to me. Maybe you can give it a try on your system. All I could do ... I am not a shell expert.
EDIT: there are 3 backslashes... my browser shows just two
BTW, you can test with dash 'SHELL=/bin/dash git change-commits ...'

There is still a small problem in your alias : when author name is like "firstname lastname", there is a problem regarding space char...
I found the solution with this line :
change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter "if [ \"$echo $VAR\" = \"$OLD\" ]; then export $VAR=\"$NEW\"; fi" $@; }; f"

Hope this can help !

Could you put the change-commit line into 'pre' tags ? That should avoid mangling of baskslashes.

thanks @jgastonraoul, just used your suggestion.
@rockdaboot sorry, how it would be with pre tags?

@brauliobo Maybe it is displayed correctly. My comment from 25th April displays the number of backslashes incorrectly. Something with markdow I guess. I tested it and multiple backslashes show correctly when putting the string into pre tags.