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

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:

Merge branch 'feature--vcsh-commit'
authorRichard Hartmann <richih.mailinglist@gmail.com>
Wed, 31 Jul 2013 22:19:02 +0000 (00:19 +0200)
committerRichard Hartmann <richih.mailinglist@gmail.com>
Wed, 31 Jul 2013 22:19:02 +0000 (00:19 +0200)
Conflicts:
doc/vcsh.1.ronn
vcsh

1  2 
doc/vcsh.1.ronn
vcsh

diff --combined doc/vcsh.1.ronn
index 9532e654278c1187eb0112b8d50769ed19156eea,b7f9725a9b454cf8cc6c023d595cd3ad9e5cb079..01cadb5942b9debfeb1135ea0e81ba257e1edb1e
@@@ -29,8 -29,6 +29,8 @@@ vcsh(1) - Version Control System for $H
  
  `vcsh` run <repo> <shell command>
  
 +`vcsh` status
 +
  `vcsh` upgrade <repo>
  
  `vcsh` version
@@@ -83,9 -81,9 +83,12 @@@ an interactive user
  * clone:
    Clone an existing repository.
  
 +  If you need to clone a bundle of repositories, look into the
 +  `post-clone-retired` hook.
 +
+ * commit:
+   Commit in all repositories
  * delete:
    Delete an existing repository.
  
    This is needed to support mr and other scripts properly and of no concern to
    an interactive user.
  
 +* status:
 +  Show statuses of all vcsh repositories.
 +
  * upgrade:
    Upgrade repository to currently recommended settings.
  
@@@ -169,13 -164,11 +172,13 @@@ executed in the context of your shell
  Interesting knobs you can turn:
  
  * <$VCSH_GITIGNORE>:
 -  Can be either <exact> or <recursive>.
 +  Can be <exact>, <none>, or <recursive>.
  
 -  <exact> will seed the repo-specific <.gitignore> with all file and directory
 +  <exact> will seed the repo-specific ignore file with all file and directory
    names which `git ls-files` returns.
  
 +  <none> will not write any ignore file.
 +
    <recursive> will descend through all directories recursively additionally to
    the above.
  
diff --combined vcsh
index f2bbd7a229c8211b9d79cb3bb0ee262f54a28eec,1918af44d8cb8f2dafc5c33aae26cb5b007699e6..85e20d8e6bc3ce41a0f451192a85f8c6e1fba28a
--- 1/vcsh
--- 2/vcsh
+++ b/vcsh
@@@ -8,7 -8,7 +8,7 @@@
  # While the following is not legally binding, the author would like to
  # explain the choice of GPLv2+ over GPLv3+.
  # The author prefers GPLv3+ over GPLv2+ but feels it's better to maintain
 -# full compatibility's with git. In case git ever changes its licensing terms,
 +# full compatibility's with Git. In case Git ever changes its licensing terms,
  # which is admittedly extremely unlikely to the point of being impossible,
  # this software will most likely follow suit.
  
@@@ -24,7 -24,7 +24,7 @@@ basename() 
  }
  
  SELF=$(basename $0)
 -VERSION='1.20130614'
 +VERSION='1.20130724'
  
  fatal() {
        echo "$SELF: fatal: $1" >&2
@@@ -92,6 -92,7 +92,7 @@@ help() 
     commands:
     clone <remote> \\
           [<repo>]       Clone from an existing repository
+    commit               Commit in all repositories
     delete <repo>        Delete an existing repository
     enter <repo>         Enter repository; spawn new instance of \$SHELL
     help                 Display this help text
            <newname>     Rename repository
     run <repo> \\
         <command>        Use this repository
 +   status               Show statuses of all vcsh repositories
     upgrade <repo>       Upgrade repository to currently recommended settings
     version              Print version information
     which <substring>    Find substring in name of any tracked file
@@@ -154,10 -154,20 +155,22 @@@ clone() 
    Once this situation has been resolved, run 'vcsh run $VCSH_REPO_NAME git pull' to finish cloning.\n" 17
        git merge origin/master
        hook post-clone
 +      retire
 +      hook post-clone-retired
  }
  
+ commit() {
+       hook pre-commit
+       for VCSH_REPO_NAME in $(list); do
+               echo "$VCSH_REPO_NAME: "
+               export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git"
+               use
+               git commit --untracked-files=no --quiet
+               echo
+       done
+       hook post-commit
+ }
  delete() {
        cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11
        use
@@@ -234,7 -244,6 +247,7 @@@ pull() 
                export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git"
                use
                git pull
 +              echo
        done
        hook post-pull
  }
