]> 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 'master' of github.com:RichiH/vcsh
authorErrietta Kostala <errietta@errietta.me>
Tue, 7 Jan 2014 16:36:41 +0000 (16:36 +0000)
committerErrietta Kostala <errietta@errietta.me>
Tue, 7 Jan 2014 16:36:41 +0000 (16:36 +0000)
.gitignore
CONTRIBUTORS
README.md
changelog
vcsh

index 7567c757ac02695448c2261b78265f9ffc03dae7..4dec9bf3d79aeab9a9a982342256f2f9d1602af0 100644 (file)
@@ -1,4 +1,5 @@
 vcsh.1
 *.patch
 *.swp
+.swp
 *.bak
index 2dad8ed3f7ed610fac2812cbe68730758925e629..9ccbd8737b9ee809f27f07effb7fbd26af4337e0 100644 (file)
@@ -3,19 +3,25 @@ Auto-generated from tools/list_CONTRIBUTORS.
 
 Eric Bouchut <ebouchut@gmail.com>
 Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
+Rob Cornish <jrmcornish@gmail.com>
 Vincent Demeester <vincent@demeester.fr>
 Thomas Ferris Nicolaisen <tfnico@gmail.com>
 martin f. krafft <madduck@madduck.net>
 Alessandro Ghedini <alessandro@ghedini.me>
+Mikhail Gusarov <dottedmag@dottedmag.net>
 Valentin Haenel <valentin.haenel@gmx.de>
 Richard Hartmann <richih@debian.org>
 Gregor Jasny <gjasny@googlemail.com>
 Caleb Maclennan <caleb@alerque.com>
+Markus Martin <markus@archwyrm.net>
 mek-apelsin <mek@pels.in>
 Evan Pitstick <nerdx00@gmail.com>
 Dieter Plaetinck <dieter@plaetinck.be>
 Corey Quinn <corey@sequestered.net>
+Pavlos Ratis <dastergon@gentoo.org>
 Gernot Schulz <post@gernot-schulz.com>
 Alexander Skurikhin <a.skurihin@gmail.com>
 Jonathan Sternberg <jonathansternberg@gmail.com>
 Frank Terbeck <ft@bewatermyfriend.org>
+Aaron VonderHaar <gruen0aermel@gmail.com>
+Tony <zearin@gonk.net>
index 6166a6740c58465cd703192ed2d9269e769bcf41..57f56ed773586ae1becf75c2549d694b1c179041 100644 (file)
--- a/README.md
+++ b/README.md
@@ -70,44 +70,21 @@ modes you will still be fine.
 `vcsh enter` and `vcsh run`  will be covered in later sections.
 
 
-## Initialize a new repository called "vim"
+| Task                                                  | Command                                           |
+| ----------------------------------------------------- | ------------------------------------------------- |
+| _Initialize a new repository called "vim"_            |   `vcsh init vim`                                 |
+| _Clone an existing repository_                        |   `vcsh clone <remote> <repository_name>`         |
+| _Add files to repository "vim"_                       |   `vcsh vim add ~/.vimrc ~/.vim`                  |
+|                                                       |   `vcsh vim commit -m 'Update Vim configuration'` |
+| _Add a remote for repository "vim"_                   |   `vcsh vim remote add origin <remote>`           |
+|                                                       |   `vcsh vim push origin master:master`            |
+|                                                       |   `vcsh vim branch --track master origin/master`  |
+| _Push to remote of repository "vim"_                  |   `vcsh vim push`                                 |
+| _Pull from remote of repository "vim"_                |   `vcsh vim pull`                                 |
+| _Show status of changed files in all repositories_    |   `vcsh status`                                   |
+| _Pull from all repositories_                          |   `vcsh pull`                                     |
+| _Push to all repositories_                            |   `vcsh push`                                     |
 
-    vcsh init vim
-
-## Clone an existing repository
-
-    vcsh clone <remote> <repository_name>
-
-## Add files to repository "vim"
-
-    vcsh vim add ~/.vimrc ~/.vim
-    vcsh vim commit -m 'Update Vim configuration'
-
-## Add a remote for repository "vim"
-
-    vcsh vim remote add origin <remote>
-    vcsh vim push origin master:master
-    vcsh vim branch --track master origin/master
-
-## Push to remote of repository "vim"
-
-    vcsh vim push
-
-## Pull from remote of repository "vim"
-
-    vcsh vim pull
-
-## Show status of changed files in all repositories
-
-    vcsh status
-
-## Pull from all repositories
-
-    vcsh pull
-
-## Push to all repositories
-
-    vcsh push
 
 # Overview
 
@@ -280,14 +257,21 @@ the template will be stored.
 
     apt-get install mr
 
-#### Install vcsh
+### Install vcsh
 
 #### Debian
 
-If you are using Debian Squeeze, you will need to enable backports
+If you are using Debian Squeeze, you will need to enable backports.
+From Wheezy onwards, you can install it directly:
 
     apt-get install vcsh
 
