#!/bin/bash
-err() { echo "error: $*" >&2; exit 1; }
+PROG=${0##*/}
+
+err() { echo "${PROG}: error: $*" >&2; exit 1; }
_cvs_url() {
[[ $# -gt 1 ]] && err "accepted args: <file>[:rev1[:rev2]]"
done
}
+git_root() {
+ git rev-parse --show-toplevel 2>/dev/null
+}
git_url() {
[[ $# -gt 1 ]] && err "accepted args: <rev>"
repo=$(echo "${remote}" | sed -e 's,.*/,,' -e 's,[.]git$,,')
url="https://gcc.gnu.org/git/?p=${repo}.git;a=commit;h="
;;
- rpc://*)
- url="${remote#rpc://}"
+ sso://*|rpc://*)
+ url="${remote#sso://}"
+ url="${url#rpc://}"
url="https://${url/\//.googlesource.com/}/+/"
;;
*.googlesource.com/*)
done
}
+piper_root() {
+ g4 info 2>/dev/null | sed -n "/^Client root: / { s|^[^:]*:\s*|| ; p }"
+}
+piper_url() {
+ : "${root:=$(piper_root)}"
+ echo "http://depot/${PWD#${root}/}"
+}
+
usage() {
exec cat <<-EOF
- Usage: $0 [options] [args]
+ Usage: ${PROG} [options] [args]
Options:
-# Number of commits to show (default: 3)
done
set -- "${args}"
+ local root
if [[ ${vcs} == "auto" ]] ; then
- if [[ -d CVS ]] ; then
+ # Order by which VCS actually matter nowadays.
+ if [[ -n ${root:=$(git_root)} ]] ; then
+ vcs="git"
+ elif [[ -d CVS ]] ; then
vcs="cvs"
elif svn info >&/dev/null ; then
vcs="svn"
- else
- vcs="git"
+ elif [[ -n ${root:=$(piper_root)} ]] ; then
+ vcs="piper"
fi
fi
case ${vcs} in
- cvs) cvs_url "$@";;
git) git_url "$@";;
+ cvs) cvs_url "$@";;
svn) svn_url "$@";;
+ piper) piper_url "$@";;
+ *) err "unknown VCS for ${PWD}";;
esac
}
main "$@"