From b35b309ce57062d301a2036a5fd3c149ad2d62f4 Mon Sep 17 00:00:00 2001 From: sandr01d <88739791+sandr01d@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:42:37 +0200 Subject: [PATCH] Fix: Opening files from diff line when not in project root (#393) When trying to open a file from gd in $EDITOR (alt + e) the wrong file was being opened when the command wasn't executed from the repository's root directory. --- bin/git-forgit | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/git-forgit b/bin/git-forgit index 53142683..7b953722 100755 --- a/bin/git-forgit +++ b/bin/git-forgit @@ -242,9 +242,11 @@ _forgit_diff_view() { } _forgit_edit_diffed_file() { - local input_line=$1 + local input_line rootdir + input_line=$1 + rootdir=$(git rev-parse --show-toplevel) filename=$(echo "$input_line" | _forgit_get_single_file_from_diff_line) - $EDITOR "$filename" >/dev/tty /dev/tty