grive2
grive2 copied to clipboard
.griveignore not working as expected
I've created an empty folder, and added the following into a .griveignore:
/*
/*/
!/database
and then initialized sync via grive -a
. However, it started adding all of the directories, not only database
. I thought .griveignore worked analogous to .gitignore -- what am I missing?
This is likely the same issue as #199
It should work if you specify just
*
!database
If your example works in git, but not in grive - it seems I didn't implement gitignore 100% identically, but the principle is still the same :)
I also have an issue with .griveignore not working as expected.
I cannot succeed in making something like
*
!database
database/.git
work. As soon as it sees !database, grive wants to sync everything inside database including .git that should be excluded.
I think that "positive" patterns get interpreted incorrectly. Saying !database
gets interpreted as include database
and anything inside it and the anything inside it part ends up taking precedence over the exclude pattern for database/.git
. However !database
should only include database
. Including anything inside database
should be !database/**
Infact, this is the case. The way in which patterns are turned into regular expressions is wrong. I have modified the grive source code to print the ignore regular expression that is generated and if you use a .griveignore
file like:
*
!database
database/.git
you get
^(?!database)([^/]*|database/\.git)$|^\.(grive|grive_state|trash)
which is obviously not correct, because the initial lookahead item (?!database)
prevents matching of anything that starts with database
and not just database
itself. This not only means that database/.git
gets included. Also anything like database23
would be incorrectly included.
How about adding a \Z
at the end of the lookahead pattern?
Ok, sorry, my master was not up to date. This is the reason for the closed pull request #237. However, I tried with the most recent master which is a bit better and still there is a problem, which is the reason for the new pull request #238.
Basically, if you use an include pattern for database
, then there is no reason for it to mean get database
and everything below it. For the latter you should say !database/**
. Otherwise, there is no way to include database
but then exclude some directory below database
.
My pull request seems to do the job, but some more testing is probably needed.