-
Notifications
You must be signed in to change notification settings - Fork 423
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
fixing bad regex on file tracking in two VCS (git and hg) #509
Conversation
This appears to undo a previous commit? Firstly, Second, what problem is this solving? Your explanation seems confusing, the flag should show as soon as there is something that is not tracked. |
Sorry for not having been clearer, I'll show you what I get on my machine (ubuntu 16.10): Both, with -E and without it works for checking if untracked file are present: $ touch testfile
$ git status --porcelain
?? testfile
$ if LC_ALL=C \git status --porcelain 2>/dev/null | \grep -Eq '^\?\?'; then echo untracked; fi>
untracked
$ if LC_ALL=C \git status --porcelain 2>/dev/null | \grep -q '^\?\?'; then echo untracked; fi
untracked But if I modify a file and have no untracked file: $ echo >> README.md
$ git status --porcelain
M README.md
$ if LC_ALL=C \git status --porcelain 2>/dev/null | \grep -q '^\?\?'; then echo untracked; fi
untracked I still get the untracked mark which is false. I'll look into a better solution though, since -E is not portable. |
c539804
to
9e9d51c
Compare
replacing it by Basic Regular Expression, Extended ones are not supported on non GNU grep
9e9d51c
to
feafb03
Compare
From the grep man page (Linux Mint 18.1):
I assume that without -E we are using BRE so we should use grep -q '^??'. Escaping the "?" does exactly the opposite of what we want.
|
@j-degreef yeah, sorry about not writing anything about it but I came to the exact same conclusion yesterday; I updated my PR and that's what it now does. Afaik (and could test) it's now working fine and is ready to merge |
Interestingly, I was unable to reproduce the original problem on machines without GNU grep. It is only on machines with GNU grep that have this issue. So much for grep portability... Anyway, this patch now doesn't break anything on my machines, and it does fix the problem on the machines that had the problem, so this gets my approval. |
@Rycieos |
I'm not sure what version of grep my machine has (SunOS 11.3, no man pages, grep won't return a version), but I get this:
As I said above, I have tested this patch on my systems with this lesser grep, and it works as intended. |
Ok, my edit crossed your reply ;) |
@Rycieos Do you have |
Yes I do. For reference:
Not sure how it could be used though in place of |
We could use
|
Well, on Linux egrep is actually a wrapper around grep -E
|
I don't think this is too pressing of a problem, since almost* anything that could be written in extended grep could also be written in normal grep. * The The only remaining usage of |
untracked flag is showing as soon as modification has been made (as soon as git status --porcelain show something)
This fix should solve this for both git and mercurial