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

feat(git-bulk): add new option to no follow symlinks #1194

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

pierreay
Copy link
Contributor

Add a new option --no-follow-symlinks for git-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.

@pierreay pierreay marked this pull request as ready for review February 17, 2025 06:36
Copy link
Collaborator

@hyperupcall hyperupcall left a 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") )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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 the stdin 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 commit 57c0eb7 of git-bulk, for a non obvious reason to me.

if [[ "$no_follow_symlinks" == true ]]; then
find_flags+=(-P)
else
find_flags+=(-L)
Copy link
Collaborator

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?

Copy link
Contributor Author

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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants