#!/bin/bash
#
# (Try to) Show the dependency list for applying a given commit on the current
# branch.
#

if [ $# -ne 1 ] && [ $# -ne 2 ]; then
	echo "Usage: stable deps <commit sha1>"
	exit 1
fi

STABLE_MAJ_VER=$(grep VERSION Makefile | head -n1 | awk {'print $3'})
STABLE_MIN_VER=$(grep PATCHLEVEL Makefile | head -n1 | awk {'print $3'})
cmt=$(git rev-parse $1)

for i in $(cat ~/deps/v$STABLE_MAJ_VER.$STABLE_MIN_VER/$cmt | awk {'print $1'}); do
	stable commit-in-tree $i
	if [ $? -eq 1 ]; then
		continue
	fi
	git ol $i
done
