simulate --ff-only in git 1.5.6.5
Debian stable has git 1.5.6.5 which is missing the --ff-only options in git pull/git me开发者_高级运维rge. Is there a way to simulate this behavior with a series of alternative git commands?
You can test if one of the commits is a descendant of the other. If one is, then that's the definition of a fast-forward merge.
If commit A is a descendant of commit B (as in, B is some Nth parent of A), then:
$ git checkout B
$ git merge A #<--- this is a fast-forward merge
But testing if commits are descendants is not the easiest. That answer lies here: How can I tell if one commit is a descendant of another commit?
Of course, I can just run merge with --no-commit and then see if anything has changed in the index. If it's a fast-forward or empty merge, then git diff --cached should be empty, given that it was empty before the merge.
精彩评论