spr icon indicating copy to clipboard operation
spr copied to clipboard

Amend panics when `true` is not available at `/usr/bin/true`

Open abatilo opened this issue 4 years ago • 4 comments

git error: /usr/lib/git-core/git-rebase: 1: eval: /usr/bin/true: not found
Could not execute editor
panic: exit status 1

goroutine 1 [running]:
github.com/ejoffe/spr/spr.check(...)
        /Users/eitan/Code/spr/spr/spr.go:426
github.com/ejoffe/spr/spr.(*stackediff).mustgit(...)
        /Users/eitan/Code/spr/spr/spr.go:421
github.com/ejoffe/spr/spr.(*stackediff).AmendCommit(0xc0000d3f28, 0x5efa78, 0xc000116000)
        /Users/eitan/Code/spr/spr/spr.go:73 +0x6b0
main.main()
        /Users/eitan/Code/spr/cmd/amend/main.go:57 +0x32e

It looks like the path to true is hardcoded for /usr/bin/true as per this line: https://github.com/ejoffe/spr/blob/a9bb60ff8c7ac2fbe03a58d041c1db309fb9be6b/git/realgit/realcmd.go#L38

I have /bin/true which I just copied to /usr/bin/true which fixed this problem but maybe spr should just look for something in the PATH?

abatilo avatar Nov 11 '21 17:11 abatilo

I think we can safely replace "/user/bin/true" with just true here. It's probably a good idea to add a check that "true" exists and if not throw a meaningful error.

ejoffe avatar Nov 11 '21 18:11 ejoffe

The point of this is to basically just auto accept whatever text comes into the $EDITOR that git pulls up, is that right? I wonder if there's a way to basically set an auto accept without having to open an editor?

abatilo avatar Nov 15 '21 16:11 abatilo

Yes, that's correct, and to give some more color. This handles a special init case where there are some commits in the branch already and git spr is run for the very first time. When spr runs the first time, it installs the commit-msg hook which appends a commit-id to each commit for tracking purposes. If spr runs and detects that there are some commits without a commit-id it uses this mechanism of auto accept rebase to rewrite the commits in order for the hook to append the commit-id to them. There might be a better way to achieve this.

ejoffe avatar Nov 15 '21 18:11 ejoffe

If spr runs and detects that there are some commits without a commit-id it uses this mechanism of auto accept rebase to rewrite the commits in order for the hook to append the commit-id to them. There might be a better way to achieve this.

I've seen other similar projects do this by simply having a foo install-hook command which needs to run before creating the commits.

leoluk avatar Dec 09 '21 14:12 leoluk

closing as this hasn't occured in a while.

ejoffe avatar Mar 07 '23 00:03 ejoffe