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
9 changes: 8 additions & 1 deletion bin/git-bulk
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,14 @@ function wsnameToCurrent () {
while read -r workspace; do
if [ -z "$workspace" ]; then continue; fi
parseWsName "$workspace"
if echo "$PWD" | grep -o -q "$rwsdir"; then wsname="$rwsname" && return; fi
# compatibility with environment variable inside .gitconfig:
# use combination of `eval` and `realpath` to:
# 1. dereference possible environment variable contained in $rwsdir
# 2. match workspaces even across different symlinks
rwsdir_rp=$(eval realpath $rwsdir 2>/dev/null)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rwsdir_rp=$(eval realpath $rwsdir 2>/dev/null)
rwsdir_rp=$(eval "$(realpath "$rwsdir")" 2>/dev/null)

Adding this makes the eval a bit easier to read for me.

pwd_rp=$(eval realpath $PWD 2>/dev/null)
# if pwd and workspace directory match, use this workspace name as current workspace
if [[ "$pwd_rp" =~ "$rwsdir_rp" ]]; then wsname="$rwsname" && return; fi
done <<< "$(listall)"
# when here then not in workspace dir
echo 1>&2 "error: you are not in a workspace directory. your registered workspaces are:" && \
Expand Down
Loading