-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat(git-bulk): add new option to no follow symlinks #1194
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.
Thanks! I think the feature is good, had a few comments on the implementation.
bin/git-bulk
Outdated
find_flags+=(-L) | ||
fi | ||
# find all git repositories under the workspace on which we want to operate | ||
allGitFolders=( $(eval find $find_flags . -name ".git") ) |
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.
allGitFolders=( $(eval find $find_flags . -name ".git") ) | |
readarray allGitFolders <(find "${find_flags[@]}" . -name ".git") |
Possible to do this instead? This won't break on filepaths that include a newline and removes the (unecessary?) eval
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.
Thank you for the improvement. It is fixed with my new commit 5a7c33d
.
A few comments:
- Compared to your proposition, I added a missing
<
(the first one is thestdin
redirection, the second one is the process substitution). I tested this implementation against paths with spaces, which is working. Note that I assume you meant "filepaths that include a space" and not "filepaths that include a newline", right? - I removed the unnecessary
eval
, which was introduced here since the very first commit57c0eb7
ofgit-bulk
, for a non obvious reason to me.
if [[ "$no_follow_symlinks" == true ]]; then | ||
find_flags+=(-P) | ||
else | ||
find_flags+=(-L) |
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 codepath changes the default. According to the manpage:
Since it is the default, the -P option should be considered to be in effect unless either -H or -L is specified.
I don't think changing the default behavior is a good idea. Maybe the flag should be --follow-symlinks
to make this clearer?
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.
Indeed, this codepath change the default of find
... but not the default of the git-bulk
behavior, where the -L
flag was added in commit 3730339
in 2018.
I did this in this way to not change the default git-bulk
behavior. But I agree with you that it may have been better to not change find
default in the first place.
So, from this, what do you prefer? On my side, I don't have any strong opinion about this. :)
1. Use `readarray` such that we can handle paths with spaces 2. Remove the unnecessary `eval`
Add a new option
--no-follow-symlinks
forgit-bulk
to not traverse symlinks under the workspace directories when searching for git repositories. This PR does not change the default behavior, it only add the option for the user.