-
-
Notifications
You must be signed in to change notification settings - Fork 43
Add -vcs_ignore
flag via libgit2
#162
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
base: main
Are you sure you want to change the base?
Conversation
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.
Left some comments but there is a major design flaw with the current implementation. To work properly it needs to support multiple active repos simultaneously. If you want I can sketch out the ideas I had for that but it would be a major refactor.
git_libgit2_init(); | ||
return 0; |
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.
git_libgit2_init(); | |
return 0; | |
return git_libgit2_init(); |
@@ -80,6 +80,9 @@ for LIB; do | |||
oniguruma) | |||
LDLIB=-lonig | |||
;; | |||
libgit2) |
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.
Should be sorted alphabetically
@@ -67,4 +67,5 @@ ALL_PKGS := \ | |||
libcap \ | |||
libselinux \ | |||
liburing \ | |||
oniguruma | |||
oniguruma \ | |||
libgit2 |
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.
Should be sorted alphabetically
@@ -53,6 +53,7 @@ External dependencies are auto-detected by default, but you can build --with or | |||
--with-libselinux --without-libselinux | |||
--with-liburing --without-liburing | |||
--with-oniguruma --without-oniguruma | |||
--with-libgit2 --without-libgit2 |
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.
Should be sorted alphabetically
#ifdef BFS_WITH_LIBGIT2 | ||
#include <git2.h> | ||
#endif |
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.
bfs
coding style is to use #if
for these, not #ifdef
, so that #define BFS_WITH_LIBGIT2 false
works as expected
#ifdef BFS_WITH_LIBGIT2 | |
#include <git2.h> | |
#endif | |
#if BFS_WITH_LIBGIT2 | |
# include <git2.h> | |
#endif |
|
||
#ifdef BFS_WITH_LIBGIT2 | ||
/** The git repository for the current root. */ | ||
struct git_repository *git_repo; |
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.
This is the wrong place to store this. There is only one bfs_ctx
, but there can be multiple git repos active at a time. Consider
$ bfs src/repo1 src/repo2
or even just bfs src/repo
in the presence of git submodules.
@@ -1584,6 +1584,14 @@ static struct bfs_expr *parse_hidden(struct bfs_parser *parser, int arg1, int ar | |||
return parse_nullary_test(parser, eval_hidden); | |||
} | |||
|
|||
/** | |||
* Parse -ignore-vcs. |
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.
* Parse -ignore-vcs. | |
* Parse -ignore_vcs. |
@@ -3838,6 +3853,7 @@ struct bfs_ctx *bfs_parse_cmdline(int argc, char *argv[]) { | |||
} | |||
|
|||
ctx->argc = argc; | |||
ctx->ignore_vcs = false; |
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.
Don't think you need this, it's already set to false in bfs_ctx_new()
# Detect whether -ignore_vcs has any effect (i.e., built with libgit2) | ||
invoke_bfs . -name '*_file' -print >"$OUT.base" || fail | ||
invoke_bfs . -ignore_vcs -name '*_file' -print >"$OUT.ign" || fail | ||
if cmp -s "$OUT.base" "$OUT.ign"; then |
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.
You don't need to do this, just do
invoke_bfs -quit -ignore_vcs || skip
at the top
Thanks for the review.
Is your idea still using libgit2? Like checking for repo in each dir? The way I use this tool, I don't care about nested repos, but I understand it's not as expected. Also, is the whole |
libgit2 is fine. I was originally going to write my own The hard part is to find somewhere to store the
My idea is to unify these into something like
I want
Yes it's needed, all of bfs's dependencies are optional. |
Fixes #42
This is entirely vibe coded, I don't really know C that well. It seemed to work, I didn't benchmark it (not really relevant for my use cases), I doubt this:
is working. I'm posting this in hopes that someone takes it the rest of the way. Or, with guidance, I can do that too but I'm not gonna be guessing blindly here.