libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.58k stars 382 forks source link

Please add flags argument to `Index.add_all` function. #1208

Open sergey-komissarov opened 1 year ago

sergey-komissarov commented 1 year ago

Hello,

Sometimes I have to add directories matched with .gitignore to repository. libgit2 function git_index_add_all have force flag for this. But pygit2 does not have argument for flags. Is it possible to add such argument in future releases?

OpenBagTwo commented 1 year ago

Seconding this, as the design decision to exclude flags feels like it must have been intentional, and I'd love to understand the rationale at the very least.

@sergey-komissarov as a workaround, it appears that index.add(explicit_file_path) ignores .gitignore-matches, so you can always manually iterate through all the files in those directories.

That would work for me as well except I potentially want to force-add patterns, and I'm still suffering from the trauma of figuring out the OS-specific nuances of fnmatch to want to reverse-engineer a glob-based solution of my own.