5 # TODO this logic should probably rather be in rev-parse itself
7 # whenever an expression foo@@bar is used as an argument
8 # it checks whether foo is a valid reference, and if not, bar is used instead
14 # have to detect some rev-parse syntax
18 first=`processarg "$first"`
19 rest=`processarg "$rest"`
25 first=`processarg "$first"`
31 first=`processarg "$first"`
37 first=`processarg "$first"`
43 first=`processarg "$first"`
48 first=`processarg "$first"`
51 # handle foo@@bar so that if foo exists, foo stays, otherwise bar
53 first=${1%%$SEPARATOR*}
55 if git rev-parse "$first" >/dev/null 2>&1; then
61 # other args stay as is
76 set -- "$@" "`processarg "$X"`"
78 echo >&2 "In `pwd`: $*"
85 # recurse through all sub-repos
87 # TODO is there a better way to identify all sub-repos?
88 find . -type d -name \*.git -prune | while IFS= read -r GITDIR; do
89 # TODO I would LIKE to do this, but then some commands (like pull) fail
90 #export GIT_DIR="$GITDIR"
91 #export GIT_WORK_TREE="${GITDIR%/.git}"
92 # so I will have to chdir instead
94 ( cd "$GITDIR/.." && processargs git "$@" <&3 3<&- ) # use restored stdin
95 if [ "$?" -gt "$status" ]; then