diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000000000000000000000000000000000000..bf0849747acfe4687d71d559c5a39af6380c690d --- /dev/null +++ b/.mailmap @@ -0,0 +1 @@ +Richard Hartmann <richih.mailinglist@gmail.com> <richih+github.com@richih.org> diff --git a/AUTHORS b/AUTHORS index 5e52a9df220eb79795dd53e7816bf68ba2cba103..e6c3f11e2553c66b4a828e88e9ee405a55a2d50e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,7 +1,7 @@ Alphabetical list of everyone who ever committed to this repository Vincent Demeester <vincent@demeester.fr> -Richard Hartmann <richih+github.com@richih.org> +Valentin Haenel <valentin.haenel@gmx.de> Richard Hartmann <richih.mailinglist@gmail.com> Dieter Plaetinck <dieter@plaetinck.be> Corey Quinn <corey@sequestered.net> diff --git a/Makefile b/Makefile index a52e9edf49b4996a99dad1658c93c9c19a12b1b7..cb112c72b619dec628d167f17f75630a99bb34fd 100644 --- a/Makefile +++ b/Makefile @@ -43,4 +43,4 @@ test: if which git > /dev/null ; then :; else echo "'git' not found, exiting..."; exit 1; fi moo: - if [ -x /usr/games/cowsay ]; then /usr/games/cowsay "I hope you're happy now..."; fi + @if [ -x /usr/games/cowsay ]; then /usr/games/cowsay "I hope you're happy now..."; fi diff --git a/PACKAGING b/PACKAGING new file mode 100644 index 0000000000000000000000000000000000000000..92c1dd50d0d0bcddad814852b492fc55dd67570e --- /dev/null +++ b/PACKAGING @@ -0,0 +1,25 @@ +# Archlinux + +AUR does not require any packaging information within this repository. + +# Debian + +Debian packages are provided by the author in separate branches, maintained in +the upstream repository + +## Ubuntu + +Ubuntu imports Debian's package automagically. + +# Mac OS X + +Homebrew does not require any packaging information within this repository. +A separate branch with a statically compiled manpage and release tags is +provided to ease packaging. The static manpage because Homebrew lacks Ronn; +the tag so github generates tarballs Homebrew can be pointed at. + +# Anything else + +If you are maintaining a package for a different distribution, please get +in touch so your work can be included in another branch, thus allowing others +to adapt it to their needs or to improve it. diff --git a/README.md b/README.md index c0585d237617259e167c1ca5670d5d4c831a9bc8..66db1106b82582cc3e0b4bf50b97ddbb1a551c35 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,11 @@ The following overview will try to give you an idea of the use cases and advantages of vcsh. See sections 3 and 4 for detailed instructions and examples. +## 2.1 Talks ## + +Some people found it useful to look at slides and videos explaining how vcsh works. +They can all be found at [here](http://richardhartmann.de/talks/). + # 3 Overview ## 3.1 Comparison to Other Solutions ## @@ -197,19 +202,48 @@ the template will be stored. apt-get install mr -#### 4.1.2 Clone the Template #### +#### 4.1.2 Install vcsh #### + +#### 4.1.2.1 Debian #### + +If you are using Debian Squeeze, you will need to enable backports + + apt-get install vcsh + +#### 4.1.2.2 Arch Linux #### + +vcsh is availabe via [AUR](https://aur.archlinux.org/packages.php?ID=54164) +and further documentation about the use of AUR is available +[on Arch's wiki](https://wiki.archlinux.org/index.php/Arch_User_Repository). + + cd /var/abs/local/ + wget https://aur.archlinux.org/packages/vc/vcsh-git/vcsh-git.tar.gz + tar xfz vcsh-git.tar.gz + cd vcsh-git + makepkg -s + pacman -U vcsh*.pkg.tar.xz + +#### 4.1.2.3 From source #### +If your version of mr is older than version 1.07, make sure to put + + include = cat /usr/share/mr/vcsh + +into your .mrconfig . + + # choose a location for your checkout cd $HOME mkdir -p ~/work/git - git clone git://github.com/RichiH/vcsh.git vcsh - # make sure 'include = cat /usr/share/mr/vcsh' points to an exiting file - vim .mrconfig + git clone git://github.com/RichiH/vcsh.git cd vcsh ln -s vcsh /usr/local/bin # or add it to your PATH cd + +#### 4.1.3 Clone the Template #### + vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr -#### 4.1.3 Enable Your Test Repository #### +#### 4.1.4 Enable Your Test Repository #### mv ~/.zsh ~/zsh.bak mv ~/.zshrc ~/zshrc.bak @@ -218,7 +252,7 @@ the template will be stored. cd mr up -#### 4.1.4 Set Up Your Own Repositories #### +#### 4.1.5 Set Up Your Own Repositories #### Now, it's time to edit the template config and fill it with your own remotes: diff --git a/changelog b/changelog index bfc4d24064c924d5c6d9bf4659d91a73279e146d..12e32088102ba5aae813c5767ab4aa842b55e127 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,28 @@ +2013-04-21 Richard Hartmann <richih.mailinglist@gmail.com> + + * Release 1.2 + * Introduce `vcsh version` + +2013-03-31 Richard Hartmann <richih.mailinglist@gmail.com> + + * Release 1.1 + * Documentation fixes + * Use rm -f when removing a git repo + * Fix quoting bug (Debian #699093) + +2013-02-13 Richard Hartmann <richih.mailinglist@gmail.com> + + * Release 1.0.1 + * Improve documentation + * Fix parameter bug + +2012-06-30 Richard Hartmann <richih.mailinglist@gmail.com> + + * Release 1.0 + * Make `vcsh list` more resilient + * Lots of doc improvements + + 2012-02-27 Richard Hartmann <richih.mailinglist@gmail.com> * Refactor Makefile diff --git a/debian/changelog b/debian/changelog index d662c1efcde5b167bb11e31243bf41a87d6bfd02..bb0428202c362b494046d536d36670a9f640399c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,28 @@ +vcsh (1.2-1) experimental; urgency=low + + * New upstream release + + Documentation fixes + + Introduce `vcsh version` Closes: #694584 + + -- Richard Hartmann <richih.mailinglist@gmail.com> Sun, 21 Apr 2013 01:17:27 +0200 + +vcsh (1.1-1) experimental; urgency=low + + * New upstream release + + Documentation fixes + + Use rm -f when removing a git repo + + Fix quoting bug Closes: #699093 + + -- Richard Hartmann <richih.mailinglist@gmail.com> Sun, 31 Mar 2013 20:46:10 +0200 + +vcsh (1.0-1) unstable; urgency=low + + * New upstream release + + Make `vcsh list` more resilient + + Lots of doc improvements + + -- Richard Hartmann <richih.mailinglist@gmail.com> Sat, 30 Jun 2012 01:49:00 +0200 + vcsh (0.20120227-1~bpo60+1) squeeze-backports; urgency=low * Rebuild for squeeze-backports. diff --git a/debian/control b/debian/control index edded467ad67f17f28a63729534b8b09280522da..cdd81abd4aef8b939bf326e28aeb99ebf645afd5 100644 --- a/debian/control +++ b/debian/control @@ -3,15 +3,19 @@ Maintainer: Richard Hartmann <richih.mailinglist@gmail.com> Section: misc Priority: optional Standards-Version: 3.9.3 -Build-Depends: debhelper (>= 7), git +Build-Depends: debhelper (>= 7), + git Vcs-Git: git://github.com/RichiH/vcsh.git Vcs-Browser: https://github.com/RichiH/vcsh Homepage: https://github.com/RichiH/vcsh/blob/master/README.md Package: vcsh Architecture: all -Depends: ${shlibs:Depends}, ${misc:Depends}, git -Recommends: mr (>= 1.07), ssh-client +Depends: git, + ${misc:Depends}, + ${shlibs:Depends} +Recommends: mr (>= 1.07), + ssh-client Description: manage config files in $HOME via fake bare git repositories vcsh allows you to have several git repositories, all maintaining their working trees in $HOME without clobbering each other. That, in turn, means you can have diff --git a/debian/copyright b/debian/copyright index 009cc048db9e11aa7a8e5eaab0b4f7fe93ddc4a8..8cf5b501d3faa7c1383d2888ee63bf5f859349b4 100644 --- a/debian/copyright +++ b/debian/copyright @@ -2,8 +2,8 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: vcsh Upstream-Contact: <richih.mailinglist@gmail.com> Source: https://github.com/RichiH/vcsh -License: GPL-2+ Copyright: 2011-2012 Richard Hartmann +License: GPL-2+ Files: * Copyright: 2011-2012 Richard Hartmann <richih.mailinglist@gmail.com> diff --git a/doc/error_codes.md b/doc/error_codes.md index e127e7d6e7d85f9ffa9bd7207446dfd8b22add99..49cb084ee4593b68d06668a631cc1fa367c94bec 100644 --- a/doc/error_codes.md +++ b/doc/error_codes.md @@ -1,7 +1,7 @@ * 0: OK * 1: Generic error -* 10: Init failed because $GIT_DIR exists -* 11: Could not enter $GIT_WORK_TREE +* 10: Init failed because $GIT\_DIR exists +* 11: Could not enter $GIT\_WORK\_TREE * 12: No repository found * 13: Required directory exists but is not a directory * 16: Potentially harmful operation aborted diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 76ae2a50920cb57db994787ada87f9ba5cb1e38a..e12cf1599c175ee5c8c3be9b12a845a5e28a70e8 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -3,6 +3,8 @@ vcsh(1) - manage config files in $HOME via fake bare git repositories ## SYNOPSIS +`vcsh` [<options>] <command> + `vcsh` clone <url> [<repo>] `vcsh` delete <repo> @@ -21,15 +23,17 @@ vcsh(1) - manage config files in $HOME via fake bare git repositories `vcsh` rename <repo> <newname> -`vcsh` run <repo> <command> +`vcsh` run <repo> <shell command> `vcsh` setup <repo> +`vcsh` version + `vcsh` which <substring> `vcsh` write-gitignore <repo> -`vcsh` <repo> <gitcommand> +`vcsh` <repo> <git command> `vcsh` <repo> @@ -59,6 +63,17 @@ an interactive user. ## OPTIONS +* -c: + Source <file> prior to other configuration files + +* -d: + Enable debug mode + +* -v: + Enable verbose mode + +## COMMANDS + * clone: Clone an existing repository. @@ -100,6 +115,9 @@ an interactive user. * setup: Set up repository with recommended settings. +* version: + Print version information. + * which <substring>: Find <substring> in name of any tracked file. @@ -117,6 +135,59 @@ an interactive user. As noted earlier, `vcsh` will set <$GIT_DIR> and <$GIT_WORK_TREE> to the appropriate values for fake bare git repositories. +## CONFIG + +There are several ways to turn the various knobs on `vcsh`. In order of +ascending precedence, they are: + +* `VARIABLE=foo vcsh` +* </etc/vcsh/config> +* <$XDG_CONFIG_HOME/vcsh/config> +* `vcsh -c <file>` + +Please note that those files are sourced. Any and all commands will be +executed in the context of your shell. + +Interesting knobs you can turn: + +* <$VCSH_GITIGNORE>: + Can be either <exact> or <recursive>. + + <exact> will seed the repo-specific <.gitignore> with all file and directory + names which `git ls-files` returns. + + <recursive> will descend through all directories recursively additionally to + the above. + + Defaults to <exact>. + +Less interesting knobs you could turn: + +* <$VCSH_DEBUG>: + Enter debug mode. + +* <$XDG_CONFIG_HOME>: + As specified in the 'XDG Base Directory Specification', see + <http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html> + + Defaults to <$HOME/.config>. + +* <$VCSH_REPO_D>: + The directory where repositories are read from and stored. + + Defaults to <$XDG_CONFIG_HOME/vcsh/repo.d>. + +* <$VCSH_HOOK_D>: + The directory where hooks are read from. + + Defaults to <$XDG_CONFIG_HOME/vcsh/hooks-enabled>. + +* <$VCSH_BASE>: + The directory where repositories are checked out to. + + Defaults to <$HOME>. + + ## HOOK SYSTEM `vcsh` provides a hook system. Hook scripts must be executable and should be @@ -141,25 +212,35 @@ but please let upstream know so we can ship them by default. ## DETAILED HOWTO AND FURTHER READING -Man pages are intended to be short and thus often useless to glean best -practices from. This software comes with a file called <README.md>. It contains -various approaches to setting up and using vcsh. You can view the file it as +Manpages are often short and sometimes useless to glean best practices from. +While the author tried to avoid this in this case, manpages can not cover +detailed howtos. + +This software also comes with a file called <README.md>. It contains various +approaches to setting up and using vcsh. You can view the file it as plain text or render it into various other formats via Markdown. On Debian-based systems, this file can be found in </usr/share/doc/vcsh>. ## SECURITY CONSIDERATIONS -`vcsh` allows you to execute arbitrary commands via `vcsh` run. For example, +`vcsh` allows you to execute arbitrary commands via `vcsh run`. For example, adding a `sudo`(8) rule for `vcsh` would be pretty stupid. -Additionally, vcsh will source, i.e. execute, <$XDG_CONFIG_HOME/vcsh/config>. -You can put any and all commands into this config file and they will be executed. +Additionally, vcsh will source, i.e. execute, all files listed in <CONFIG>. +You can put any and all commands into these config files and they will be +executed. ## BUGS None are known at this time, but reports and/or patches are more than welcome. +## INTEROPERABILITY + +If you rely on `git submodule` use `git` 1.7.12 or later. Earlier versions +do not clean internal variables properly before descending into submodules, +resulting in unhappy end users. + ## HISTORY Like most people, the author initially made do with a single repository for all diff --git a/tools/list_AUTHORS b/tools/list_AUTHORS index 2b91ac97945b45ad539e2d00882c6b864009671e..351820564a77614b5b10f335d38cf5ba549d76fa 100755 --- a/tools/list_AUTHORS +++ b/tools/list_AUTHORS @@ -2,4 +2,4 @@ echo 'Alphabetical list of everyone who ever committed to this repository ' -git log --all --format='%an <%ae>' | sort -u -k2 +git shortlog -se --all | cut -f1 --complement | sort -u -k2 diff --git a/vcsh b/vcsh index ba0049e542120cf4931ce3652b9b412808bef2b4..c446fb981ce89e4561f2bace26036a7cfb869da3 100755 --- a/vcsh +++ b/vcsh @@ -5,26 +5,82 @@ # For details, see LICENSE. To submit patches, you have to agree to # license your code under the GNU GPL version 2 or later. +# 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 compability with git. In case git ever changes its licensing terms, +# this software will most likely follow suit. +SELF=$(basename $0) +VERSION='1.2' + +fatal() { + echo "$SELF: fatal: $1" >&2 + exit $2 +} + +# We need to run getops as soon as possible so we catch -d and other +# options that will modify our behaviour. +# Commands are handled at the end of this script. +while getopts "c:dv" flag; do + if [ "$1" = '-d' ] || [ "$1" = '--debug' ]; then + set -vx + VCSH_DEBUG=1 + elif [ "$1" = '-v' ];then + VCSH_VERBOSE=1 + elif [ "$1" = '-c' ];then + VCSH_OPTION_CONFIG=$OPTARG + fi + shift 1 +done + +source_all() { + # Source file even if it's in $PWD and does not have any slashes in it + case "$1" in + */*) . "$1";; + *) . "$PWD/$1";; + esac; +} + + +# Read configuration and set defaults if anything's not set [ -n "$VCSH_DEBUG" ] && set -vx [ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config" + +# Read configuration files if there are any +[ -r "/etc/vcsh/config" ] && . "/etc/vcsh/config" [ -r "$XDG_CONFIG_HOME/vcsh/config" ] && . "$XDG_CONFIG_HOME/vcsh/config" +if [ -n "$VCSH_OPTION_CONFIG" ]; then + # Source $VCSH_OPTION_CONFIG if it can be read and is in $PWD of $PATH + if [ -r "$VCSH_OPTION_CONFIG" ]; then + source_all "$VCSH_OPTION_CONFIG" + else + fatal "Can not read configuration file '$VCSH_OPTION_CONFIG'" 1 + fi +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' -SELF=$(basename $0) help() { - echo "usage: $SELF <args> + echo "usage: $SELF <options> <command> + options: + -c <file> Source file + -d Enable debug mode + -v Enable verbose mode + + commands: clone <remote> \\ [<repo>] Clone from an existing repository + delete <repo> Delete an existing repository + enter <repo> Enter repository; spawn new instance of \$SHELL help Display this help text - delete Delete an existing repository - enter Enter repository; spawn new instance of \$SHELL init <repo> Initialize a new repository list List all repositories list-tracked List all files tracked by vcsh @@ -34,7 +90,8 @@ help() { <newname> Rename repository run <repo> \\ <command> Use this repository - setup Set up repository with recommended settings + setup <repo> Set up repository with recommended settings + version Print version information which <substring> Find substring in name of any tracked file write-gitignore \\ <repo> Write .gitignore.d/<repo> via git ls-files @@ -51,11 +108,6 @@ verbose() { if [ -n "$VCSH_DEBUG" ] || [ -n "$VCSH_VERBOSE" ]; then echo "$SELF: verbose: $@"; fi } -fatal() { - echo "$SELF: fatal: $1" >&2 - exit $2 -} - error() { echo "$SELF: error: $1" >&2 } @@ -88,7 +140,7 @@ clone() { delete() { cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 use - info "This operation WILL DETROY DATA!" + info "This operation WILL DESTROY DATA!" files=$(git ls-files) echo "These files will be deleted: @@ -101,7 +153,7 @@ To continue, type 'Yes, do as I say'" for file in $files; do rm -f $file || info "could not delete '$file', continuing with deletion" done - rm -r "$GIT_DIR" || error "could not delete '$GIT_DIR'" + rm -rf "$GIT_DIR" || error "could not delete '$GIT_DIR'" } enter() { @@ -133,8 +185,8 @@ init() { } list() { - for i in "$VCSH_REPO_D"/*.git; do - echo $(basename "$i" .git) + for repo in "$VCSH_REPO_D"/*.git; do + [ -d "$repo" ] && [ -r "$repo" ] && echo $(basename "$repo" .git) done } @@ -164,7 +216,7 @@ rename() { run() { hook pre-run use - $VCSH_EXTERNAL_COMMAND + "$@" hook post-run } @@ -234,6 +286,9 @@ if [ "$1" = 'clone' ]; then [ -n "$3" ] && VCSH_REPO_NAME="$3" || VCSH_REPO_NAME=$(basename "$GIT_REMOTE" .git) export VCSH_REPO_NAME export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" +elif [ "$1" = 'version' ]; then + echo "$SELF $VERSION" + exit elif [ "$1" = 'which' ]; then [ -z "$2" ] && fatal "$1: please specify a filename" 1 [ -n "$3" ] && fatal "$1: too many parameters" 1 @@ -254,7 +309,7 @@ elif [ "$1" = 'delete' ] || 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 && export VCSH_EXTERNAL_COMMAND="$*" + [ "$VCSH_COMMAND" = 'run' ] && shift 2 [ "$VCSH_COMMAND" = 'write-gitignore' ] elif [ "$1" = 'list' ] || [ "$1" = 'list-tracked' ]; then @@ -265,7 +320,7 @@ elif [ -n "$2" ]; then export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" [ -d $GIT_DIR ] || { help; exit 1; } shift 1 - export VCSH_EXTERNAL_COMMAND="git $*" + set -- "git" "$@" elif [ -n "$1" ]; then export VCSH_COMMAND='enter' export VCSH_REPO_NAME="$1" @@ -299,6 +354,6 @@ done verbose "$VCSH_COMMAND begin" export VCSH_COMMAND=$(echo $VCSH_COMMAND | sed 's/-/_/g') hook pre-command -$VCSH_COMMAND +$VCSH_COMMAND "$@" hook post-command verbose "$VCSH_COMMAND end, exiting"