#!/bin/sh USAGE='[commit]' LONG_USAGE='git show-url prints a gitweb url for a given commit (or HEAD if no commit is given). You must first configure the gitweb baseurl for the repository. You can do so using git config, e.g.: $ git config gitweb.baseurl "http://yum.baseurl.org/gitweb?p=yum.git" or by editing the git config file directly: [gitweb] baseurl = http://yum.baseurl.org/gitweb?p=yum.git ' SUBDIRECTORY_OK=Yes OPTIONS_SPEC= . git-sh-setup [ $# -gt 1 ] && usage baseurl="$(git config --get gitweb.baseurl)" [ -n "$baseurl" ] || die "Set gitweb.baseurl in git config" commit=$1 [ -z "$commit" ] && commit=HEAD if ! [[ $commit =~ ^[0-9a-f]{4,40}$ ]] && [ "$commit" != "HEAD" ]; then commit=$(git rev-parse --quiet --short --verify "$commit") fi [ -n "$commit" ] || die "Unable to find a suitable commit" echo "$baseurl;a=commit;h=$commit"