From a00d7dff708517ab7dc361f81d75fabdb5bff4cc Mon Sep 17 00:00:00 2001 From: nirenjan Date: Wed, 6 Feb 2013 21:59:02 -0800 Subject: [PATCH] Add git-branch-parent script from git-scripts repo --- scripts/git/git-branch-parent | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 scripts/git/git-branch-parent diff --git a/scripts/git/git-branch-parent b/scripts/git/git-branch-parent new file mode 100755 index 0000000..f83767f --- /dev/null +++ b/scripts/git/git-branch-parent @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Support script to find the commit from which the given branch was spawned. +# Takes one or two arguments, the first argument is mandatory and specifies +# the child branch while the second argument is optional and specifies the +# parent branch. If omitted, the parent branch defaults to 'master' + +CHILD=$1 +PARENT=$2 + +USAGE="Usage: $0 " + +if [ "$CHILD" == "" ] +then + echo $USAGE + exit +fi + +if [ "$PARENT" == "" ] +then + PARENT="master" +fi + +PCOMMIT=`diff -u <(git rev-list --first-parent $CHILD) \ + <(git rev-list --first-parent $PARENT) | sed -ne 's/^ //p' | head -1` + +git show --pretty="%H %an | %s" $PCOMMIT | head -1 +