Skip to content

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.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume you meant "filepaths that include a space" and not "filepaths that include a newline", right?

Yeah that's what I meant haha

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. :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oops! Yeah you're right, my mistake. I agree we don't want to change the default git-bulk behavior

@pierreay pierreay force-pushed the feat/git-bulk-no-follow-symlinks branch from 5a7c33d to f646ff6 Compare February 20, 2025 16:14
@pierreay
Copy link
Contributor Author

FYI, I rebased on master to get rid of conflicts.

@spacewander
Copy link
Collaborator

@hyperupcall
Would you take a look at this PR again? Thanks!

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! With the new changes everything looks great

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.

Oops! Yeah you're right, my mistake. I agree we don't want to change the default git-bulk behavior

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.

I assume you meant "filepaths that include a space" and not "filepaths that include a newline", right?

Yeah that's what I meant haha

@spacewander spacewander merged commit 8eed5f4 into tj:main Feb 27, 2025
5 checks passed
@spacewander
Copy link
Collaborator

Merged. Thanks!

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.

3 participants