+#### Gentoo
+
+To install vcsh in Gentoo Linux just give the following command as root:
+
+    emerge dev-vcs/vcsh
+
 #### Arch Linux
 
 vcsh is availabe via [AUR](https://aur.archlinux.org/packages.php?ID=54164)
index b0bac5d205166c3e704c18b4c85c3ce10d0fe2e9..dc578c6f6686ca8d107bc505f22d41b07543bfab 100644 (file)
--- a/changelog
+++ b/changelog
@@ -1,3 +1,10 @@
+2013-12-29  Richard Hartmann <richih.mailinglist@gmail.com>
+
+       * Release 1.20131229
+       * Fix mktemp bug (GitHub issue #99)
+       * Make code more resilient and efficient
+       * Improve output
+
 2013-12-14  Richard Hartmann <richih.mailinglist@gmail.com>
 
        * Release 1.20131214
diff --git a/vcsh b/vcsh
index cb7eada9a88ff1a42c898e026b684f62479f8ee2..5d502e7c68f372a427f0ad68e62bc8938899cead 100755 (executable)
--- a/vcsh
+++ b/vcsh
 # This should always be the first line of code to facilitate debugging
 [ -n "$VCSH_DEBUG" ] && set -vx
 
+
+# If '.git-HEAD' is appended to the version, you are seeing an unreleased
+# version of vcsh; the master branch is supposed to be clean at all times
+# so you can most likely just use it nonetheless
+VERSION='1.20131229.git-HEAD'
 SELF=$(basename $0)
-VERSION='1.20131214.git-HEAD'
 
 fatal() {
        echo "$SELF: fatal: $1" >&2
@@ -32,11 +36,11 @@ while getopts "c:dv" flag; do
                VCSH_DEBUG=1
                echo "debug mode on"
                echo "$SELF $VERSION"
-       elif [ "$1" = '-v' ];then
+       elif [ "$1" = '-v' ]; then
                VCSH_VERBOSE=1
                echo "verbose mode on"
                echo "$SELF $VERSION"
-       elif [ "$1" = '-c' ];then
+       elif [ "$1" = '-c' ]; then
                VCSH_OPTION_CONFIG=$OPTARG
        fi
        shift 1
@@ -53,7 +57,7 @@ source_all() {
 
 # Read configuration and set defaults if anything's not set
 [ -n "$VCSH_DEBUG" ]                  && set -vx
-[ -z "$XDG_CONFIG_HOME" ]             && XDG_CONFIG_HOME="$HOME/.config"
+: ${XDG_CONFIG_HOME:=$HOME/.config}
 
 # Read configuration files if there are any
 [ -r "/etc/vcsh/config" ]             && . "/etc/vcsh/config"
@@ -69,11 +73,11 @@ fi
 [ -n "$VCSH_DEBUG" ]                  && set -vx
 
 # Read defaults
-[ -z "$VCSH_REPO_D" ]                 && VCSH_REPO_D="$XDG_CONFIG_HOME/vcsh/repo.d"
-[ -z "$VCSH_HOOK_D" ]                 && VCSH_HOOK_D="$XDG_CONFIG_HOME/vcsh/hooks-enabled"
-[ -z "$VCSH_BASE" ]                   && VCSH_BASE="$HOME"
-[ -z "$VCSH_GITIGNORE" ]              && VCSH_GITIGNORE='exact'
-[ -z "$VCSH_WORKTREE" ]               && VCSH_WORKTREE='absolute'
+: ${VCSH_REPO_D:=$XDG_CONFIG_HOME/vcsh/repo.d}
+: ${VCSH_HOOK_D:=$XDH_CONFIG_HOME/vcsh/hooks-enabled}
+: ${VCSH_BASE:=$HOME}
+: ${VCSH_GITIGNORE:=exact}
+: ${VCSH_WORKTREE:=absolute}
 
 if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then
        fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1
@@ -247,7 +251,7 @@ list_tracked_by() {
 pull() {
        hook pre-pull
        for VCSH_REPO_NAME in $(list); do
-               echo -n "$VCSH_REPO_NAME: "
+               printf "$VCSH_REPO_NAME: "
                export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git"
                use
                git pull
@@ -259,7 +263,7 @@ pull() {
 push() {
        hook pre-push
        for VCSH_REPO_NAME in $(list); do
-               echo -n "$VCSH_REPO_NAME: "
+               printf "$VCSH_REPO_NAME: "
                export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git"
                use
                git push
@@ -359,8 +363,9 @@ write_gitignore() {
        done | sort -u)
 
        # Contrary to GNU mktemp, mktemp on BSD/OSX requires a template for temp files
-       # Use the template GNU mktemo defaults to
-       tempfile=$(mktemp tmp.XXXXXXXXXX) || fatal "could not create tempfile" 51
+       # Using a template makes GNU mktemp default to $PWD and not #TMPDIR for tempfile location
+       # To make every OS happy, set full path explicitly
+       tempfile=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal "could not create tempfile: '${tempfile}'" 51
 
        echo '*' > "$tempfile" || fatal "could not write to '$tempfile'" 57
        for gitignore in $gitignores; do
@@ -390,22 +395,23 @@ fi
 
 export VCSH_COMMAND="$1"
 
-[ "$VCSH_COMMAND" = 'clon' ]   || [ "$VCSH_COMMAND" = 'clo' ]   || [ "$VCSH_COMMAND" = 'cl' ]                                                                && VCSH_COMMAND='clone'
-[ "$VCSH_COMMAND" = 'commi' ]  || [ "$VCSH_COMMAND" = 'comm' ]  || [ "$VCSH_COMMAND" = 'com' ]  || [ "$VCSH_COMMAND" = 'co' ]                                && VCSH_COMMAND='commit'
-[ "$VCSH_COMMAND" = 'delet' ]  || [ "$VCSH_COMMAND" = 'dele' ]  || [ "$VCSH_COMMAND" = 'del' ]  || [ "$VCSH_COMMAND" = 'de' ]                                && VCSH_COMMAND='delete'
-[ "$VCSH_COMMAND" = 'ente' ]   || [ "$VCSH_COMMAND" = 'ent' ]   || [ "$VCSH_COMMAND" = 'en' ]                                                                && VCSH_COMMAND='enter'
-[ "$VCSH_COMMAND" = 'hel' ]    || [ "$VCSH_COMMAND" = 'he' ]                                                                                                 && VCSH_COMMAND='help'
-[ "$VCSH_COMMAND" = 'ini' ]    || [ "$VCSH_COMMAND" = 'in' ]                                                                                                 && VCSH_COMMAND='init'
-[ "$VCSH_COMMAND" = 'pul' ]                                                                                                                                  && VCSH_COMMAND='pull'
-[ "$VCSH_COMMAND" = 'pus' ]                                                                                                                                  && VCSH_COMMAND='push'
-[ "$VCSH_COMMAND" = 'renam' ]  || [ "$VCSH_COMMAND" = 'rena' ]  || [ "$VCSH_COMMAND" = 'ren' ]  || [ "$VCSH_COMMAND" = 're' ]                                && VCSH_COMMAND='rename'
-[ "$VCSH_COMMAND" = 'ru' ]                                                                                                                                   && VCSH_COMMAND='run'
-[ "$VCSH_COMMAND" = 'statu' ]  || [ "$VCSH_COMMAND" = 'stat' ]  || [ "$VCSH_COMMAND" = 'sta' ]  || [ "$VCSH_COMMAND" = 'st' ]                                && VCSH_COMMAND='status'
-[ "$VCSH_COMMAND" = 'upgrad' ] || [ "$VCSH_COMMAND" = 'upgra' ] || [ "$VCSH_COMMAND" = 'upgr' ] || [ "$VCSH_COMMAND" = 'upg' ]                               && VCSH_COMMAND='upgrade'
-[ "$VCSH_COMMAND" = 'versio' ] || [ "$VCSH_COMMAND" = 'versi' ] || [ "$VCSH_COMMAND" = 'vers' ] || [ "$VCSH_COMMAND" = 'ver' ] || [ "$VCSH_COMMAND" = 've' ] && VCSH_COMMAND='version'
-[ "$VCSH_COMMAND" = 'whic' ]   || [ "$VCSH_COMMAND" = 'whi' ]   || [ "$VCSH_COMMAND" = 'wh' ]                                                                && VCSH_COMMAND='which'
-[ "$VCSH_COMMAND" = 'write' ]  || [ "$VCSH_COMMAND" = 'writ' ]  || [ "$VCSH_COMMAND" = 'wri' ]  || [ "$VCSH_COMMAND" = 'wr' ]                                && VCSH_COMMAND='write-gitignore'
-
+case "$VCSH_COMMAND" in
+       clon|clo|cl) VCSH_COMMAND=clone;;
+       commi|comm|com|co) VCSH_COMMAND=commit;;
+       delet|dele|del|de) VCSH_COMMAND=delete;;
+       ente|ent|en) VCSH_COMMAND=enter;;
+       hel|he) VCSH_COMMAND=help;;
+       ini|in) VCSH_COMMAND=init;;
+       pul) VCSH_COMMAND=pull;;
+       pus) VCSH_COMMAND=push;;
+       renam|rena|ren|re) VCSH_COMMAND=rename;;
+       ru) VCSH_COMMAND=run;;
+       statu|stat|sta|st) VCSH_COMMAND=status;;
+       upgrad|upgra|upgr|up) VCSH_COMMAND=upgrade;;
+       versio|versi|vers|ver|ve) VCSH_COMMAND=version;;
+       which|whi|wh) VCSH_COMMAND=which;;
+       write|writ|wri|wr) VCSH_COMMAND=write-gitignore;;
+esac    
 
 if [ "$VCSH_COMMAND" = 'clone' ]; then
        [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a remote" 1