]> git.madduck.net Git - code/vcsh.git/blobdiff - vcsh

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

vcsh: Implement skeleton of `vcsh foreach`
[code/vcsh.git] / vcsh
diff --git a/vcsh b/vcsh
index 0f2c5af7373af05fa9a0510ff6173df44ac31ab7..a5c3f487c0707ad6ddc2cda61e37967dd4e776b2 100755 (executable)
--- a/vcsh
+++ b/vcsh
@@ -214,6 +214,16 @@ enter() {
        hook post-enter
 }
 
+foreach() {
+       hook pre-foreach
+       for VCSH_REPO_NAME in $(list); do
+               GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR
+               use
+               "$@"
+       done
+       hook post-foreach
+}
+
 git_dir_exists() {
        [ -d "$GIT_DIR" ] || fatal "no repository found for '$VCSH_REPO_NAME'" 12
 }
@@ -546,6 +556,9 @@ elif [ x"$VCSH_COMMAND" = x'delete' ]           ||
        [ x"$VCSH_COMMAND" = x'rename' ] && { VCSH_REPO_NAME_NEW=$3; export VCSH_REPO_NAME_NEW;
                                              GIT_DIR_NEW=$VCSH_REPO_D/$VCSH_REPO_NAME_NEW.git; export GIT_DIR_NEW; }
        [ x"$VCSH_COMMAND" = x'run' ]    && shift 2
+elif [ x"$VCSH_COMMAND" = x'foreach' ]; then
+       [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a command" 1
+       shift 1
 elif [ x"$VCSH_COMMAND" = x'commit' ] ||
      [ x"$VCSH_COMMAND" = x'list'   ] ||
      [ x"$VCSH_COMMAND" = x'list-tracked' ] ||