"fatal: bad object" when calling `git diff-tree` in bash script

I have a freestyle step that runs a bash script which errors out on the line below with “fatal: bad object”

files=$(git diff-tree --no-commit-id --name-only -r "$GITHASH" "$GITHASH"^1)

I can run the same bash script locally just fine as long as I export GITHASH=blahblah before it. It is being run as a bash script from the first line #!/bin/bash.

Any ideas why it’s giving this error only in a Codefresh freestyle step?


The default shell in freestyle steps is sh. To change it to bash you need to add a ‘shell’ property in your yaml definition as seen here Freestyle · Codefresh | Docs

If that doesn’t work I suggest you simply put the contents into a file such as ‘my-script.sh’ and execute that from the freestyle step instead of the snippet that you have now.

If this still doesn’t work, I suggest you open a ticket with us so that our support team can investigate.