Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
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

#!/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"
#!/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"
  • Copy link
  • Flag this post
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.2.1 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct