Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion modules/git/functions/git-hub-browse
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ if ! is-true "$(command git rev-parse --is-inside-work-tree 2> /dev/null)"; then
return 1
fi

root="$(command git rev-parse --show-toplevel)"

local remotes remote references reference file url

remote="${1:-origin}"
Expand Down Expand Up @@ -42,7 +44,8 @@ if [[ "$reference" == 'HEAD' ]]; then
reference="$(command git rev-parse HEAD 2> /dev/null)"
fi

file="$3"
file="${3:-$(pwd)}"
file="$(command realpath "$file" | sed "s|^$root||")"

if [[ -n "$url" ]]; then
url="$url/tree/$reference/$file"
Expand Down