~kaction/forge-link

96b7c620d5ad2c2dff79fc4f47e35ddc673917ab — Dmitry Bogatov 10 months ago 34e1f35 master
Lift constraint on current directory

Now "forge-link" works even if current directory is outside of git repository
of target file.
1 files changed, 8 insertions(+), 1 deletions(-)

M forge-link
M forge-link => forge-link +8 -1
@@ 24,8 24,15 @@ if [ ! -e "${file}" ]; then
	exit 1
fi

gitroot=$(git rev-parse --show-toplevel)

abspath=$(readlink -e "${file}")

# Make sure things work even if current directory is not in the same git
# repository as target file. Makes integration code simpler.
containing_dir=$(dirname "${file}")
cd "${containing_dir}"

gitroot=$(git rev-parse --show-toplevel)
relpath=${abspath##${gitroot}}
sha1=$(git rev-parse HEAD)