From 5d09b20421503dfeba68e000f6f6cc0c13ddd0d4 Mon Sep 17 00:00:00 2001 From: Jay Pratt Date: Thu, 9 May 2024 02:42:02 +1000 Subject: [PATCH] Add relative path fix to git-hub-browse --- modules/git/functions/git-hub-browse | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/git/functions/git-hub-browse b/modules/git/functions/git-hub-browse index 3451198c..2fce1da6 100644 --- a/modules/git/functions/git-hub-browse +++ b/modules/git/functions/git-hub-browse @@ -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}" @@ -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"