All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
5 # A convenient way to display the gitweb URL of a commit-ish, as well as the
6 # base URL and tree. Also for each argument, the tree or blob URL is printed.
8 # Copyright © 2010 martin f. krafft <madduck@madduck.net>
9 # Released under the terms of the Artistic Licence 2.0
10 # Contributions from Yaroslav O. Halchenko <debian@onerussian.com>
12 # Source repository: http://git.madduck.net/v/etc/zsh.git
15 local branch remote remote_name
16 branch=$(git symbolic-ref -q HEAD); branch="${branch#refs/heads/}"
17 # Obtain remote which current branch tracks, origin if not known
18 remote_name=$(git config branch.$branch.remote || echo origin)
19 remote=$(git config --get remote.$remote_name.url)
21 local part gitweb_base style commitkw
23 commitkw=commitdiff # keyword for commit -- differ for github
24 argssep=: # separator for arguments of the query
26 madduck:pub/*|ssh://git.madduck.net/madduck/pub/*)
27 gitweb_base=http://git.madduck.net/v
28 part="${remote#madduck:pub/}"
29 part="${part#ssh://git.madduck.net/madduck/pub/}"
30 part="${part%.git}.git"
32 debian:*|*://git.debian.org/git/*|*://alioth.debian.org/git/*|*@git.debian.org/git/*)
33 gitweb_base=http://git.debian.org
34 part="${remote#debian:}"
35 part="${part#*://git.debian.org/git/}"
36 part="${part#*://alioth.debian.org/git/}"
37 part="${part#*@git.debian.org/git/}"
38 part="${part%.git}.git"
41 github:*|*://github.com/*|*@github.com[/:]*)
42 gitweb_base=http://github.com
43 part="${remote#github:}"
44 part="${part#*://github.com/}"
45 part="${part#*@github.com[:/]}"
52 echo >&2 "E: I do not know how to translate $remote into a gitweb URL."
58 hash=$(git rev-parse HEAD)
62 echo "$gitweb_base/$part"
63 echo "$gitweb_base/$part/$commitkw/$hash"
64 echo "$gitweb_base/$part/tree/HEAD"
66 [ -f "$i" ] && echo "$gitweb_base/$part/blob/HEAD${argssep}/$i"
67 [ -d "$i" ] && echo "$gitweb_base/$part/tree/HEAD${argssep}/$i"
71 echo "$gitweb_base/?p=$part"
72 echo "$gitweb_base/?p=$part;a=commitdiff;h=$hash"
73 echo "$gitweb_base/?p=$part;a=tree;h=HEAD"
75 [ -f "$i" ] && echo "$gitweb_base/?p=$part;a=blob;hb=HEAD;f=$i"
76 [ -d "$i" ] && echo "$gitweb_base/?p=$part;a=tree;hb=HEAD;f=$i"