Skip to content
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

Add support for .gitignore files #450

Open
thijsvandien opened this issue Dec 14, 2020 · 2 comments
Open

Add support for .gitignore files #450

thijsvandien opened this issue Dec 14, 2020 · 2 comments

Comments

@thijsvandien
Copy link

thijsvandien commented Dec 14, 2020

I'm using Tarsnap to backup my projects, and it would be really nice if it would respect .gitignore files. That way I won't need to constantly add excludes to the same extent, or waste space. While I suppose I could write a bunch of shell code to find all my .gitignore files, prepend their paths to their respective patterns and then hand all those to Tarsnap, or clean all those projects before doing the backup, perhaps git is now common enough to justify this special treatment to make things user friendly. Ripgrep, for example, already works like that.

@gperciva
Copy link
Member

Interesting idea! I'll look into what exactly ripgrep does. The most difficult part of .gitignore is that if you've already added a file to git and then ignored it in .gitignore, the relevant part of .gitignore is ignored. (i.e. git still tracks changes in that file.) So if we think that we should ignore a certain file based on a regex, we'd still need to check whether git is actually ignoring that file or not.

BSD tar (libarchive) does not have any such option, but GNU tar has --exclude-vcs-ignores. I'm not certain how they handle the "file would be ignored, but it's actually still tracked by git" case.

That said, I think it's very unlikely that we would add support for this to our binary unless it's already in libarchive. It's much more likely that we would share a shell script which does what you describe.

@Villemoes
Copy link
Contributor

I'd also like to see something like this. I think it is more likely that libarchive/bsdtar could grow support for --exclude-ignore=FILE / --exclude-ignore-recursive=FILE, as the semantics of those are better defined and likely easier to implement - it just so happens that those would be sufficient for my use case. FTR,

       --exclude-ignore=FILE
              Before  dumping  a  directory,  see if it contains FILE.  If so,
              read exclusion patterns from this  file.   The  patterns  affect
              only the directory itself.

       --exclude-ignore-recursive=FILE
              Same  as --exclude-ignore, except that patterns from FILE affect
              both the directory and all its subdirectories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants