-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix path related bugs. #58
Conversation
Cool! I see this. I will get a commit in as soon as I can. I am on vacation so it may be a few days :) |
@cjappl No rush. Take your time :) |
BREAKING CHANGE: 🧨 Paths listed by forgit::diff will use repo's root as start point.
@@ -63,7 +64,7 @@ forgit::add() { | |||
" | |||
files=$(git -c color.status=always -c status.relativePaths=true status --short | | |||
grep -F -e "$changed" -e "$unmerged" -e "$untracked" | | |||
awk '{printf "[%10s] ", $1; $1=""; print $0}' | | |||
sed 's/^\(..[^[:space:]]*\)[[:space:]]\+\(.*\)$/[\1] \2/' | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @wfxr, working on this now, but want to be 100% sure I'm understanding what this is before I put it in!
Can you explain what this sed command, and the sed command up top do? I'm not super well versed on sed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here regular expressions are used for capturing and replacing.
If you remove the escape character it will look a bit clearer:
sed 's/^(..[^[:space:]]*)[[:space:]]+(.*)$/[\1] \2/'
.
What this line does is to capture the status indicator at the beginning of the line, surround it with square brackets, then append the full path. Completely explaining sed's regex rules is not easy. But you can test it to see how it works:
# go to `forgit`'s local repo
touch 'a b c'
echo 'hello world!' >> README.md
# buggy
git status --short | awk '{printf "[%10s] ", $1; $1=""; print $0}'
# fixed
git status --short | sed 's/^\(..[^[:space:]]*\)[[:space:]]\+\(.*\)$/[\1] \2/'
Description
Fix some path related bugs. Add status indicator to
forgit::diff
command BTW.Type of change
Please delete options that are not relevant.
forgit::diff
command BTW.Shells this fix should effect:
Shells this fix has been tested in:
Test Configuration:
Checklist:
Related issue(s):
#39 : This pr will remove the dependency on
realpath
.Please help sync the fish version. @cjappl