aboutsummaryrefslogtreecommitdiffstats
path: root/git-oldest-ancestor
blob: 57db44dea118153a7b129c518e871354f4ca1faf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash

# git-oldest-ancestor
#
# Finds the branch point of the current HEAD.
#
# From lindes (https://stackoverflow.com/users/313756/lindes) on Stack Overflow
# https://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git/4991675#4991675
# https://stackoverflow.com/questions/1527234/finding-a-branch-point-with-git/4991675#comment42897586_4991675

diff \
		--old-line-format='' \
		--new-line-format='' \
		<(git rev-list --first-parent "${1:-master}") \
		<(git rev-list --first-parent "${2:-HEAD}") |
	head -1