Skip to content

Loading…

Avoid infinite loop in __gs_relative_path when $(PWD) contains a symlink... #42

Merged
merged 1 commit into from

2 participants

@alhad

[Resending pull request - I had closed my previous request because I thought "readlink -f" would fall over when given a non-symlinked path, but it handles it just fine]

When $(PWD) has a symlinked directory, in function __gs_relative_path, the comparison becomes between an absolute path and symlinked directory, resulting in the while loop never terminating, and "gs" for example getting stuck forever. The patch first resolves $(PWD) to an absolute path.

For example I have a ~/work directory that maps to the base of all my sources, and I typically do |cd ~/work| to go there.

@ndbroadbent
Owner

OK, this looks fine to me. I might merge it, and then re-indent your new lines :)

@ndbroadbent ndbroadbent merged commit 94b2b9b into ndbroadbent:master
@ndbroadbent
Owner

ah, you were using tabs, no problem :)

Thanks for helping out with this! But I see that you were working on the bash fallback - there is a Ruby version that is a lot faster. All you need to do is install Ruby.

@alhad

Yeah, sorry about the tabs :)

I did notice that it was not picking up Ruby, must be something wrong with my Ruby install. Need to look into it.

Also, thanks in general for scm_breeze! I almost can't imagine using git without it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/git/fallback/status_shortcuts_shell.sh
View
3 lib/git/fallback/status_shortcuts_shell.sh
@@ -128,7 +128,8 @@ _gs_output_file_group() {
relative="${stat_file[$i]}"
else
dest="$project_root/${stat_file[$i]}"
- relative="$(_gs_relative_path "$PWD" "$dest" )"
+ local pwd=$(readlink -f "$PWD")
+ relative="$(_gs_relative_path "$pwd" "$dest" )"
fi
if [[ $f -gt 10 && $e -lt 10 ]]; then local pad=" "; else local pad=""; fi # (padding)
Something went wrong with that request. Please try again.