@@@ -246,27 -255,15 +259,27 @@@ push() 
                export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git"
                use
                git push
 +              echo
        done
        hook post-push
  }
  
 +retire() {
 +      unset GIT_WORK_TREE
 +      unset VCSH_DIRECTORY
 +}
 +
  rename() {
        git_dir_exists
        [ -d "$GIT_DIR_NEW" ] && fatal "'$GIT_DIR_NEW' exists" 54
        mv -f "$GIT_DIR" "$GIT_DIR_NEW" || fatal "Could not mv '$GIT_DIR' '$GIT_DIR_NEW'" 52
  
 +      # Now that the repository has been renamed, we need to fix up its configuration
 +      # Overwrite old name..
 +      GIT_DIR="$GIT_DIR_NEW"
 +      $VCSH_REPO_NAME="$VCSH_REPO_NAME_NEW"
 +      # ..and clobber all old configuration
 +      upgrade
  }
  
  run() {
        hook post-run
  }
  
 +status() {
 +      for VCSH_REPO_NAME in $(list); do
 +              echo "$VCSH_REPO_NAME:"
 +              export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git"
 +              use
 +              git status --short --untracked-files='no'
 +              echo
 +      done
 +}
 +
  upgrade() {
        hook pre-upgrade
        use
        git config core.worktree     "$GIT_WORK_TREE"
 -      git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME"
 +      [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME"
        git config vcsh.vcsh         'true'
        [ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME"
        hook post-upgrade
@@@ -311,12 -298,6 +324,12 @@@ which() 
  }
  
  write_gitignore() {
 +      # Don't do anything if the user does not want to write gitignore
 +      if [ "x$VCSH_GITIGNORE" = 'xnone' ]; then
 +              info "Not writing gitignore as '\$VCSH_GITIGNORE' is set to 'none'"
 +              exit
 +      fi
 +
        use
        cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11
        gitignores=$(for file in $(git ls-files); do
        echo '*' > "$tempfile" || fatal "could not write to '$tempfile'" 57
        for gitignore in $gitignores; do
                echo "$gitignore" | sed 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57
 -              if [ x$VCSH_GITIGNORE = x'recursive' ] && [ -d "$gitignore" ]; then
 +              if [ "x$VCSH_GITIGNORE" = 'xrecursive' ] && [ -d "$gitignore" ]; then
                        { echo "$gitignore/*" | sed 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57; }
                fi
        done
                fatal "could not move '$tempfile' to '$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME'" 53
  }
  
 -if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then
 -      fatal "'\$VCSH_GITIGNORE' must be either 'exact' or 'recursive'" 1
 +if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then
 +      fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1
  fi
  
  if [ "$1" = 'clone' ]; then
@@@ -376,18 -357,18 +389,19 @@@ elif [ "$1" = 'delete' ]           |
       [ "$1" = 'write-gitignore' ]; then
        [ -z $2 ]                      && fatal "$1: please specify repository to work on" 1
        [ "$1" = 'rename' -a -z "$3" ] && fatal "$1: please specify a target name" 1
 -      [ "$1" = 'run' -a -z "$3" ]    && fatal "$1: please specify a command" 1
 +      [ "$1" = 'run'    -a -z "$3" ] && fatal "$1: please specify a command" 1
        export VCSH_COMMAND="$1"
        export VCSH_REPO_NAME="$2"
        export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git"
 -      [ "$VCSH_COMMAND" = 'rename' ]         && export GIT_DIR_NEW="$VCSH_REPO_D/$3.git"
 -      [ "$VCSH_COMMAND" = 'run' ] && shift 2
 -      [ "$VCSH_COMMAND" = 'write-gitignore' ]
 +      [ "$VCSH_COMMAND" = 'rename' ] && { export VCSH_REPO_NAME_NEW="$3";
 +                                          export GIT_DIR_NEW="$VCSH_REPO_D/$VCSH_REPO_NAME_NEW.git"; }
 +      [ "$VCSH_COMMAND" = 'run' ]    && shift 2
- elif [ "$1" = 'list' ] ||
+ elif [ "$1" = 'commit' ] ||
+      [ "$1" = 'list' ] ||
       [ "$1" = 'list-tracked' ] ||
       [ "$1" = 'pull' ] ||
 -     [ "$1" = 'push' ]; then
 +     [ "$1" = 'push' ] ||
 +     [ "$1" = 'status' ]; then
        export VCSH_COMMAND="$1"
  elif [ -n "$2" ]; then
        export VCSH_COMMAND='run'
@@@ -413,8 -394,9 +427,8 @@@ if echo $VCSH_REPO_NAME | grep -q '/'; 
        export VCSH_REPO_NAME=$(basename "$VCSH_REPO_NAME" .git)
  fi
  
 -
 -for check_directory in "$VCSH_REPO_D" "$VCSH_BASE/.gitignore.d"
 -do
 +check_dir() {
 +      check_directory="$1"
        if [ ! -d "$check_directory" ]; then
                if [ -e "$check_directory" ]; then
                        fatal "'$check_directory' exists but is not a directory" 13
                        mkdir -p "$check_directory" || fatal "could not create '$check_directory'" 50
                fi
        fi
 -done
 +}
 +
 +check_dir "$VCSH_REPO_D"
 +[ ! "x$VCSH_GITIGNORE" = 'xnone' ] && check_dir "$VCSH_BASE/.gitignore.d"
  
  verbose "$VCSH_COMMAND begin"
  export VCSH_COMMAND=$(echo $VCSH_COMMAND | sed 's/-/_/g')