"Squash all 'fixup!' commits above selected commit" needs git 2.22
Describe the bug
Using the "squash all 'fixup!' commits above selected commit" command fails with our minimum required git version, which is 2.20. It uses the --rebase-merges option, which was only added in 2.22.
It wouldn't be hard to omit the --rebase-merges option when git is older than 2.22; but then again, we might as well bump the minimum required version to 2.22, which isn't that much newer than 2.20. @jesseduffield Let me know which of these you prefer.
(Hopefully this would have been found by #2456)
Looking here 2.20 was 2018-12-09 and 2.22 was 2019-06-07, so 6 months difference, but 6 months is a big difference when we're only talking about a 4 year gap in the first place.
I think our approach to compatibility requires some more thought. I.e. it's a common thing with terminal git clients (niche market though it is) for people to want to use a git client on some old server where it's not convenient to upgrade git. I doubt people need to make use the squash-all-fixup-commits feature in that context, so I'm inclined to just say that specific feature is disabled when on an older git version, so that the bread and butter of lazygit (adding files, pulling/pushing, etc) is all still there.
For a given feature that requires a certain version of git we have three options (in order of most convenient for us and least convenient for users):
- bump the minimum git version required at startup
- disable the feature for those on an old git version
- implement the feature in different ways depending on the git version
In this case I'm thinking we go with option 2. What are your thoughts?
We can easily do 3. in this case, by simply omitting the --rebase-merges option when it is not available. The squash-all-fixup-commits feature would still work, except that it would drop merge commits if there are any; but that's probably a bit of an uncommon use case anyway.
Sweet, let's do that
I was mislead by the git release notes of 2.22, which said
* "git rebase --rebase-merges" replaces its old "--preserve-merges"
option; the latter is now marked as deprecated.
I read this as --rebase-merges being introduced in that version only. That's not true though, it existed since 2.18 already; so all is well, and I'm closing this.