X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=tg.sh;h=d520a230096ebdfbe442af71f333c59c7a9a1c32;hb=2e5b885d1d0178edefb8762ce9f44105bf3a9d0f;hp=03a392b7ad2703e6975297c85c7290fdcf5433e6;hpb=db4bc100e4afd0e405443f5bab4a242b989a6a64;p=topgit.git diff --git a/tg.sh b/tg.sh index 03a392b..d520a23 100644 --- a/tg.sh +++ b/tg.sh @@ -45,11 +45,11 @@ setup_hook() # setup_ours (no arguments) setup_ours() { - if [ ! -s "$git_dir/info/gitattributes" ] || ! grep -q topmsg "$git_dir/info/gitattributes"; then + if [ ! -s "$git_dir/info/attributes" ] || ! grep -q topmsg "$git_dir/info/attributes"; then { echo -e ".topmsg\tmerge=ours" echo -e ".topdeps\tmerge=ours" - } >>"$git_dir/info/gitattributes" + } >>"$git_dir/info/attributes" fi if ! git config merge.ours.driver >/dev/null; then git config merge.ours.name '"always keep ours" merge driver' @@ -152,9 +152,22 @@ switch_to_base() do_help() { if [ -z "$1" ] ; then + ## Build available commands list for help output + + cmds= + sep= + for cmd in "@cmddir@"/tg-*; do + ! [ -r "$cmd" ] && continue + # strip directory part and "tg-" prefix + cmd="$(basename "$cmd")" + cmd="${cmd#tg-}" + cmds="$cmds$sep$cmd" + sep="|" + done + echo "TopGit v0.1 - A different patch queue manager" - echo "Usage: tg (create|delete|info|patch|summary|update|help) ..." - elif [ -f "@sharedir@/tg-$1.txt" ] ; then + echo "Usage: tg ($cmds|help) ..." + elif [ -r "@sharedir@/tg-$1.txt" ] ; then cat "@sharedir@/tg-$1.txt" else echo "`basename $0`: no help for $1" 1>&2 @@ -171,6 +184,8 @@ root_dir="$(git rev-parse --show-cdup)"; root_dir="${root_dir:-.}" setup_ours setup_hook "pre-commit" +[ -d "@cmddir@" ] || + die "No command directory: '@cmddir@'" ## Dispatch @@ -183,15 +198,16 @@ cmd="$1" shift case "$cmd" in -help) +help|--help|-h) do_help "$1" exit 1;; -create|delete|info|patch|summary|update) - . "@cmddir@"/tg-$cmd;; --hooks-path) # Internal command echo "@hooksdir@";; *) - echo "Unknown subcommand: $cmd" >&2 - exit 1;; + [ -r "@cmddir@"/tg-$cmd ] || { + echo "Unknown subcommand: $cmd" >&2 + exit 1 + } + . "@cmddir@"/tg-$cmd;; esac