From 76ee5bf80365ace5154b06042d39ee27a4b0ab10 Mon Sep 17 00:00:00 2001 From: sandroid Date: Fri, 26 Apr 2024 23:38:30 +0200 Subject: [PATCH] Fix: Opening files from diff line when not in project root 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 5314268..7b95372 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