terse=
graphviz=
+sort=
## Parse options
terse=1;;
--graphviz)
graphviz=1;;
+ --sort)
+ sort=1;;
*)
- echo "Usage: tg [...] summary [-t | --graphviz]" >&2
+ echo "Usage: tg [...] summary [-t | --sort | --graphviz]" >&2
exit 1;;
esac
done
! [ -n "$terse" -a -n "$graphviz" ] ||
die "-t and --graphviz options are mutual exclusive"
+! [ -n "$sort" -a -n "$graphviz" ] ||
+ die "--sort and --graphviz options are mutual exclusive"
+
+! [ -n "$sort" -a -n "$terse" ] ||
+ die "-t and --sort options are mutual exclusive"
+
if [ -n "$graphviz" ]; then
cat <<EOT
# GraphViz output; pipe to:
EOT
fi
+if [ -n "$sort" ]; then
+ tsort_input=`mktemp`
+ exec 4>$tsort_input
+ exec 5<$tsort_input
+ rm $tsort_input
+fi
## List branches
echo "$name"
continue
fi
- if [ -n "$graphviz" ]; then
+ if [ -n "$graphviz" ] || [ -n "$sort" ]; then
git cat-file blob "$name:.topdeps" | while read dep; do
dep_is_tgish=true
ref_exists "refs/top-bases/$dep" ||
dep_is_tgish=false
if ! "$dep_is_tgish" || ! branch_annihilated $dep; then
- echo "\"$name\" -> \"$dep\";"
+ if [ -n "$graphviz" ]; then
+ echo "\"$name\" -> \"$dep\";"
+ else
+ echo "$name $dep" >&4
+ fi
fi
done
continue
echo '}'
fi
+if [ -n "$sort" ]; then
+ tsort <&5
+fi
+
+
# vim:noet