Skip to content

Instantly share code, notes, and snippets.

@marek-saji
Created August 29, 2013 15:38
Show Gist options
  • Save marek-saji/6379708 to your computer and use it in GitHub Desktop.
Save marek-saji/6379708 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Show from which one of integration branches does current branch grows from
# (c) Marek `saji` Augustynowicz
#
# INSTALL:
# git config alias.grows-from '!sh .git/bin/grows-from.sh'
#
# USAGE:
# git grows-from [<commit>]
DEVEL_BASE="$( command git merge-base ${1:-HEAD} devel )"
NEXT_BASE="$( command git merge-base ${1:-HEAD} next )"
MASTER_BASE="$( command git merge-base ${1:-HEAD} master )"
FIRST_BASE=$( command git log --pretty=format:%H --max-count=1 $MASTER_BASE $NEXT_BASE $DEVEL_BASE )
case $FIRST_BASE in
$DEVEL_BASE ) echo devel ;;
$NEXT_BASE ) echo next ;;
$MASTER_BASE ) echo master ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment