Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions bin/git-bulk
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ guardedmode=false
singlemode=false
allwsmode=false
quiet=false
no_follow_symlinks=false

#
# print usage message
#
usage() {
echo 1>&2 "usage: git bulk [-q|--quiet] [-g] ([-a]|[-w <ws-name>]) <git command>"
echo 1>&2 "usage: git bulk [--no-follow-symlinks] [-q|--quiet] [-g] ([-a]|[-w <ws-name>]) <git command>"
echo 1>&2 " git bulk --addworkspace <ws-name> <ws-root-directory> (--from <URL or file>)"
echo 1>&2 " git bulk --removeworkspace <ws-name>"
echo 1>&2 " git bulk --addcurrent <ws-name>"
Expand Down Expand Up @@ -146,7 +147,15 @@ function executBulkOp () {
local actual=$PWD
[ "${quiet?}" != "true" ] && echo 1>&2 "Executing bulk operation in workspace ${inverse}$actual${reset}"

allGitFolders=( $(eval find -L . -name ".git" 2>/dev/null) )
# build `find` flags depending on command-line options
local find_flags=()
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

fi
# find all git repositories under the workspace on which we want to operate
readarray allGitFolders < <(find "${find_flags[@]}" . -name ".git" 2>/dev/null)

for line in "${allGitFolders[@]}"; do
local gitrepodir=${line::${#line}-5} # cut the .git part of find results to have the root git directory of that repository
Expand All @@ -172,6 +181,8 @@ while [ "${#}" -ge 1 ] ; do
butilcommand="${1:2}" && break ;;
--removeworkspace|--addcurrent|--addworkspace)
butilcommand="${1:2}" && wsname="$2" && wsdir="$3" && if [ "$4" == "--from" ]; then source="$5"; fi && break ;;
--no-follow-symlinks)
no_follow_symlinks=true ;;
-a)
allwsmode=true ;;
-g)
Expand Down
8 changes: 6 additions & 2 deletions man/git-bulk.1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.\" generated with Ronn-NG/v0.9.1
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
.TH "GIT\-BULK" "1" "September 2024" "" "Git Extras"
.TH "GIT\-BULK" "1" "February 2025" "" "Git Extras"
.SH "NAME"
\fBgit\-bulk\fR \- Run git commands on multiple repositories
.SH "SYNOPSIS"
\fBgit\-bulk\fR [\-g] ([\-a]|[\-w
\fBgit\-bulk\fR [\-g] [\-\-no\-follow\-symlinks] ([\-a]|[\-w
.br
\fBgit\-bulk\fR \-\-addworkspace
.br
Expand Down Expand Up @@ -33,6 +33,10 @@ Run a git command on all workspaces and their repositories\.
.P
Ask the user for confirmation on every execution\.
.P
\-\-no\-follow\-symlinks
.P
Do not traverse symbolic links under the workspace when searching for git repositories\.
.P
\-w <ws\-name>
.P
Run the git command on the specified workspace\. The workspace must be registered\.
Expand Down
8 changes: 6 additions & 2 deletions man/git-bulk.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/git-bulk.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ git-bulk(1) -- Run git commands on multiple repositories

## SYNOPSIS

`git-bulk` [-g] ([-a]|[-w &lt;ws-name&gt;]) &lt;git command&gt; <br/>
`git-bulk` [-g] [--no-follow-symlinks] ([-a]|[-w &lt;ws-name&gt;]) &lt;git command&gt; <br/>
`git-bulk` --addworkspace &lt;ws-name&gt; &lt;ws-root-directory&gt; (--from &lt;URL or file&gt;) <br/>
`git-bulk` --removeworkspace &lt;ws-name&gt; <br/>
`git-bulk` --addcurrent &lt;ws-name&gt; <br/>
Expand All @@ -28,6 +28,10 @@ git bulk adds convenient support for operations that you want to execute on mult

Ask the user for confirmation on every execution.

--no-follow-symlinks

Do not traverse symbolic links under the workspace when searching for git repositories.

-w &lt;ws-name&gt;

Run the git command on the specified workspace. The workspace must be registered.
Expand Down
2 changes: 1 addition & 1 deletion man/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ git-clear-soft(1) git-clear-soft
git-clear(1) git-clear
git-coauthor(1) git-coauthor
git-commits-since(1) git-commits-since
git-contrib(1) git-contrib
git-continue(1) git-continue
git-contrib(1) git-contrib
git-count(1) git-count
git-cp(1) git-cp
git-create-branch(1) git-create-branch
Expand Down
Loading