Jani Nikula @jani@floss.social · activity timestamp last month Want to share URLs to commits or files at a certain commit in a git web?For git.kernel.org, here's my git-link script.$ git link v6.16-rc1$ git link HEAD^^ Makefile #git #kernel Read more Read less alt #!/bin/bash # $0: commit-ish [file] set -eu URL="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/" commit=${1:-HEAD} file=${2:-} if [[ "$(git describe $commit)" != "$commit" ]]; then commit=$(git rev-parse $commit) fi if [[ -n "$file" ]]; then # Just check that the file exists in commit git show "$commit:$file" >/dev/null URL+="tree/$file" else URL+="commit/" fi URL+="?id=$commit" echo "$URL" #!/bin/bash # $0: commit-ish [file] set -eu URL="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/" commit=${1:-HEAD} file=${2:-} if [[ "$(git describe $commit)" != "$commit" ]]; then commit=$(git rev-parse $commit) fi if [[ -n "$file" ]]; then # Just check that the file exists in commit git show "$commit:$file" >/dev/null URL+="tree/$file" else URL+="commit/" fi URL+="?id=$commit" echo "$URL" Reply Boost Like More actions Copy link Flag this post Block
alt #!/bin/bash # $0: commit-ish [file] set -eu URL="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/" commit=${1:-HEAD} file=${2:-} if [[ "$(git describe $commit)" != "$commit" ]]; then commit=$(git rev-parse $commit) fi if [[ -n "$file" ]]; then # Just check that the file exists in commit git show "$commit:$file" >/dev/null URL+="tree/$file" else URL+="commit/" fi URL+="?id=$commit" echo "$URL" #!/bin/bash # $0: commit-ish [file] set -eu URL="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/" commit=${1:-HEAD} file=${2:-} if [[ "$(git describe $commit)" != "$commit" ]]; then commit=$(git rev-parse $commit) fi if [[ -n "$file" ]]; then # Just check that the file exists in commit git show "$commit:$file" >/dev/null URL+="tree/$file" else URL+="commit/" fi URL+="?id=$commit" echo "$URL"