A branch gmock was proposed as pull request 483 on GitHub, accepted, merged into master and deleted. It had two commits:
- bf05ec1 tests: replace existing gtest 1.5.0
- 5cbe0c5 gmock: use Google C++ Mocking
In GitHub, the reference pull/483/head is preserved and points to the last commit of the branch that no longer exists.
master + | 849afe + merged and deleted branch gmock |\ d5cb91 + \ | + bf05ec1 tests: replace existing gtest 1.5.0 (pull/483/head) 5301b2 + | | + 5cbe0c5 gmock: use Google C++ Mocking | / |/ 5a6549 + | . . .
To list the commits that were merged we need to find the commit in master that is immediately after the former branch started.
base=$(git rev-list --topo-order master ^pull/483/head | tail -1)
The base variable contains 5301b2 which is the first commit of master that is not reachable from pull/483/head, in topological order instead of the default chronological order.
$ git rev-list --oneline $base^..pull/483/head bf05ec1 tests: replace existing gtest 1.5.0 5cbe0c5 gmock: use Google C++ Mocking
Displays the commits of the former gmock branch. Note the ^ after $base that means the first parent of $base. If the graph is as shown above, it does not make a difference. But if it is as follows:
master + | 849afe + merged and deleted branch gmock |\ | \ | + bf05ec1 tests: replace existing gtest 1.5.0 (pull/483/head) | | | + 5cbe0c5 gmock: use Google C++ Mocking | / |/ 5a6549 + | . . .
Then $base would be 849afe and git rev-list –oneline $base..pull/483/head (without the ^) would display nothing because pull/483/head is reachable from $base. Since $base^ is the first parent (i.e. the left parent on the graph above), it is 5a6549 and we get the desired result.