| 1 | #!/bin/bash |
| 2 | set -e |
| 3 | |
| 4 | # stg-show - unlike "stg show", just "git show" with knowledge of stg refs |
| 5 | |
| 6 | # Ex: |
| 7 | # stg-show --color-words -- files |
| 8 | |
| 9 | # Copyright (c) 2007 Yann Dirson <ydirson@altern.org> |
| 10 | # Subject to the GNU GPL, version 2. |
| 11 | |
| 12 | command=(git show) |
| 13 | |
| 14 | # subsitute git id's for stg ones until -- |
| 15 | endofpatches=0 |
| 16 | while [ "$#" -gt 0 ]; do |
| 17 | case "$1" in |
| 18 | --) endofpatches=1; break ;; |
| 19 | -*) command+=("$1"); shift ;; |
| 20 | *) command+=( $(stg id "$1" 2>/dev/null || echo "$1") ); shift ;; |
| 21 | esac |
| 22 | done |
| 23 | |
| 24 | # append remaining args |
| 25 | command+=("$@") |
| 26 | |
| 27 | eval "${command[@]}" |