From: Richard Hartmann Date: Wed, 31 Jul 2013 22:19:02 +0000 (+0200) Subject: Merge branch 'feature--vcsh-commit' X-Git-Url: https://git.madduck.net/code/vcsh.git/commitdiff_plain/67b0da790e240f714bdd1c4256957c3261d5533a?hp=a5523eb298c3bab97002f3b53161cfd6c328044a Merge branch 'feature--vcsh-commit' Conflicts: doc/vcsh.1.ronn vcsh --- diff --git a/.mailmap b/.mailmap index bf08497..1e66b4d 100644 --- a/.mailmap +++ b/.mailmap @@ -1 +1,2 @@ Richard Hartmann +Alexander Skurikhin diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 62be089..abea9e0 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3,11 +3,13 @@ Alphabetical list of everyone who ever committed to this repository Vincent Demeester Thomas Ferris Nicolaisen martin f. krafft +Alessandro Ghedini Valentin Haenel Richard Hartmann mek-apelsin Dieter Plaetinck Corey Quinn Gernot Schulz +Alexander Skurikhin Jonathan Sternberg Frank Terbeck diff --git a/changelog b/changelog index c835962..1f1d1e6 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,25 @@ +2013-07-24 Richard Hartmann + + * Release 1.20130724 + * Add support for `vcsh status` + * Improve output of `vcsh pull` + * Improve output of `vcsh push` + * Minor documentation improvements + +2013-07-23 Richard Hartmann + + * Release 1.20130723 + * Support $VCSH_GITIGNORE == none + * Documentation improvements, + * Improved zsh completion + * Add support for `vcsh pull` + * Add support for `vcsh push` + * Add retire() to tear down vcsh ENV + * Add clone hooks, including one witout vcsh ENV to + allow subsequent cloning of other repos + * Fix `vcsh rename` + * Improve general code robustness + 2013-06-14 Richard Hartmann * Release 1.20130614 diff --git a/doc/hooks b/doc/hooks index 5547131..3c72ef8 100644 --- a/doc/hooks +++ b/doc/hooks @@ -1,9 +1,25 @@ Available hooks are: -pre-command -post-command -pre-enter -post-enter -pre-run -post-run -pre-upgrade -post-upgrade + +* pre-clone +* post-clone +* post-clone-retired + Use this if you need to operate on different git repositories after cloning. + This hook can be useful if your configuration needs some remote + repositories, but you do not want to include it into your vcsh + repository. For instance, if you use vim plugins manager (vundle, + NeoBundle), zsh configuration frameworks (oh-my-zsh, prezto), etc. +* pre-command +* post-command +* pre-enter +* post-enter +* pre-pull +* post-pull +* pre-push +* post-push +* pre-run +* post-run +* pre-upgrade +* post-upgrade + +If you write any interesting or useful hooks, please send them upstream +so they can be included in an examples section. diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index b7f9725..01cadb5 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -29,6 +29,8 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` run +`vcsh` status + `vcsh` upgrade `vcsh` version @@ -81,6 +83,9 @@ 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 @@ -125,6 +130,9 @@ an interactive user. 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. @@ -164,11 +172,13 @@ executed in the context of your shell. Interesting knobs you can turn: * <$VCSH_GITIGNORE>: - Can be either or . + Can be , , or . - will seed the repo-specific <.gitignore> with all file and directory + will seed the repo-specific ignore file with all file and directory names which `git ls-files` returns. + will not write any ignore file. + will descend through all directories recursively additionally to the above. diff --git a/vcsh b/vcsh index 1918af4..85e20d8 100755 --- a/vcsh +++ b/vcsh @@ -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 @@ basename() { } SELF=$(basename $0) -VERSION='1.20130614' +VERSION='1.20130724' fatal() { echo "$SELF: fatal: $1" >&2 @@ -107,6 +107,7 @@ help() { Rename repository run \\ Use this repository + status Show statuses of all vcsh repositories upgrade Upgrade repository to currently recommended settings version Print version information which Find substring in name of any tracked file @@ -154,6 +155,8 @@ 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() { @@ -244,6 +247,7 @@ pull() { export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" use git pull + echo done hook post-pull } @@ -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() { @@ -273,11 +289,21 @@ 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 @@ -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 @@ -311,7 +343,7 @@ write_gitignore() { 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 @@ -328,8 +360,8 @@ write_gitignore() { 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 @@ -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" = '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' @@ -394,9 +427,8 @@ if echo $VCSH_REPO_NAME | grep -q '/'; then 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 @@ -405,7 +437,10 @@ do 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')