From 00e44097d5e7112acb7decd2d606d929b2c71a2f Mon Sep 17 00:00:00 2001 From: Errietta Kostala Date: Sun, 15 Dec 2013 23:12:46 +0000 Subject: [PATCH 001/164] A few tests. --- t/000-tear-env.t | 17 +++++++++++++++ t/001-setup-env.t | 19 +++++++++++++++++ t/100-init.t | 54 +++++++++++++++++++++++++++++++++++++++++++++++ t/200-delete.t | 19 +++++++++++++++++ t/999-tear-env.t | 17 +++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 t/000-tear-env.t create mode 100644 t/001-setup-env.t create mode 100644 t/100-init.t create mode 100644 t/200-delete.t create mode 100644 t/999-tear-env.t diff --git a/t/000-tear-env.t b/t/000-tear-env.t new file mode 100644 index 00000000..afe261a8 --- /dev/null +++ b/t/000-tear-env.t @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Shell::Command; +use Test::Most; + +chdir 't' or die $!; + +if (!-d 'etc') { + plan skip_all => 'No need to tear previous env.'; +} + +ok rm_rf 'etc'; + +done_testing; diff --git a/t/001-setup-env.t b/t/001-setup-env.t new file mode 100644 index 00000000..fb59f058 --- /dev/null +++ b/t/001-setup-env.t @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::Most; + +system ("mkdir -p t/etc"); +ok !$?; + +system ("mkdir -p t/etc/.vcsh_home"); +ok !$?; + +chdir 't/etc/' or die $!; + +system ("ln -s '../../vcsh'"); +ok !$?; + +done_testing; diff --git a/t/100-init.t b/t/100-init.t new file mode 100644 index 00000000..b7268684 --- /dev/null +++ b/t/100-init.t @@ -0,0 +1,54 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Cwd 'abs_path'; +use Test::Most; + +chdir 't/etc/' or die $!; + +$ENV{'HOME'} = abs_path ('.vcsh_home'); + +my $output = `./vcsh status`; + +ok $output eq "", 'No repos set up yet.'; + +$output = `./vcsh init test1`; + +ok $output eq "Initialized empty Git repository in " . $ENV{'HOME'} . "/.config/vcsh/repo.d/test1.git/\n"; + +$output = `./vcsh status`; + +ok $output eq "test1:\n\n", 'Our new repo is there'; + +chdir $ENV{"HOME"} . '/.config/vcsh/repo.d/test1.git/' or die $!; + +ok -f 'HEAD'; +ok -d 'branches'; +ok -f 'config'; +ok -f 'description'; +ok -d 'hooks'; +ok -d 'info'; +ok -d 'objects'; +ok -d 'refs'; + +ok -f 'hooks/applypatch-msg.sample'; +ok -f 'hooks/commit-msg.sample'; +ok -f 'hooks/post-update.sample'; +ok -f 'hooks/pre-applypatch.sample'; +ok -f 'hooks/pre-commit.sample'; +ok -f 'hooks/pre-push.sample'; +ok -f 'hooks/pre-rebase.sample'; +ok -f 'hooks/prepare-commit-msg.sample'; +ok -f 'hooks/update.sample'; + +ok -f 'info/exclude'; + +ok -d 'objects/info'; +ok -d 'objects/pack'; + +ok -d 'refs/heads'; +ok -d 'refs/tags'; + +done_testing; diff --git a/t/200-delete.t b/t/200-delete.t new file mode 100644 index 00000000..cd078714 --- /dev/null +++ b/t/200-delete.t @@ -0,0 +1,19 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Cwd 'abs_path'; +use Test::Most; + +chdir 't/etc/' or die $!; + +$ENV{'HOME'} = abs_path ('.vcsh_home'); + +system ("echo 'Yes, do as I say' | ./vcsh delete test1"); + +my $output = `./vcsh status`; + +ok $output eq "", 'No repos set up anymore.'; + +done_testing; diff --git a/t/999-tear-env.t b/t/999-tear-env.t new file mode 100644 index 00000000..afe261a8 --- /dev/null +++ b/t/999-tear-env.t @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Shell::Command; +use Test::Most; + +chdir 't' or die $!; + +if (!-d 'etc') { + plan skip_all => 'No need to tear previous env.'; +} + +ok rm_rf 'etc'; + +done_testing; From dda9802233e27008cdd3206d4474be69d54a55b0 Mon Sep 17 00:00:00 2001 From: Errietta Kostala Date: Thu, 9 Jan 2014 12:15:52 +0000 Subject: [PATCH 002/164] vcsh add test --- t/300-add.t | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 t/300-add.t diff --git a/t/300-add.t b/t/300-add.t new file mode 100644 index 00000000..f16f6e1b --- /dev/null +++ b/t/300-add.t @@ -0,0 +1,32 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Cwd 'abs_path'; + +use Shell::Command; +use Test::Most; + +chdir 't/etc/' or die $!; + +$ENV{'HOME'} = abs_path ('.vcsh_home'); + +eval { + touch 'a'; +}; + +die $@ if $@; + +system ("./vcsh -d test1 add 'a'"); + +my $output = `./vcsh status`; + +diag $output; + +ok $output eq "test1: +A a +", 'Adding a file worksl'; + +done_testing; + From 9bb603de8a2a49172513c41ccc8fb4309f90bb95 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 9 Jan 2014 22:15:34 +0100 Subject: [PATCH 003/164] t/300-add.t: Disable debug mode --- t/300-add.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/300-add.t b/t/300-add.t index f16f6e1b..6c8b9cdf 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -18,7 +18,7 @@ eval { die $@ if $@; -system ("./vcsh -d test1 add 'a'"); +system ("./vcsh test1 add 'a'"); my $output = `./vcsh status`; From 8f4180366d4a5541f7042d24a1fc424b26e41bb9 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 9 Jan 2014 22:16:10 +0100 Subject: [PATCH 004/164] Move repo deletion to the end... --- t/{200-delete.t => 950-delete.t} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename t/{200-delete.t => 950-delete.t} (100%) diff --git a/t/200-delete.t b/t/950-delete.t similarity index 100% rename from t/200-delete.t rename to t/950-delete.t From 0be68e89bd73e70978436463d8c8196d1770cf24 Mon Sep 17 00:00:00 2001 From: Jeff Fein-Worton Date: Sat, 22 Feb 2014 00:33:23 -0800 Subject: [PATCH 005/164] added sample post-init --- doc/sample_hooks/post-init-add-origin | 6 ++++++ doc/sample_hooks/post-init-setup-mr | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100755 doc/sample_hooks/post-init-add-origin create mode 100755 doc/sample_hooks/post-init-setup-mr diff --git a/doc/sample_hooks/post-init-add-origin b/doc/sample_hooks/post-init-add-origin new file mode 100755 index 00000000..a3030d5f --- /dev/null +++ b/doc/sample_hooks/post-init-add-origin @@ -0,0 +1,6 @@ +#!/bin/sh + +# This adds a remote origin at $GITURL/dotfiles/$VCSH_DIRECTORY +# Assumes $GITURL is set to the base of your remote repos. + +vcsh $VCSH_DIRECTORY remote add origin $GITURL/dotfiles/$VCSH_DIRECTORY diff --git a/doc/sample_hooks/post-init-setup-mr b/doc/sample_hooks/post-init-setup-mr new file mode 100755 index 00000000..a38c0129 --- /dev/null +++ b/doc/sample_hooks/post-init-setup-mr @@ -0,0 +1,10 @@ +#!/bin/sh + +# This sets up your new repos with mr. + +cat > $HOME/.config/mr/available.d/$VCSH_DIRECTORY.vcsh << EOF +[\$HOME/.config/vcsh/repo.d/$VCSH_DIRECTORY.git] +checkout = vcsh clone $GITURL/dotfiles/$VCSH_DIRECTORY.git +EOF + +ln -s $HOME/.config/mr/available.d/$VCSH_DIRECTORY.vcsh $HOME/.config/mr/config.d/ From c2802e6be31b38797a1e8a96a7653adfa5948fc0 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 4 Mar 2014 20:32:22 +0100 Subject: [PATCH 006/164] vcsh: Default to not using ~/.gitattributes.d github: fixes richih/vcsh#111 --- vcsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index a6653fc5..fcb3aa40 100755 --- a/vcsh +++ b/vcsh @@ -77,6 +77,7 @@ fi : ${VCSH_HOOK_D:=$XDH_CONFIG_HOME/vcsh/hooks-enabled} : ${VCSH_BASE:=$HOME} : ${VCSH_GITIGNORE:=exact} +: ${VCSH_GITATTRIBUTES:=none} : ${VCSH_WORKTREE:=absolute} if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && [ ! "x$VCSH_GITIGNORE" = 'xrecursive' ]; then @@ -334,7 +335,7 @@ upgrade() { git config core.worktree "$VCSH_BASE" fi [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && git config core.excludesfile ".gitignore.d/$VCSH_REPO_NAME" - git config core.attributesfile ".gitattributes.d/$VCSH_REPO_NAME" + [ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && git config core.attributesfile ".gitattributes.d/$VCSH_REPO_NAME" git config vcsh.vcsh 'true' use [ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" @@ -500,7 +501,7 @@ check_dir() { check_dir "$VCSH_REPO_D" [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && check_dir "$VCSH_BASE/.gitignore.d" -check_dir "$VCSH_BASE/.gitattributes.d" +[ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && check_dir "$VCSH_BASE/.gitattributes.d" verbose "$VCSH_COMMAND begin" export VCSH_COMMAND=$(echo $VCSH_COMMAND | sed 's/-/_/g') From c436ac84069261ae1e7aab4db28539019aaee49b Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 6 Mar 2014 20:06:35 -0800 Subject: [PATCH 007/164] Various fixes to readme --- README.md | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 785b36ca..6a433ffb 100644 --- a/README.md +++ b/README.md @@ -121,10 +121,17 @@ myrepos is just another set of files that you cat track with `vcsh` like any other. This makes setting up any new machine a breeze. It can take literally less than five minutes to go from standard installation to fully set up system. -We suggest using [myrepos][myrepos] to manage both `vcsh` and other repositories. The -`mr` utility takes care of pulling in and pushing out new data for a variety of -version control systems. While the use of myrepos is technically optional, it will -be an integral part of the proposed system that follows. +We suggest using [myrepos][myrepos] to manage both `vcsh` and other +repositories. The `mr` utility takes care of pulling in and pushing +out new data for a variety of version control systems. While the use +of myrepos is technically optional, it will be an integral part of the +proposed system that follows. For instance, you can use +[myrepos][myrepos] to track repositories in home such as `.emacs.d`, +which `mr` can clone and update for you automatically. To do this, +just add a `mr` configuration file to `availabile.d` with a `checkout` +command to clone the repo, and set the [title] to the desired +location, e.g. `$HOME/.emacs.d`. Try the `mr register` command in an +existing repository, then view `~/.mrconfig` for an example. ## Default Directory Layout @@ -174,12 +181,15 @@ repository. This is for demonstration, only. Of course, you are more than welcome to clone from this repository and fork your own. [$XDG_CONFIG_HOME/vcsh/repo.d/zsh.git] - checkout = vcsh clone 'git://github.com/RichiH/zshrc.git' zsh + checkout = vcsh clone 'git://github.com/RichiH/zshrc.git' 'zsh' update = vcsh zsh pull push = vcsh zsh push status = vcsh zsh status gc = vcsh zsh gc + [$HOME/.emacs.d] + checkout = vcsh clone 'git://github.com/andschwa/emacs.git' '.emacs.d' + ### config.d $XDG\_CONFIG\_HOME/mr/available.d contains *all available* repositories. Only @@ -248,12 +258,12 @@ Below, you will find a few different methods for setting up vcsh: Make sure none of the following files and directories exist for your test (user). If they do, move them away for now: -* ~/.gitignore.d -* ~/.mrconfig -* $XDG\_CONFIG\_HOME/mr/available.d/mr.vcsh -* $XDG\_CONFIG\_HOME/mr/available.d/zsh.vcsh -* $XDG\_CONFIG\_HOME/mr/config.d/mr.vcsh -* $XDG\_CONFIG\_HOME/vcsh/repo.d/mr.git/ +* `~/.gitignore.d` +* `~/.mrconfig` +* `$XDG\_CONFIG\_HOME/mr/available.d/mr.vcsh` +* `$XDG\_CONFIG\_HOME/mr/available.d/zsh.vcsh` +* `$XDG\_CONFIG\_HOME/mr/config.d/mr.vcsh` +* `$XDG\_CONFIG\_HOME/vcsh/repo.d/mr.git/` All of the files are part of the template repository, the directory is where the template will be stored. @@ -293,7 +303,7 @@ Or you can do it yourself manually using the documentation on installing AUR pac If you prefer to use the devel package that installs the git HEAD version it is available [here](https://aur.archlinux.org/packages/vcsh-git/). -#### Mac OSX +#### Mac OS X Formulas are available for vcsh as well as git and myrepos through [homebrew](http://brew.sh). The vcsh formula is set to depend on myrepos, so you only need one install command: @@ -385,12 +395,10 @@ Grab my myrepos config. see below for details on how I set this up ln -s ../available.d/* . -myrepos is used to actually retrieve configs, etc +`myrepos` is used to actually retrieve configs, etc ~ % cat ~/.mrconfig [DEFAULT] - # adapt /usr/share/mr/vcsh to your system if needed - include = cat /usr/share/mr/vcsh include = cat $XDG_CONFIG_HOME/mr/config.d/* ~ % echo $XDG_CONFIG_HOME /home/richih/.config From 880e1144c97bb2a564fc1f5f358be5a1bc756841 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 6 Mar 2014 20:43:46 -0800 Subject: [PATCH 008/164] One more --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6a433ffb..41167e7c 100644 --- a/README.md +++ b/README.md @@ -395,7 +395,7 @@ Grab my myrepos config. see below for details on how I set this up ln -s ../available.d/* . -`myrepos` is used to actually retrieve configs, etc +[myrepos][myrepos] is used to actually retrieve configs, etc. ~ % cat ~/.mrconfig [DEFAULT] From 2ef5c0c8e476fb92a56cf05c72a327d47cbfbf3c Mon Sep 17 00:00:00 2001 From: Jeff Fein-Worton Date: Tue, 11 Mar 2014 22:47:27 -0700 Subject: [PATCH 009/164] Improved post-init-add-origin hook Added better help text Added error message if $GITURL unset --- doc/sample_hooks/post-init-add-origin | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/doc/sample_hooks/post-init-add-origin b/doc/sample_hooks/post-init-add-origin index a3030d5f..993f3c70 100755 --- a/doc/sample_hooks/post-init-add-origin +++ b/doc/sample_hooks/post-init-add-origin @@ -1,6 +1,18 @@ #!/bin/sh -# This adds a remote origin at $GITURL/dotfiles/$VCSH_DIRECTORY -# Assumes $GITURL is set to the base of your remote repos. +# This adds a remote origin at $GITURL/dotfiles/$VCSH_DIRECTORY which +# is helpful for creating new dotfile repositories that you plan to +# store on (e.g.) Github. +# +# You must set $GITURL in order to use this hook. For example, add the +# following to your .bashrc (or equivalent for your shell), replacing +# YOURUSERNAME with your github username: +# +# export GITURL="git@github.com:YOURUSERNAME" + +if [ -z $GITURL ]; then + echo "\$GITURL is not set; please see post-init-add-origin hook" + exit 1; +fi vcsh $VCSH_DIRECTORY remote add origin $GITURL/dotfiles/$VCSH_DIRECTORY From 989fcf277a72adee545df4105ceccd842c63c4f2 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 13 Mar 2014 22:35:16 +0100 Subject: [PATCH 010/164] Update manpage --- doc/vcsh.1.ronn | 9 +++++++++ vcsh.1 | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 56df4ed2..05da4fad 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -171,6 +171,15 @@ executed in the context of your shell. Interesting knobs you can turn: +* <$VCSH_GITATTRIBUTES>: + Can be , or any other value. + + will not maintain Git attributes in a special location. + + If set to any other value, repo-specific gitattributes files will be maintained. + + Defaults to . + * <$VCSH_GITIGNORE>: Can be , , or . diff --git a/vcsh.1 b/vcsh.1 index 967aee8c..4c77838c 100644 --- a/vcsh.1 +++ b/vcsh.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "VCSH" "1" "February 2014" "" "" +.TH "VCSH" "1" "March 2014" "" "" . .SH "NAME" \fBvcsh\fR \- Version Control System for $HOME \- multiple Git repositories in $HOME @@ -213,6 +213,19 @@ Please note that those files are sourced\. Any and all commands will be executed Interesting knobs you can turn: . .TP +\fI$VCSH_GITATTRIBUTES\fR +Can be \fInone\fR, or any other value\. +. +.IP +\fInone\fR will not maintain Git attributes in a special location\. +. +.IP +If set to any other value, repo\-specific gitattributes files will be maintained\. +. +.IP +Defaults to \fInone\fR\. +. +.TP \fI$VCSH_GITIGNORE\fR Can be \fIexact\fR, \fInone\fR, or \fIrecursive\fR\. . From 952eff91dd9817446386806e5333f8822efec9f3 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 13 Mar 2014 22:36:27 +0100 Subject: [PATCH 011/164] Release v1.20140313 The "Git won the Linux New Media Award for Outstanding contributions to Open Source" edition. --- changelog | 13 +++++++++++++ vcsh | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index dc578c6f..b5d6e781 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,16 @@ +2014-03-13 Richard Hartmann + + * Release 1.20140313 -- the "Git won a prize" edition + * Initialize repos with --shared=0600 + * Fix cloning from some spefically-named remotes + * Support custom gitattribute files + * Support filenames with whitespace in gitignores + * Pass out git exit codes + * Switch to static, pre-built manpage + * Improve documentation + * Use more portable find(1) syntax + * Various minor improvements + 2013-12-29 Richard Hartmann * Release 1.20131229 diff --git a/vcsh b/vcsh index 4761a534..d39f4158 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # 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' +VERSION='1.20140313' SELF=$(basename $0) fatal() { From 5b3ee2feb9b93ebee541cba407b6352a58c68bbf Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 16 Mar 2014 20:32:13 +0100 Subject: [PATCH 012/164] Add copyright blurb for https://github.com/RichiH/vcsh/issues/121 --- tools/list_CONTRIBUTORS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/list_CONTRIBUTORS b/tools/list_CONTRIBUTORS index 2954f583..1b88451d 100755 --- a/tools/list_CONTRIBUTORS +++ b/tools/list_CONTRIBUTORS @@ -1,5 +1,11 @@ #!/bin/sh +# This program is licensed under the GNU GPL version 2 or later. +# (c) Richard "RichiH" Hartmann , 2012-2014 +# For details, see LICENSE. To submit patches, you have to agree to +# license your code under the GNU GPL version 2 or later. + + echo 'Alphabetical list of surnames of everyone who ever committed to this repository. Auto-generated from tools/list_CONTRIBUTORS. ' From 805c55368c98b24b381e947e0b825be96f0d46c4 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 16 Mar 2014 20:32:42 +0100 Subject: [PATCH 013/164] vcsh: Update copyright information --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d39f4158..1e9f2d5f 100755 --- a/vcsh +++ b/vcsh @@ -1,7 +1,7 @@ #!/bin/sh # This program is licensed under the GNU GPL version 2 or later. -# (c) Richard "RichiH" Hartmann , 2011-2013 +# (c) Richard "RichiH" Hartmann , 2011-2014 # For details, see LICENSE. To submit patches, you have to agree to # license your code under the GNU GPL version 2 or later. From 4f6ad732e3d62523eef96dedf63179cdaf54f3ed Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 16 Mar 2014 21:27:25 +0100 Subject: [PATCH 014/164] CONTRIBUTORS: Update --- CONTRIBUTORS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index cbb144ac..f042ac70 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1,10 +1,12 @@ Alphabetical list of surnames of everyone who ever committed to this repository. Auto-generated from tools/list_CONTRIBUTORS. +Skurikhin Alexander Eric Bouchut Dridi Boukelmoune Rob Cornish Vincent Demeester +Jeff Fein-Worton Thomas Ferris Nicolaisen martin f. krafft Alessandro Ghedini @@ -20,7 +22,9 @@ Evan Pitstick Dieter Plaetinck Corey Quinn Pavlos Ratis +Dewey Sasser Gernot Schulz +Andrew Schwartzmeyer Dato Simó Alexander Skurikhin Jonathan Sternberg From 3e809e23d131e70e1edb2f0bcddb69943638f069 Mon Sep 17 00:00:00 2001 From: Thomas Ferris Nicolaisen Date: Sun, 23 Mar 2014 19:53:29 +0100 Subject: [PATCH 015/164] Fix a typo and some casing --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 41167e7c..0fc717a5 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ vcsh - Version Control System for $HOME - multiple Git repositories in $HOME # Index -1. [30 second howto](#30-second-howto) +1. [30 Second How-to](#30-second-how-to) 2. [Introduction](#introduction) -3. [Usage Exmaples](#usage-examples) +3. [Usage Examples](#usage-examples) 4. [Overview](#overview) 5. [Getting Started](#getting-started) 6. [Contact](#contact) -# 30 second howto +# 30 Second How-to While it may appear that there's an overwhelming amount of documentation and while the explanation of the concepts behind `vcsh` needs to touch a few gory From 4e58175e1b848f2f632b66571586d8bb70e2fa64 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 24 Mar 2014 10:25:41 +0100 Subject: [PATCH 016/164] Move docs to doc/ --- INSTALL.md => doc/INSTALL.md | 0 PACKAGING.md => doc/PACKAGING.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename INSTALL.md => doc/INSTALL.md (100%) rename PACKAGING.md => doc/PACKAGING.md (100%) diff --git a/INSTALL.md b/doc/INSTALL.md similarity index 100% rename from INSTALL.md rename to doc/INSTALL.md diff --git a/PACKAGING.md b/doc/PACKAGING.md similarity index 100% rename from PACKAGING.md rename to doc/PACKAGING.md From dee87ae899b1d44640a42f2b85027242a0744704 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 24 Mar 2014 14:42:43 +0100 Subject: [PATCH 017/164] README.md: Move into doc/; put in tiny one in place Hopefully, this makes vcsh less scary --- README.md | 402 +----------------------------------------- doc/README.md | 476 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 477 insertions(+), 401 deletions(-) create mode 100644 doc/README.md diff --git a/README.md b/README.md index 0fc717a5..e0a1c583 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,7 @@ vcsh - Version Control System for $HOME - multiple Git repositories in $HOME 1. [30 Second How-to](#30-second-how-to) 2. [Introduction](#introduction) -3. [Usage Examples](#usage-examples) -4. [Overview](#overview) -5. [Getting Started](#getting-started) -6. [Contact](#contact) +3. [Contact](#contact) # 30 Second How-to @@ -61,403 +58,6 @@ All slides, videos, and further information can be found [on the author's talk page][talks]. -# Usage Examples - -There are three different ways to interact with `vcsh` repositories; this -section will only show the simplest and easiest way. - -Certain more advanced use cases require the other two ways, but don't worry -about this for now. If you never even bother playing with the other two -modes you will still be fine. - -`vcsh enter` and `vcsh run` will be covered in later sections. - - -| Task | Command | -| ----------------------------------------------------- | ------------------------------------------------- | -| _Initialize a new repository called "vim"_ | `vcsh init vim` | -| _Clone an existing repository_ | `vcsh clone ` | -| _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 ` | -| | `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 - -## From zero to vcsh - -You put a lot of effort into your configuration and want to both protect and -distribute this configuration. - -Most people who decide to put their dotfiles under version control start with a -single repository in `$HOME`, adding all their dotfiles (and possibly more) -to it. This works, of course, but can become a nuisance as soon as you try to -manage more than one host. - -The next logical step is to create single-purpose repositories in, for example, -`~/.dotfiles` and to create symbolic links into `$HOME`. This gives you the -flexibility to check out only certain repositories on different hosts. The -downsides of this approach are the necessary manual steps of cloning and -symlinking the individual repositories. - -`vcsh` takes this approach one step further. It enables single-purpose -repositories and stores them in a hidden directory. However, it does not create -symbolic links in `$HOME`; it puts the actual files right into `$HOME`. - -As `vcsh` allows you to put an arbitrary number of distinct repositories into -your `$HOME`, you will end up with a lot of repositories very quickly. - -`vcsh` was designed with [myrepos][myrepos], a tool to manage Multiple -Repositories, in mind and the two integrate very nicely. The myrepos tool -(`mr`) has native support for `vcsh` repositories and the configuration for -myrepos is just another set of files that you cat track with `vcsh` like any -other. This makes setting up any new machine a breeze. It can take literally -less than five minutes to go from standard installation to fully set up system. - -We suggest using [myrepos][myrepos] to manage both `vcsh` and other -repositories. The `mr` utility takes care of pulling in and pushing -out new data for a variety of version control systems. While the use -of myrepos is technically optional, it will be an integral part of the -proposed system that follows. For instance, you can use -[myrepos][myrepos] to track repositories in home such as `.emacs.d`, -which `mr` can clone and update for you automatically. To do this, -just add a `mr` configuration file to `availabile.d` with a `checkout` -command to clone the repo, and set the [title] to the desired -location, e.g. `$HOME/.emacs.d`. Try the `mr register` command in an -existing repository, then view `~/.mrconfig` for an example. - -## Default Directory Layout - -To illustrate, this is what a possible directory structure looks like. - - $HOME - |-- $XDG_CONFIG_HOME (defaults to $HOME/.config) - | |-- mr - | | |-- available.d - | | | |-- zsh.vcsh - | | | |-- gitconfigs.vcsh - | | | |-- lftp.vcsh - | | | |-- offlineimap.vcsh - | | | |-- s3cmd.vcsh - | | | |-- tmux.vcsh - | | | |-- vim.vcsh - | | | |-- vimperator.vcsh - | | | `-- snippets.git - | | `-- config.d - | | |-- zsh.vcsh -> ../available.d/zsh.vcsh - | | |-- gitconfigs.vcsh -> ../available.d/gitconfigs.vcsh - | | |-- tmux.vcsh -> ../available.d/tmux.vcsh - | | `-- vim.vcsh -> ../available.d/vim.vcsh - | `-- vcsh - | |-- config - | `-- repo.d - | |-- zsh.git -----------+ - | |-- gitconfigs.git | - | |-- tmux.git | - | `-- vim.git | - |-- [...] | - |-- .zshrc <----------------------+ - |-- .gitignore.d - | `-- zsh - |-- .mrconfig - `-- .mrtrust - -### available.d - -The files you see in $XDG\_CONFIG\_HOME/mr/available.d are myrepos -configuration files that contain the commands to manage (checkout, update -etc.) a single repository. vcsh repo configs end in .vcsh, git configs end -in .git, etc. This is optional and your preference. For example, this is -what a zsh.vcsh with read-only access to my zshrc repo looks likes. I.e. in -this specific example, push can not work as you will be using the author's -repository. This is for demonstration, only. Of course, you are more than -welcome to clone from this repository and fork your own. - - [$XDG_CONFIG_HOME/vcsh/repo.d/zsh.git] - checkout = vcsh clone 'git://github.com/RichiH/zshrc.git' 'zsh' - update = vcsh zsh pull - push = vcsh zsh push - status = vcsh zsh status - gc = vcsh zsh gc - - [$HOME/.emacs.d] - checkout = vcsh clone 'git://github.com/andschwa/emacs.git' '.emacs.d' - -### config.d - -$XDG\_CONFIG\_HOME/mr/available.d contains *all available* repositories. Only -files/links present in mr/config.d, however, will be used by myrepos. That means -that in this example, only the zsh, gitconfigs, tmux and vim repositories will -be checked out. A simple `mr update` run in $HOME will clone or update those -four repositories listed in config.d. - -### ~/.mrconfig - -Finally, ~/.mrconfig will tie together all those single files which will allow -you to conveniently run `mr up` etc. to manage all repositories. It looks like -this: - - [DEFAULT] - include = cat ${XDG_CONFIG_HOME:-$HOME/.config}/mr/config.d/* - -### repo.d - -$XDG\_CONFIG\_HOME/vcsh/repo.d is the directory where all git repositories which -are under vcsh's control are located. Since their working trees are configured -to be in $HOME, the files contained in those repositories will be put in $HOME -directly. - -Of course, [myrepos][myrepos] will work with this layout if configured according to -this document (see above). - -vcsh will check if any file it would want to create exists. If it exists, vcsh -will throw a warning and exit. Move away your old config and try again. -Optionally, merge your local and your global configs afterwards and push with -`vcsh foo push`. - -## Moving into a New Host - -To illustrate further, the following steps could move your desired -configuration to a new host. - -1. Clone the myrepos repository (containing available.d, config.d etc.); for - example: `vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr` -2. Choose your repositories by linking them in config.d (or go with the default - you may have already configured by adding symlinks to git). -3. Run myrepos to clone the repositories: `cd; mr update`. -4. Done. - -Hopefully the above could help explain how this approach saves time by - -1. making it easy to manage, clone and update a large number of repositories - (thanks to myrepos) and -2. making it unnecessary to create symbolic links in $HOME (thanks to vcsh). - -If you want to give vcsh a try, follow the instructions below. - - -# Getting Started - -Below, you will find a few different methods for setting up vcsh: - -1. The Template Way -2. The Steal-from-Template Way -3. The Manual Way - -### The Template Way - -#### Prerequisites - -Make sure none of the following files and directories exist for your test -(user). If they do, move them away for now: - -* `~/.gitignore.d` -* `~/.mrconfig` -* `$XDG\_CONFIG\_HOME/mr/available.d/mr.vcsh` -* `$XDG\_CONFIG\_HOME/mr/available.d/zsh.vcsh` -* `$XDG\_CONFIG\_HOME/mr/config.d/mr.vcsh` -* `$XDG\_CONFIG\_HOME/vcsh/repo.d/mr.git/` - -All of the files are part of the template repository, the directory is where -the template will be stored. - -### Install vcsh - -#### Debian - -If you are using Debian Squeeze, you will need to enable backports and the -package name for myrepos will be 'mr'. - -From Wheezy onwards, you can install both directly: - - apt-get install myrepos vcsh - -#### Gentoo - -To install vcsh in Gentoo Linux just give the following command as root: - - emerge dev-vcs/vcsh - -Note the portage package for myrepos still has the old project name: - - emerge dev-vcs/mr - -#### Arch Linux - -vcsh is available via this [AUR](https://aur.archlinux.org/packages/vcsh/) -package. Likewise myrepos is available [here](https://aur.archlinux.org/packages/myrepos/). -You may install both useing your favorite AUR helper. e.g. with yaourt: - - yaourt -Sya myrepos vcsh - -Or you can do it yourself manually using the documentation on installing AUR packages -[on Arch's wiki](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages). - -If you prefer to use the devel package that installs the git HEAD version it -is available [here](https://aur.archlinux.org/packages/vcsh-git/). - -#### Mac OS X - -Formulas are available for vcsh as well as git and myrepos through [homebrew](http://brew.sh). The -vcsh formula is set to depend on myrepos, so you only need one install command: - - brew install vcsh - -#### From source - -To install the latest version from git: - - # choose a location for your checkout - mkdir -p ~/work/git - cd ~/work/git - git clone git://github.com/RichiH/vcsh.git - cd vcsh - sudo ln -s vcsh /usr/local/bin # or add it to your PATH - -For myrepos: - - # use checkout location from above - cd ~/work/git - git clone git://myrepos.branchable.com/ myrepos - cd myrepos - make install - -#### Clone the Template - - vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr - -#### Enable Your Test Repository - - mv ~/.zsh ~/zsh.bak - mv ~/.zshrc ~/zshrc.bak - cd $XDG_CONFIG_HOME/mr/config.d/ - ln -s ../available.d/zsh.vcsh . # link, and thereby enable, the zsh repository - cd - mr up - -#### Set Up Your Own Repositories - -Now, it's time to edit the template config and fill it with your own remotes: - - vim $XDG_CONFIG_HOME/mr/available.d/mr.vcsh - vim $XDG_CONFIG_HOME/mr/available.d/zsh.vcsh - -And then create your own stuff: - - vcsh init foo - vcsh foo add bar baz quux - vcsh foo remote add origin git://quuux - vcsh foo commit - vcsh foo push - - cp $XDG_CONFIG_HOME/mr/available.d/mr.vcsh $XDG_CONFIG_HOME/mr/available.d/foo.vcsh - vim $XDG_CONFIG_HOME/mr/available.d/foo.vcsh # add your own repo - -Done! - -### The Steal-from-Template Way - -You're welcome to clone the example repository: - - vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr - # make sure 'include = cat /usr/share/mr/vcsh' points to an exiting file - vim .mrconfig - -Look around in the clone. It should be reasonably simple to understand. If not, -poke me, RichiH, on Freenode (query) or OFTC (#vcs-home). - - -### The Manual Way - -This is how my old setup procedure looked like. Adapt it to your own style or -copy mine verbatim, either is fine. - - # Create workspace - mkdir -p ~/work/git - cd !$ - - # Clone vcsh and make it available - git clone git://github.com/RichiH/vcsh.git vcsh - sudo ln -s ~/work/git/vcsh/vcsh /usr/bin/local - hash -r - -Grab my myrepos config. see below for details on how I set this up - - vcsh clone ssh:///mr.git - cd $XDG_CONFIG_HOME/mr/config.d/ - ln -s ../available.d/* . - - -[myrepos][myrepos] is used to actually retrieve configs, etc. - - ~ % cat ~/.mrconfig - [DEFAULT] - include = cat $XDG_CONFIG_HOME/mr/config.d/* - ~ % echo $XDG_CONFIG_HOME - /home/richih/.config - ~ % ls $XDG_CONFIG_HOME/mr/available.d # random selection of my repos - git-annex gitk.vcsh git.vcsh ikiwiki mr.vcsh reportbug.vcsh snippets.git wget.vcsh zsh.vcsh - ~ % - # then simply ln -s whatever you want on your local machine from - # $XDG_CONFIG_HOME/mr/available.d to $XDG_CONFIG_HOME/mr/config.d - ~ % cd - ~ % mr -j 5 up - - -# myrepos usage ; will be factored out & rewritten - -### Keeping repositories Up-to-Date - -This is the beauty of it all. Once you are set up, just run: - - mr up - mr push - -Neat. - -### Making Changes - -After you have made some changes, for which you would normally use `git add` -and `git commit`, use the vcsh wrapper (like above): - - vcsh foo add bar baz quux - vcsh foo commit - vcsh foo push - -### Using vcsh without myrepos - -vcsh encourages you to use [myrepos][myrepos]. It helps you manage a large number of -repositories by running the necessary vcsh commands for you. You may choose not -to use myrepos, in which case you will have to run those commands manually or by -other means. - - -To initialize a new repository: `vcsh init zsh` - -To clone a repository: `vcsh clone ssh:///zsh.git` - -To interact with a repository, use the regular Git commands, but prepend them -with `vcsh run $repository_name`. For example: - - vcsh zsh status - vcsh zsh add .zshrc - vcsh zsh commit - -Obviously, without myrepos keeping repositories up-to-date, it will have to be done -manually. Alternatively, you could try something like this: - - for repo in `vcsh list`; do - vcsh run $repo git pull; - done - - # Contact There are several ways to get in touch with the author and a small but committed diff --git a/doc/README.md b/doc/README.md new file mode 100644 index 00000000..0fc717a5 --- /dev/null +++ b/doc/README.md @@ -0,0 +1,476 @@ +vcsh - Version Control System for $HOME - multiple Git repositories in $HOME + + +# Index + +1. [30 Second How-to](#30-second-how-to) +2. [Introduction](#introduction) +3. [Usage Examples](#usage-examples) +4. [Overview](#overview) +5. [Getting Started](#getting-started) +6. [Contact](#contact) + + +# 30 Second How-to + +While it may appear that there's an overwhelming amount of documentation and +while the explanation of the concepts behind `vcsh` needs to touch a few gory +details of `git` internals, getting started with `vcsh` is extremely simple. + +Let's say you want to version control your `vim` configuration: + + vcsh init vim + vcsh vim add ~/.vimrc ~/.vim + vcsh vim commit -m 'Initial commit of my Vim configuration' + # optionally push your files to a remote + vcsh vim remote add origin + vcsh vim push -u origin master + # from now on you can push additional commits like this + vcsh vim push + +If all that looks a _lot_ like standard `git`, that's no coincidence; it's +a design feature. + + +# Introduction + +[vcsh][vcsh] allows you to maintain several Git repositories in one single +directory. They all maintain their working trees without clobbering each other +or interfering otherwise. By default, all Git repositories maintained via +`vcsh` store the actual files in `$HOME` but you can override this setting if +you want to. + +All this means that you can have one repository per application or application +family, i.e. `zsh`, `vim`, `ssh`, etc. This, in turn, allows you to clone +custom sets of configurations onto different machines or even for different +users; picking and mixing which configurations you want to use where. +For example, you may not need to have your `mplayer` configuration on a server +or available to root and you may want to maintain different configuration for +`ssh` on your personal and your work machines. + +A lot of modern UNIX-based systems offer packages for `vcsh`. In case yours +does not read `INSTALL.md` for install instructions or `PACKAGING.md` to create +a package, yourself. If you do end up packaging `vcsh` please let us know so we +can give you your own packaging branch in the upstream repository. + +## Talks + +Some people found it useful to look at slides and videos explaining how `vcsh` +works instead of working through the docs. +All slides, videos, and further information can be found +[on the author's talk page][talks]. + + +# Usage Examples + +There are three different ways to interact with `vcsh` repositories; this +section will only show the simplest and easiest way. + +Certain more advanced use cases require the other two ways, but don't worry +about this for now. If you never even bother playing with the other two +modes you will still be fine. + +`vcsh enter` and `vcsh run` will be covered in later sections. + + +| Task | Command | +| ----------------------------------------------------- | ------------------------------------------------- | +| _Initialize a new repository called "vim"_ | `vcsh init vim` | +| _Clone an existing repository_ | `vcsh clone ` | +| _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 ` | +| | `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 + +## From zero to vcsh + +You put a lot of effort into your configuration and want to both protect and +distribute this configuration. + +Most people who decide to put their dotfiles under version control start with a +single repository in `$HOME`, adding all their dotfiles (and possibly more) +to it. This works, of course, but can become a nuisance as soon as you try to +manage more than one host. + +The next logical step is to create single-purpose repositories in, for example, +`~/.dotfiles` and to create symbolic links into `$HOME`. This gives you the +flexibility to check out only certain repositories on different hosts. The +downsides of this approach are the necessary manual steps of cloning and +symlinking the individual repositories. + +`vcsh` takes this approach one step further. It enables single-purpose +repositories and stores them in a hidden directory. However, it does not create +symbolic links in `$HOME`; it puts the actual files right into `$HOME`. + +As `vcsh` allows you to put an arbitrary number of distinct repositories into +your `$HOME`, you will end up with a lot of repositories very quickly. + +`vcsh` was designed with [myrepos][myrepos], a tool to manage Multiple +Repositories, in mind and the two integrate very nicely. The myrepos tool +(`mr`) has native support for `vcsh` repositories and the configuration for +myrepos is just another set of files that you cat track with `vcsh` like any +other. This makes setting up any new machine a breeze. It can take literally +less than five minutes to go from standard installation to fully set up system. + +We suggest using [myrepos][myrepos] to manage both `vcsh` and other +repositories. The `mr` utility takes care of pulling in and pushing +out new data for a variety of version control systems. While the use +of myrepos is technically optional, it will be an integral part of the +proposed system that follows. For instance, you can use +[myrepos][myrepos] to track repositories in home such as `.emacs.d`, +which `mr` can clone and update for you automatically. To do this, +just add a `mr` configuration file to `availabile.d` with a `checkout` +command to clone the repo, and set the [title] to the desired +location, e.g. `$HOME/.emacs.d`. Try the `mr register` command in an +existing repository, then view `~/.mrconfig` for an example. + +## Default Directory Layout + +To illustrate, this is what a possible directory structure looks like. + + $HOME + |-- $XDG_CONFIG_HOME (defaults to $HOME/.config) + | |-- mr + | | |-- available.d + | | | |-- zsh.vcsh + | | | |-- gitconfigs.vcsh + | | | |-- lftp.vcsh + | | | |-- offlineimap.vcsh + | | | |-- s3cmd.vcsh + | | | |-- tmux.vcsh + | | | |-- vim.vcsh + | | | |-- vimperator.vcsh + | | | `-- snippets.git + | | `-- config.d + | | |-- zsh.vcsh -> ../available.d/zsh.vcsh + | | |-- gitconfigs.vcsh -> ../available.d/gitconfigs.vcsh + | | |-- tmux.vcsh -> ../available.d/tmux.vcsh + | | `-- vim.vcsh -> ../available.d/vim.vcsh + | `-- vcsh + | |-- config + | `-- repo.d + | |-- zsh.git -----------+ + | |-- gitconfigs.git | + | |-- tmux.git | + | `-- vim.git | + |-- [...] | + |-- .zshrc <----------------------+ + |-- .gitignore.d + | `-- zsh + |-- .mrconfig + `-- .mrtrust + +### available.d + +The files you see in $XDG\_CONFIG\_HOME/mr/available.d are myrepos +configuration files that contain the commands to manage (checkout, update +etc.) a single repository. vcsh repo configs end in .vcsh, git configs end +in .git, etc. This is optional and your preference. For example, this is +what a zsh.vcsh with read-only access to my zshrc repo looks likes. I.e. in +this specific example, push can not work as you will be using the author's +repository. This is for demonstration, only. Of course, you are more than +welcome to clone from this repository and fork your own. + + [$XDG_CONFIG_HOME/vcsh/repo.d/zsh.git] + checkout = vcsh clone 'git://github.com/RichiH/zshrc.git' 'zsh' + update = vcsh zsh pull + push = vcsh zsh push + status = vcsh zsh status + gc = vcsh zsh gc + + [$HOME/.emacs.d] + checkout = vcsh clone 'git://github.com/andschwa/emacs.git' '.emacs.d' + +### config.d + +$XDG\_CONFIG\_HOME/mr/available.d contains *all available* repositories. Only +files/links present in mr/config.d, however, will be used by myrepos. That means +that in this example, only the zsh, gitconfigs, tmux and vim repositories will +be checked out. A simple `mr update` run in $HOME will clone or update those +four repositories listed in config.d. + +### ~/.mrconfig + +Finally, ~/.mrconfig will tie together all those single files which will allow +you to conveniently run `mr up` etc. to manage all repositories. It looks like +this: + + [DEFAULT] + include = cat ${XDG_CONFIG_HOME:-$HOME/.config}/mr/config.d/* + +### repo.d + +$XDG\_CONFIG\_HOME/vcsh/repo.d is the directory where all git repositories which +are under vcsh's control are located. Since their working trees are configured +to be in $HOME, the files contained in those repositories will be put in $HOME +directly. + +Of course, [myrepos][myrepos] will work with this layout if configured according to +this document (see above). + +vcsh will check if any file it would want to create exists. If it exists, vcsh +will throw a warning and exit. Move away your old config and try again. +Optionally, merge your local and your global configs afterwards and push with +`vcsh foo push`. + +## Moving into a New Host + +To illustrate further, the following steps could move your desired +configuration to a new host. + +1. Clone the myrepos repository (containing available.d, config.d etc.); for + example: `vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr` +2. Choose your repositories by linking them in config.d (or go with the default + you may have already configured by adding symlinks to git). +3. Run myrepos to clone the repositories: `cd; mr update`. +4. Done. + +Hopefully the above could help explain how this approach saves time by + +1. making it easy to manage, clone and update a large number of repositories + (thanks to myrepos) and +2. making it unnecessary to create symbolic links in $HOME (thanks to vcsh). + +If you want to give vcsh a try, follow the instructions below. + + +# Getting Started + +Below, you will find a few different methods for setting up vcsh: + +1. The Template Way +2. The Steal-from-Template Way +3. The Manual Way + +### The Template Way + +#### Prerequisites + +Make sure none of the following files and directories exist for your test +(user). If they do, move them away for now: + +* `~/.gitignore.d` +* `~/.mrconfig` +* `$XDG\_CONFIG\_HOME/mr/available.d/mr.vcsh` +* `$XDG\_CONFIG\_HOME/mr/available.d/zsh.vcsh` +* `$XDG\_CONFIG\_HOME/mr/config.d/mr.vcsh` +* `$XDG\_CONFIG\_HOME/vcsh/repo.d/mr.git/` + +All of the files are part of the template repository, the directory is where +the template will be stored. + +### Install vcsh + +#### Debian + +If you are using Debian Squeeze, you will need to enable backports and the +package name for myrepos will be 'mr'. + +From Wheezy onwards, you can install both directly: + + apt-get install myrepos vcsh + +#### Gentoo + +To install vcsh in Gentoo Linux just give the following command as root: + + emerge dev-vcs/vcsh + +Note the portage package for myrepos still has the old project name: + + emerge dev-vcs/mr + +#### Arch Linux + +vcsh is available via this [AUR](https://aur.archlinux.org/packages/vcsh/) +package. Likewise myrepos is available [here](https://aur.archlinux.org/packages/myrepos/). +You may install both useing your favorite AUR helper. e.g. with yaourt: + + yaourt -Sya myrepos vcsh + +Or you can do it yourself manually using the documentation on installing AUR packages +[on Arch's wiki](https://wiki.archlinux.org/index.php/Arch_User_Repository#Installing_packages). + +If you prefer to use the devel package that installs the git HEAD version it +is available [here](https://aur.archlinux.org/packages/vcsh-git/). + +#### Mac OS X + +Formulas are available for vcsh as well as git and myrepos through [homebrew](http://brew.sh). The +vcsh formula is set to depend on myrepos, so you only need one install command: + + brew install vcsh + +#### From source + +To install the latest version from git: + + # choose a location for your checkout + mkdir -p ~/work/git + cd ~/work/git + git clone git://github.com/RichiH/vcsh.git + cd vcsh + sudo ln -s vcsh /usr/local/bin # or add it to your PATH + +For myrepos: + + # use checkout location from above + cd ~/work/git + git clone git://myrepos.branchable.com/ myrepos + cd myrepos + make install + +#### Clone the Template + + vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr + +#### Enable Your Test Repository + + mv ~/.zsh ~/zsh.bak + mv ~/.zshrc ~/zshrc.bak + cd $XDG_CONFIG_HOME/mr/config.d/ + ln -s ../available.d/zsh.vcsh . # link, and thereby enable, the zsh repository + cd + mr up + +#### Set Up Your Own Repositories + +Now, it's time to edit the template config and fill it with your own remotes: + + vim $XDG_CONFIG_HOME/mr/available.d/mr.vcsh + vim $XDG_CONFIG_HOME/mr/available.d/zsh.vcsh + +And then create your own stuff: + + vcsh init foo + vcsh foo add bar baz quux + vcsh foo remote add origin git://quuux + vcsh foo commit + vcsh foo push + + cp $XDG_CONFIG_HOME/mr/available.d/mr.vcsh $XDG_CONFIG_HOME/mr/available.d/foo.vcsh + vim $XDG_CONFIG_HOME/mr/available.d/foo.vcsh # add your own repo + +Done! + +### The Steal-from-Template Way + +You're welcome to clone the example repository: + + vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr + # make sure 'include = cat /usr/share/mr/vcsh' points to an exiting file + vim .mrconfig + +Look around in the clone. It should be reasonably simple to understand. If not, +poke me, RichiH, on Freenode (query) or OFTC (#vcs-home). + + +### The Manual Way + +This is how my old setup procedure looked like. Adapt it to your own style or +copy mine verbatim, either is fine. + + # Create workspace + mkdir -p ~/work/git + cd !$ + + # Clone vcsh and make it available + git clone git://github.com/RichiH/vcsh.git vcsh + sudo ln -s ~/work/git/vcsh/vcsh /usr/bin/local + hash -r + +Grab my myrepos config. see below for details on how I set this up + + vcsh clone ssh:///mr.git + cd $XDG_CONFIG_HOME/mr/config.d/ + ln -s ../available.d/* . + + +[myrepos][myrepos] is used to actually retrieve configs, etc. + + ~ % cat ~/.mrconfig + [DEFAULT] + include = cat $XDG_CONFIG_HOME/mr/config.d/* + ~ % echo $XDG_CONFIG_HOME + /home/richih/.config + ~ % ls $XDG_CONFIG_HOME/mr/available.d # random selection of my repos + git-annex gitk.vcsh git.vcsh ikiwiki mr.vcsh reportbug.vcsh snippets.git wget.vcsh zsh.vcsh + ~ % + # then simply ln -s whatever you want on your local machine from + # $XDG_CONFIG_HOME/mr/available.d to $XDG_CONFIG_HOME/mr/config.d + ~ % cd + ~ % mr -j 5 up + + +# myrepos usage ; will be factored out & rewritten + +### Keeping repositories Up-to-Date + +This is the beauty of it all. Once you are set up, just run: + + mr up + mr push + +Neat. + +### Making Changes + +After you have made some changes, for which you would normally use `git add` +and `git commit`, use the vcsh wrapper (like above): + + vcsh foo add bar baz quux + vcsh foo commit + vcsh foo push + +### Using vcsh without myrepos + +vcsh encourages you to use [myrepos][myrepos]. It helps you manage a large number of +repositories by running the necessary vcsh commands for you. You may choose not +to use myrepos, in which case you will have to run those commands manually or by +other means. + + +To initialize a new repository: `vcsh init zsh` + +To clone a repository: `vcsh clone ssh:///zsh.git` + +To interact with a repository, use the regular Git commands, but prepend them +with `vcsh run $repository_name`. For example: + + vcsh zsh status + vcsh zsh add .zshrc + vcsh zsh commit + +Obviously, without myrepos keeping repositories up-to-date, it will have to be done +manually. Alternatively, you could try something like this: + + for repo in `vcsh list`; do + vcsh run $repo git pull; + done + + +# Contact + +There are several ways to get in touch with the author and a small but committed +community around the general idea of version controlling your (digital) life. + +* IRC: #vcs-home on irc.oftc.net + +* Mailing list: [http://lists.madduck.net/listinfo/vcs-home][vcs-home-list] + +* Pull requests or issues on [https://github.com/RichiH/vcsh][vcsh] + + +[myrepos]: http://myrepos.branchable.com/ +[talks]: http://richardhartmann.de/talks/ +[vcsh]: https://github.com/RichiH/vcsh +[vcs-home-list]: http://lists.madduck.net/listinfo/vcs-home From 52b7bf56b3e6719549d2da897dd8b0a250edda80 Mon Sep 17 00:00:00 2001 From: Thomas Ferris Nicolaisen Date: Mon, 24 Mar 2014 15:30:09 +0100 Subject: [PATCH 018/164] Link to doc files GitHub markdown supports linking to relative files. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e0a1c583..d3dca9d0 100644 --- a/README.md +++ b/README.md @@ -46,9 +46,10 @@ or available to root and you may want to maintain different configuration for `ssh` on your personal and your work machines. A lot of modern UNIX-based systems offer packages for `vcsh`. In case yours -does not read `INSTALL.md` for install instructions or `PACKAGING.md` to create -a package, yourself. If you do end up packaging `vcsh` please let us know so we -can give you your own packaging branch in the upstream repository. +does not read [`INSTALL.md`](doc/INSTALL.md) for install instructions or +[PACKAGING.md](doc/PACKAGING.md) to create a package, yourself. If you do end +up packaging `vcsh` please let us know so we can give you your own packaging +branch in the upstream repository. ## Talks From b5a06ee258118b18985435c24a07284038f175f7 Mon Sep 17 00:00:00 2001 From: Thomas Ferris Nicolaisen Date: Mon, 24 Mar 2014 19:01:28 +0100 Subject: [PATCH 019/164] Fix ticks and commas --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d3dca9d0..763b7c46 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ or available to root and you may want to maintain different configuration for `ssh` on your personal and your work machines. A lot of modern UNIX-based systems offer packages for `vcsh`. In case yours -does not read [`INSTALL.md`](doc/INSTALL.md) for install instructions or -[PACKAGING.md](doc/PACKAGING.md) to create a package, yourself. If you do end +does not, read [INSTALL.md](doc/INSTALL.md) for install instructions or +[PACKAGING.md](doc/PACKAGING.md) to create a package yourself. If you do end up packaging `vcsh` please let us know so we can give you your own packaging branch in the upstream repository. From cb24803b0d99ba0ececdb9906ec15af24be1e381 Mon Sep 17 00:00:00 2001 From: Thomas Ferris Nicolaisen Date: Tue, 25 Mar 2014 22:44:10 +0100 Subject: [PATCH 020/164] Suggest shorter form of vcsh pull --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 1e9f2d5f..6e18e16b 100755 --- a/vcsh +++ b/vcsh @@ -161,7 +161,7 @@ clone() { done [ "$VCSH_CONFLICT" = '1' ]) && fatal "will stop after fetching and not try to merge! - Once this situation has been resolved, run 'vcsh run $VCSH_REPO_NAME git pull' to finish cloning." 17 + Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 git merge origin/master hook post-merge hook post-clone From c3c88c981d7e4d5cafcd69137d76de64b0236ace Mon Sep 17 00:00:00 2001 From: "G.raud" Date: Mon, 31 Mar 2014 08:07:55 +0200 Subject: [PATCH 021/164] sh-code portability improvements and fixes use export without assignment delete needless quoting (after case, in assignments, ...) add missing quoting (on the echo command line, ...) make sure 'test =' is not called with empty arguments do not call test with more than 4 arguments --- vcsh | 140 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/vcsh b/vcsh index 1e9f2d5f..18cd9e54 100755 --- a/vcsh +++ b/vcsh @@ -31,16 +31,16 @@ fatal() { # 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 + if [ x"$1" = x'-d' ] || [ x"$1" = x'--debug' ]; then set -vx VCSH_DEBUG=1 echo "debug mode on" echo "$SELF $VERSION" - elif [ "$1" = '-v' ]; then + elif [ x"$1" = x'-v' ]; then VCSH_VERBOSE=1 echo "verbose mode on" echo "$SELF $VERSION" - elif [ "$1" = '-c' ]; then + elif [ x"$1" = x'-c' ]; then VCSH_OPTION_CONFIG=$OPTARG fi shift 1 @@ -48,7 +48,7 @@ done source_all() { # Source file even if it's in $PWD and does not have any slashes in it - case "$1" in + case $1 in */*) . "$1";; *) . "$PWD/$1";; esac; @@ -57,7 +57,7 @@ source_all() { # Read configuration and set defaults if anything's not set [ -n "$VCSH_DEBUG" ] && set -vx -: ${XDG_CONFIG_HOME:=$HOME/.config} +: ${XDG_CONFIG_HOME:="$HOME/.config"} # Read configuration files if there are any [ -r "/etc/vcsh/config" ] && . "/etc/vcsh/config" @@ -73,9 +73,9 @@ fi [ -n "$VCSH_DEBUG" ] && set -vx # Read defaults -: ${VCSH_REPO_D:=$XDG_CONFIG_HOME/vcsh/repo.d} -: ${VCSH_HOOK_D:=$XDG_CONFIG_HOME/vcsh/hooks-enabled} -: ${VCSH_BASE:=$HOME} +: ${VCSH_REPO_D:="$XDG_CONFIG_HOME/vcsh/repo.d"} +: ${VCSH_HOOK_D:="$XDG_CONFIG_HOME/vcsh/hooks-enabled"} +: ${VCSH_BASE:="$HOME"} : ${VCSH_GITIGNORE:=exact} : ${VCSH_GITATTRIBUTES:=none} : ${VCSH_WORKTREE:=absolute} @@ -159,7 +159,7 @@ clone() { error "'$object' exists." && VCSH_CONFLICT=1 done - [ "$VCSH_CONFLICT" = '1' ]) && + [ x"$VCSH_CONFLICT" = x'1' ]) && fatal "will stop after fetching and not try to merge! Once this situation has been resolved, run 'vcsh run $VCSH_REPO_NAME git pull' to finish cloning." 17 git merge origin/master @@ -173,7 +173,7 @@ 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" + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git commit --untracked-files=no --quiet VCSH_COMMAND_RETURN_CODE=$? @@ -213,7 +213,7 @@ git_dir_exists() { } hook() { - for hook in $VCSH_HOOK_D/$1* $VCSH_HOOK_D/$VCSH_REPO_NAME.$1*; do + for hook in "$VCSH_HOOK_D/$1"* "$VCSH_HOOK_D/$VCSH_REPO_NAME.$1"*; do [ -x "$hook" ] || continue verbose "executing '$hook'" "$hook" @@ -232,12 +232,12 @@ init() { list() { for repo in "$VCSH_REPO_D"/*.git; do - [ -d "$repo" ] && [ -r "$repo" ] && echo $(basename "$repo" .git) + [ -d "$repo" ] && [ -r "$repo" ] && echo "$(basename "$repo" .git)" done } get_files() { - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR git ls-files } @@ -256,7 +256,7 @@ pull() { hook pre-pull for VCSH_REPO_NAME in $(list); do printf "$VCSH_REPO_NAME: " - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git pull VCSH_COMMAND_RETURN_CODE=$? @@ -269,7 +269,7 @@ push() { hook pre-push for VCSH_REPO_NAME in $(list); do printf "$VCSH_REPO_NAME: " - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git push VCSH_COMMAND_RETURN_CODE=$? @@ -289,8 +289,8 @@ rename() { # 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" + GIT_DIR=$GIT_DIR_NEW + VCSH_REPO_NAME=$VCSH_REPO_NAME_NEW # ..and clobber all old configuration upgrade } @@ -304,15 +304,15 @@ run() { } status() { - if [ ! "x$VCSH_REPO_NAME" = "x" ]; then - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" + if [ -n "$VCSH_REPO_NAME" ]; then + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git status --short --untracked-files='no' VCSH_COMMAND_RETURN_CODE=$? else for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME:" - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git status --short --untracked-files='no' VCSH_COMMAND_RETURN_CODE=$? @@ -330,7 +330,7 @@ upgrade() { # core.worktree may be absolute or relative to $GIT_DIR, depending on # user preference if [ ! "x$VCSH_WORKTREE" = 'xabsolute' ]; then - git config core.worktree $(cd $GIT_DIR && GIT_WORK_TREE="$VCSH_BASE" git rev-parse --show-cdup) + git config core.worktree "$(cd "$GIT_DIR" && GIT_WORK_TREE=$VCSH_BASE git rev-parse --show-cdup)" elif [ ! "x$VCSH_WORKTREE" = 'xrelative' ]; then git config core.worktree "$VCSH_BASE" fi @@ -345,13 +345,13 @@ upgrade() { use() { git_dir_exists - export VCSH_DIRECTORY="$VCSH_REPO_NAME" + VCSH_DIRECTORY=$VCSH_REPO_NAME; export VCSH_DIRECTORY } which() { for VCSH_REPO_NAME in $(list); do for VCSH_FILE in $(get_files); do - echo $VCSH_FILE | grep -q "$VCSH_COMMAND_PARAMETER" && echo "$VCSH_REPO_NAME: $VCSH_FILE" + echo "$VCSH_FILE" | grep -q "$VCSH_COMMAND_PARAMETER" && echo "$VCSH_REPO_NAME: $VCSH_FILE" done done | sort -u } @@ -365,13 +365,13 @@ write_gitignore() { use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 - OLDIFS="$IFS" + OLDIFS=$IFS IFS=$(printf '\n\t') gitignores=$(for file in $(git ls-files); do while true; do - echo $file; new="${file%/*}" - [ "$file" = "$new" ] && break - file="$new" + echo "$file"; new=${file%/*} + [ x"$file" = x"$new" ] && break + file=$new done; done | sort -u) @@ -387,7 +387,7 @@ write_gitignore() { { echo "$gitignore/*" | sed 's@^@!/@' >> "$tempfile" || fatal "could not write to '$tempfile'" 57; } fi done - IFS="$OLDIFS" + IFS=$OLDIFS if diff -N "$tempfile" "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" > /dev/null; then rm -f "$tempfile" || error "could not delete '$tempfile'" exit @@ -407,9 +407,9 @@ if [ ! "x$VCSH_GITIGNORE" = 'xexact' ] && [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && fatal "'\$VCSH_GITIGNORE' must equal 'exact', 'none', or 'recursive'" 1 fi -export VCSH_COMMAND="$1" +VCSH_COMMAND=$1; export VCSH_COMMAND -case "$VCSH_COMMAND" in +case $VCSH_COMMAND in clon|clo|cl) VCSH_COMMAND=clone;; commi|comm|com|co) VCSH_COMMAND=commit;; delet|dele|del|de) VCSH_COMMAND=delete;; @@ -427,57 +427,57 @@ case "$VCSH_COMMAND" in write|writ|wri|wr) VCSH_COMMAND=write-gitignore;; esac -if [ "$VCSH_COMMAND" = 'clone' ]; then +if [ x"$VCSH_COMMAND" = x'clone' ]; then [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a remote" 1 GIT_REMOTE="$2" - [ -n "$3" ] && VCSH_REPO_NAME="$3" || VCSH_REPO_NAME=$(basename "${GIT_REMOTE#*:}" .git) + [ -n "$3" ] && VCSH_REPO_NAME=$3 || VCSH_REPO_NAME=$(basename "${GIT_REMOTE#*:}" .git) [ -z "$VCSH_REPO_NAME" ] && fatal "$VCSH_COMMAND: could not determine repository name" 1 export VCSH_REPO_NAME - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR elif [ "$VCSH_COMMAND" = 'version' ]; then echo "$SELF $VERSION" git version exit -elif [ "$VCSH_COMMAND" = 'which' ]; then +elif [ x"$VCSH_COMMAND" = x'which' ]; then [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a filename" 1 [ -n "$3" ] && fatal "$VCSH_COMMAND: too many parameters" 1 - export VCSH_COMMAND_PARAMETER="$2" -elif [ "$VCSH_COMMAND" = 'delete' ] || - [ "$VCSH_COMMAND" = 'enter' ] || - [ "$VCSH_COMMAND" = 'init' ] || - [ "$VCSH_COMMAND" = 'list-tracked-by' ] || - [ "$VCSH_COMMAND" = 'rename' ] || - [ "$VCSH_COMMAND" = 'run' ] || - [ "$VCSH_COMMAND" = 'upgrade' ] || - [ "$VCSH_COMMAND" = 'write-gitignore' ]; then - [ -z $2 ] && fatal "$VCSH_COMMAND: please specify repository to work on" 1 - [ "$VCSH_COMMAND" = 'rename' -a -z "$3" ] && fatal "$VCSH_COMMAND: please specify a target name" 1 - [ "$VCSH_COMMAND" = 'run' -a -z "$3" ] && fatal "$VCSH_COMMAND: please specify a command" 1 - export VCSH_REPO_NAME="$2" - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - [ "$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 [ "$VCSH_COMMAND" = 'commit' ] || - [ "$VCSH_COMMAND" = 'list' ] || - [ "$VCSH_COMMAND" = 'list-tracked' ] || - [ "$VCSH_COMMAND" = 'pull' ] || - [ "$VCSH_COMMAND" = 'push' ]; then + VCSH_COMMAND_PARAMETER=$2; export VCSH_COMMAND_PARAMETER +elif [ x"$VCSH_COMMAND" = x'delete' ] || + [ x"$VCSH_COMMAND" = x'enter' ] || + [ x"$VCSH_COMMAND" = x'init' ] || + [ x"$VCSH_COMMAND" = x'list-tracked-by' ] || + [ x"$VCSH_COMMAND" = x'rename' ] || + [ x"$VCSH_COMMAND" = x'run' ] || + [ x"$VCSH_COMMAND" = x'upgrade' ] || + [ x"$VCSH_COMMAND" = x'write-gitignore' ]; then + [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify repository to work on" 1 + [ x"$VCSH_COMMAND" = x'rename' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a target name" 1 + [ x"$VCSH_COMMAND" = x'run' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a command" 1 + VCSH_REPO_NAME=$2; export VCSH_REPO_NAME + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + [ 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'commit' ] || + [ x"$VCSH_COMMAND" = x'list' ] || + [ x"$VCSH_COMMAND" = x'list-tracked' ] || + [ x"$VCSH_COMMAND" = x'pull' ] || + [ x"$VCSH_COMMAND" = x'push' ]; then : -elif [ "$VCSH_COMMAND" = 'status' ]; then - export VCSH_REPO_NAME="$2" +elif [ x"$VCSH_COMMAND" = x'status' ]; then + VCSH_REPO_NAME=$2; export VCSH_REPO_NAME elif [ -n "$2" ]; then - export VCSH_COMMAND='run' - export VCSH_REPO_NAME="$1" - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - [ -d $GIT_DIR ] || { help; exit 1; } + VCSH_COMMAND='run'; export VCSH_COMMAND + VCSH_REPO_NAME=$1; export VCSH_REPO_NAME + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + [ -d "$GIT_DIR" ] || { help; exit 1; } shift 1 set -- "git" "$@" elif [ -n "$VCSH_COMMAND" ]; then - export VCSH_COMMAND='enter' - export VCSH_REPO_NAME="$1" - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - [ -d $GIT_DIR ] || { help; exit 1; } + VCSH_COMMAND='enter'; export VCSH_COMMAND + VCSH_REPO_NAME=$1; export VCSH_REPO_NAME + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + [ -d "$GIT_DIR" ] || { help; exit 1; } else # $1 is empty, or 'help' help && exit @@ -485,9 +485,9 @@ fi # Did we receive a directory instead of a name? # Mangle the input to fit normal operation. -if echo $VCSH_REPO_NAME | grep -q '/'; then - export GIT_DIR=$VCSH_REPO_NAME - export VCSH_REPO_NAME=$(basename "$VCSH_REPO_NAME" .git) +if echo "$VCSH_REPO_NAME" | grep -q '/'; then + GIT_DIR=$VCSH_REPO_NAME; export GIT_DIR + VCSH_REPO_NAME=$(basename "$VCSH_REPO_NAME" .git); export VCSH_REPO_NAME fi check_dir() { @@ -507,7 +507,7 @@ check_dir "$VCSH_REPO_D" [ ! "x$VCSH_GITATTRIBUTES" = 'xnone' ] && check_dir "$VCSH_BASE/.gitattributes.d" verbose "$VCSH_COMMAND begin" -export VCSH_COMMAND=$(echo $VCSH_COMMAND | sed 's/-/_/g') +VCSH_COMMAND=$(echo "$VCSH_COMMAND" | sed 's/-/_/g'); export VCSH_COMMAND hook pre-command $VCSH_COMMAND "$@" hook post-command From 0ac61152fbc932395b73646df3d9eb76e73762a8 Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini Date: Sun, 6 Apr 2014 00:13:14 +0200 Subject: [PATCH 022/164] _vcsh: add missing commands --- _vcsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/_vcsh b/_vcsh index 47dbd9e6..a33551be 100644 --- a/_vcsh +++ b/_vcsh @@ -89,6 +89,7 @@ function _vcsh () { subcommands=( "clone:clone an existing repository" + "commit:commit in all repositories" "delete:delete an existing repository" "enter:enter repository; spawn new <\$SHELL>" "help:display help" @@ -97,8 +98,10 @@ function _vcsh () { "list-tracked:list all files tracked by vcsh" "list-tracked-by:list files tracked by a repository" "pull:pull from all vcsh remotes" + "push:push to vcsh remotes" "rename:rename a repository" "run:run command with <\$GIT_DIR> and <\$GIT_WORK_TREE> set" + "status:show statuses of all/one vcsh repositories" "upgrade:upgrade repository to currently recommended settings" "version:print version information" "which:find in name of any tracked file" From 6046fecd2148d7ab42e9c68bcc8ce04d74fe10cd Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 7 May 2014 09:07:56 +0200 Subject: [PATCH 023/164] vcsh: Make status show commits ahead/behind remote This is work in progress: * It does not deal with repos without a remote tracking branch * It does not share any info if run on a single repo * I should probably factor this out in a new function github: in response to richih/vcsh#123 --- vcsh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vcsh b/vcsh index 18cd9e54..0ec2bba8 100755 --- a/vcsh +++ b/vcsh @@ -314,6 +314,12 @@ status() { echo "$VCSH_REPO_NAME:" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use + # TODO repos without remote tracking branch error out + remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u}) + commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) + commits_ahead=$(git log ${remote_tracking_branch}.. --oneline | wc -l) + [ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits" + [ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits" git status --short --untracked-files='no' VCSH_COMMAND_RETURN_CODE=$? echo From 40e5aabecac46a43b1e68d7c8cb0a4668e780bb1 Mon Sep 17 00:00:00 2001 From: Thorsten Glaser Date: Wed, 7 May 2014 10:21:35 +0200 Subject: [PATCH 024/164] Fix format string vulnerabilities Never pass user input as first argument of printf(1), similar to how you never do that with printf(3). Signed-off-by: Thorsten Glaser --- vcsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index 31a60194..355e9fa7 100755 --- a/vcsh +++ b/vcsh @@ -255,7 +255,7 @@ list_tracked_by() { pull() { hook pre-pull for VCSH_REPO_NAME in $(list); do - printf "$VCSH_REPO_NAME: " + printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git pull @@ -268,7 +268,7 @@ pull() { push() { hook pre-push for VCSH_REPO_NAME in $(list); do - printf "$VCSH_REPO_NAME: " + printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git push From 5c7de27b054f7012b014bb21a90615e7ab567d68 Mon Sep 17 00:00:00 2001 From: Thorsten Glaser Date: Wed, 7 May 2014 10:21:35 +0200 Subject: [PATCH 025/164] Fix format string vulnerabilities Never pass user input as first argument of printf(1), similar to how you never do that with printf(3). Signed-off-by: Thorsten Glaser --- vcsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index 18cd9e54..53bec40c 100755 --- a/vcsh +++ b/vcsh @@ -255,7 +255,7 @@ list_tracked_by() { pull() { hook pre-pull for VCSH_REPO_NAME in $(list); do - printf "$VCSH_REPO_NAME: " + printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git pull @@ -268,7 +268,7 @@ pull() { push() { hook pre-push for VCSH_REPO_NAME in $(list); do - printf "$VCSH_REPO_NAME: " + printf '%s: ' "$VCSH_REPO_NAME" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use git push From 2922b986609a4ab6c455f7d91d68e4a6830cad38 Mon Sep 17 00:00:00 2001 From: Thorsten Glaser Date: Wed, 7 May 2014 10:20:32 +0200 Subject: [PATCH 026/164] Display full paths in list-tracked* Closes https://github.com/RichiH/vcsh/issues/125 Signed-off-by: Thorsten Glaser --- vcsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index 355e9fa7..19dfa05b 100755 --- a/vcsh +++ b/vcsh @@ -244,12 +244,14 @@ get_files() { list_tracked() { for VCSH_REPO_NAME in $(list); do get_files - done | sort -u + done | sed "s,^,$(printf '%s\n' "$VCSH_BASE/" | \ + sed 's/[,\&]/\\&/g')," | sort -u } list_tracked_by() { use - git ls-files | sort -u + git ls-files | sed "s,^,$(printf '%s\n' "$VCSH_BASE/" | \ + sed 's/[,\&]/\\&/g')," | sort -u } pull() { From 543fac6353d31f510bea2bb24f0ea518ce930d1d Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 7 May 2014 15:04:10 +0200 Subject: [PATCH 027/164] CONTRIBUTORS: Update --- CONTRIBUTORS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f042ac70..07456f9c 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -10,6 +10,8 @@ Jeff Fein-Worton Thomas Ferris Nicolaisen martin f. krafft Alessandro Ghedini +Thorsten Glaser +G.raud Mikhail Gusarov Valentin Haenel Richard Hartmann From db003b308f1a48a23ff60971045f956aa197c1d1 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 7 May 2014 15:07:08 +0200 Subject: [PATCH 028/164] Release v1.20140507 --- changelog | 7 +++++++ vcsh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index b5d6e781..98b1701b 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +2014-05-07 Richard Hartmann + + * Increase portability + * Improve hooks + * Improve docs + * Various minor improvements + 2014-03-13 Richard Hartmann * Release 1.20140313 -- the "Git won a prize" edition diff --git a/vcsh b/vcsh index 53bec40c..f1c10174 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # 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.20140313' +VERSION='1.20140507' SELF=$(basename $0) fatal() { From 275df624de73ca46d952755520b30d165eb5a088 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 8 May 2014 13:42:46 +0200 Subject: [PATCH 029/164] Revert "Introduce static manpage as part of normal repo" This reverts commit 056f86ae9a3c25fd2e0b74ac6b81d9b0d5630818. Conflicts: vcsh.1 This messes too much with my Debian packaging workflow; I will introduce a new branch with static manpages (basically what I did for homebrew). --- .gitignore | 1 + Makefile | 2 +- vcsh.1 | 347 ----------------------------------------------------- 3 files changed, 2 insertions(+), 348 deletions(-) delete mode 100644 vcsh.1 diff --git a/.gitignore b/.gitignore index d7b62d25..4dec9bf3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +vcsh.1 *.patch *.swp .swp diff --git a/Makefile b/Makefile index b40c618f..4ae8d889 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ RONN ?= ronn self=vcsh manpages=$(self).1 -all=test +all=test manpages all: $(all) diff --git a/vcsh.1 b/vcsh.1 deleted file mode 100644 index 4c77838c..00000000 --- a/vcsh.1 +++ /dev/null @@ -1,347 +0,0 @@ -.\" generated with Ronn/v0.7.3 -.\" http://github.com/rtomayko/ronn/tree/0.7.3 -. -.TH "VCSH" "1" "March 2014" "" "" -. -.SH "NAME" -\fBvcsh\fR \- Version Control System for $HOME \- multiple Git repositories in $HOME -. -.SH "SYNOPSIS" -\fBvcsh\fR [\fIoptions\fR] \fIcommand\fR -. -.P -\fBvcsh\fR clone \fIurl\fR [\fIrepo\fR] -. -.P -\fBvcsh\fR delete \fIrepo\fR -. -.P -\fBvcsh\fR enter \fIrepo\fR -. -.P -\fBvcsh\fR help -. -.P -\fBvcsh\fR init \fIrepo\fR -. -.P -\fBvcsh\fR list -. -.P -\fBvcsh\fR list\-tracked -. -.P -\fBvcsh\fR list\-tracked\-by \fIrepo\fR -. -.P -\fBvcsh\fR pull -. -.P -\fBvcsh\fR push -. -.P -\fBvcsh\fR rename \fIrepo\fR \fInewname\fR -. -.P -\fBvcsh\fR run \fIrepo\fR \fIshell command\fR -. -.P -\fBvcsh\fR status [\fIrepo\fR] -. -.P -\fBvcsh\fR upgrade \fIrepo\fR -. -.P -\fBvcsh\fR version -. -.P -\fBvcsh\fR which \fIsubstring\fR -. -.P -\fBvcsh\fR write\-gitignore \fIrepo\fR -. -.P -\fBvcsh\fR \fIrepo\fR \fIgit command\fR -. -.P -\fBvcsh\fR \fIrepo\fR -. -.SH "DESCRIPTION" -\fBvcsh\fR allows you to have several \fBgit\fR(1) repositories, all maintaining their working trees in $HOME without clobbering each other\. That, in turn, means you can have one repository per config set (zsh, vim, ssh, etc), picking and choosing which configs you want to use on which machine\. -. -.P -\fBvcsh\fR is using a technique called fake bare Git repositories, keeping \fI$GIT_DIR\fR in a different directory from \fI$GIT_WORK_TREE\fR which is pointed to \fI$HOME\fR\. -. -.P -The use of symlinks is not needed in this setup, making for a cleaner setup\. -. -.P -\fBvcsh\fR was designed with \fBmr\fR(1) in mind so you might want to install it alongside vcsh\. That being said, you can easily use \fBvcsh\fR without \fBmr\fR if you prefer\. -. -.P -A sample configuration for \fBvcsh\fR and \fBmr\fR can be found at \fIhttps://github\.com/RichiH/vcsh_mr_template\fR and used with \fBvcsh clone https://github\.com/RichiH/vcsh_mr_template mr\fR\. -. -.P -Please note that you can always use a path instead of a name for \fIrepo\fR\. This is needed to support mr and other scripts properly and of no concern to an interactive user\. -. -.SH "OPTIONS" -. -.TP -\-c -Source \fIfile\fR prior to other configuration files -. -.TP -\-d -Enable debug mode -. -.TP -\-v -Enable verbose mode -. -.SH "COMMANDS" -. -.TP -clone -Clone an existing repository\. -. -.IP -If you need to clone a bundle of repositories, look into the \fBpost\-clone\-retired\fR hook\. -. -.TP -commit -Commit in all repositories -. -.TP -delete -Delete an existing repository\. -. -.TP -enter -Enter repository; spawn new \fI$SHELL\fR\. -. -.TP -help -Display help\. -. -.TP -init -Initialize an empty repository\. -. -.TP -list -List all local vcsh repositories\. -. -.TP -list\-tracked -List all files tracked by vcsh\. -. -.TP -list\-tracked\-by -List files tracked by a repository\. -. -.TP -pull -Pull from all vcsh remotes\. -. -.TP -push -Push to all vcsh remotes\. -. -.TP -rename -Rename a repository\. -. -.TP -run -Run command with \fI$GIT_DIR\fR and \fI$GIT_WORK_TREE\fR set\. Allows you to run any and all commands without any restrictions\. Use with care\. -. -.IP -Please note that there is a somewhat magic feature for run\. Instead of \fIrepo\fR it accepts \fIpath\fR, as well\. Anything that has a slash in it will be assumed to be a path\. \fBvcsh run\fR will then operate on this directory instead of the one normally generated from the repository\'s name\. This is needed to support mr and other scripts properly and of no concern to an interactive user\. -. -.TP -status -Show statuses of all/one vcsh repositories\. -. -.TP -upgrade -Upgrade repository to currently recommended settings\. -. -.TP -version -Print version information\. -. -.TP -which \fIsubstring\fR -Find \fIsubstring\fR in name of any tracked file\. -. -.TP -write\-gitignore -Write \.gitignore\.d/\fIrepo\fR via \fBgit ls\-files\fR\. -. -.TP -\fIrepo\fR \fIgitcommand\fR -Shortcut to run \fBvcsh\fR on a repo\. Will prepend \fBgit\fR to \fIcommand\fR\. -. -.TP -\fIrepo\fR -Shortcut to run \fBvcsh enter \fR\. -. -.SH "ENVIRONMENT" -As noted earlier, \fBvcsh\fR will set \fI$GIT_DIR\fR and \fI$GIT_WORK_TREE\fR to the appropriate values for fake bare Git repositories\. -. -.SH "CONFIG" -There are several ways to turn the various knobs on \fBvcsh\fR\. In order of ascending precedence, they are: -. -.IP "\(bu" 4 -\fBVARIABLE=foo vcsh\fR -. -.IP "\(bu" 4 - -. -.IP "\(bu" 4 -<$XDG_CONFIG_HOME/vcsh/config> -. -.IP "\(bu" 4 -\fBvcsh \-c \fR -. -.IP "" 0 -. -.P -Please note that those files are sourced\. Any and all commands will be executed in the context of your shell\. -. -.P -Interesting knobs you can turn: -. -.TP -\fI$VCSH_GITATTRIBUTES\fR -Can be \fInone\fR, or any other value\. -. -.IP -\fInone\fR will not maintain Git attributes in a special location\. -. -.IP -If set to any other value, repo\-specific gitattributes files will be maintained\. -. -.IP -Defaults to \fInone\fR\. -. -.TP -\fI$VCSH_GITIGNORE\fR -Can be \fIexact\fR, \fInone\fR, or \fIrecursive\fR\. -. -.IP -\fIexact\fR will seed the repo\-specific ignore file with all file and directory names which \fBgit ls\-files\fR returns\. -. -.IP -\fInone\fR will not write any ignore file\. -. -.IP -\fIrecursive\fR will descend through all directories recursively additionally to the above\. -. -.IP -Defaults to \fIexact\fR\. -. -.TP -\fI$VCSH_VCSH_WORKTREE\fR -Can be \fIabsolute\fR, or \fIrelative\fR\. -. -.IP -\fIabsolute\fR will set an absolute path; defaulting to \fI$HOME\fR\. -. -.IP -\fIrelative\fR will set a path relative to \fI$GIT_DIR\fR\. -. -.IP -Defaults to \fIabsolute\fR\. -. -.P -Less interesting knobs you could turn: -. -.TP -\fI$VCSH_DEBUG\fR -Enter debug mode\. -. -.TP -\fI$XDG_CONFIG_HOME\fR -As specified in the \'XDG Base Directory Specification\', see \fIhttp://standards\.freedesktop\.org/basedir\-spec/basedir\-spec\-latest\.html\fR -. -.IP -Defaults to <$HOME/\.config>\. -. -.TP -\fI$VCSH_REPO_D\fR -The directory where repositories are read from and stored\. -. -.IP -Defaults to <$XDG_CONFIG_HOME/vcsh/repo\.d>\. -. -.TP -\fI$VCSH_HOOK_D\fR -The directory where hooks are read from\. -. -.IP -Defaults to <$XDG_CONFIG_HOME/vcsh/hooks\-enabled>\. -. -.TP -\fI$VCSH_BASE\fR -The directory where repositories are checked out to\. -. -.IP -Defaults to \fI$HOME\fR\. -. -.SH "HOOK SYSTEM" -\fBvcsh\fR provides a hook system\. Hook scripts must be executable and should be placed in <$XDG_CONFIG_HOME/vcsh/hooks\-available>\. From there, they can be soft\-linked into <$XDG_CONFIG_HOME/vcsh/hooks\-enabled>; \fBvcsh\fR will only execute hooks that are in this directory\. -. -.P -Hooks follow a simple format\. \fIpre\-run\fR will be run before anything is run\. If you want to have more than one script for a certain hook, just append any kind of string to order them\. A system of \fIpre\-run\fR, , etc is suggested; other options would be \fIpre\-run\-10\fR or \. A dot after the hook name is optional\. -. -.P -If you want to create hooks for a specific \fIvcsh\fR repository, simply prepend the repository\'s name, followed by a dot, i\.e\. \. Otherwise, the same rules as above apply\. The dot between the repository\'s name and the hook is mandatory, though\. -. -.P -Available hooks are \fIpre\-clone\fR, \fIpost\-clone\fR, \fIpost\-clone\-retired\fR, \fIpre\-command\fR, \fIpost\-command\fR, \fIpre\-enter\fR, \fIpost\-enter\fR, \fIpre\-init\fR, \fIpost\-init\fR, \fIpre\-pull\fR, \fIpost\-pull\fR, \fIpre\-push\fR, \fIpost\-push\fR, \fIpre\-run\fR, \fIpost\-run\fR, \fIpre\-upgrade\fR, and \fIpost\-upgrade\fR\. If you need more, vcsh is trivial to patch, but please let upstream know so we can ship them by default\. -. -.SH "DETAILED HOWTO AND FURTHER READING" -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\. -. -.P -This software also comes with a file called \. 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\. -. -.P -On Debian\-based systems, this file can be found in \. -. -.SH "SECURITY CONSIDERATIONS" -\fBvcsh\fR allows you to execute arbitrary commands via \fBvcsh run\fR\. For example, adding a \fBsudo\fR(8) rule for \fBvcsh\fR would be pretty stupid\. -. -.P -Additionally, vcsh will source, i\.e\. execute, all files listed in \fICONFIG\fR\. You can put any and all commands into these config files and they will be executed\. -. -.SH "BUGS" -None are known at this time, but reports and/or patches are more than welcome\. -. -.SH "INTEROPERABILITY" -If you rely on \fBgit submodule\fR use \fBgit\fR 1\.7\.12 or later\. Earlier versions do not clean internal variables properly before descending into submodules, resulting in unhappy end users\. -. -.SH "HISTORY" -Like most people, the author initially made do with a single repository for all config files, all of which were soft\-linked into \fI$HOME\fR\. -. -.P -Martin F\. Krafft aka madduck came up with the concept of fake bare Git repositories\. -. -.P -vcsh was initally written by madduck\. This version is a re\-implementation from scratch with a lot more features\. madduck graciously agreed to let the author take over the name\. -. -.SH "AUTHOR" -This manpage and \fBvcsh\fR itself were written by Richard "RichiH" Hartmann\. -. -.SH "COPYRIGHT" -Copyright 2011\-2013 Richard Hartmann \fIrichih@debian\.org\fR -. -.P -Licensed under the GNU GPL version 2 or higher\. -. -.P -https://github\.com/RichiH/vcsh -. -.SH "SEE ALSO" -\fBgit\fR(1), \fBmr\fR(1) From f7ce400c37d3308122195fd70fa79dff7aac00e3 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 8 May 2014 13:46:37 +0200 Subject: [PATCH 030/164] Release v1.20140508 --- changelog | 4 ++++ vcsh | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 98b1701b..3e8029ed 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,7 @@ +2014-05-08 Richard Hartmann + + * Revert "Introduce static manpage as part of normal repo" + 2014-05-07 Richard Hartmann * Increase portability diff --git a/vcsh b/vcsh index f1c10174..b675edd1 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # 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.20140507' +VERSION='1.20140508' SELF=$(basename $0) fatal() { From 53311ba2f69d55b2148866c40148dbbfaee8c761 Mon Sep 17 00:00:00 2001 From: Thorsten Glaser Date: Wed, 7 May 2014 10:20:32 +0200 Subject: [PATCH 031/164] Display full paths in list-tracked* Closes https://github.com/RichiH/vcsh/issues/125 Signed-off-by: Thorsten Glaser --- vcsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index e07cffbb..e8513edb 100755 --- a/vcsh +++ b/vcsh @@ -244,12 +244,14 @@ get_files() { list_tracked() { for VCSH_REPO_NAME in $(list); do get_files - done | sort -u + done | sed "s,^,$(printf '%s\n' "$VCSH_BASE/" | \ + sed 's/[,\&]/\\&/g')," | sort -u } list_tracked_by() { use - git ls-files | sort -u + git ls-files | sed "s,^,$(printf '%s\n' "$VCSH_BASE/" | \ + sed 's/[,\&]/\\&/g')," | sort -u } pull() { From 30643948aaf9e19efd5a0b7d2c9291a945169b71 Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Fri, 9 May 2014 10:14:49 +0200 Subject: [PATCH 032/164] Use cowsay from the PATH instead --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4ae8d889..31ac2e47 100644 --- a/Makefile +++ b/Makefile @@ -47,4 +47,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 + @ which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..." From 3177d4ce121ee916e83a65ffd539dc328e8f55a1 Mon Sep 17 00:00:00 2001 From: Aaron Schumacher Date: Wed, 21 May 2014 16:01:04 -0400 Subject: [PATCH 033/164] typo: "availabile.d" to "available.d" --- doc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/README.md b/doc/README.md index 0fc717a5..74a0e80c 100644 --- a/doc/README.md +++ b/doc/README.md @@ -128,7 +128,7 @@ of myrepos is technically optional, it will be an integral part of the proposed system that follows. For instance, you can use [myrepos][myrepos] to track repositories in home such as `.emacs.d`, which `mr` can clone and update for you automatically. To do this, -just add a `mr` configuration file to `availabile.d` with a `checkout` +just add a `mr` configuration file to `available.d` with a `checkout` command to clone the repo, and set the [title] to the desired location, e.g. `$HOME/.emacs.d`. Try the `mr register` command in an existing repository, then view `~/.mrconfig` for an example. From 1e02192f91f833cd829710f40b2b2870903f9e1f Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 25 Aug 2014 17:45:12 +0200 Subject: [PATCH 034/164] Makefile: Allow `PREFIX=foo make install` --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4ae8d889..9e3d5a22 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -PREFIX=/usr +PREFIX?=/usr DOCDIR_PREFIX=$(PREFIX)/share/doc DOCDIR=$(DOCDIR_PREFIX)/$(self) ZSHDIR=$(PREFIX)/share/zsh/vendor-completions From ea51d17d1146ea6502c7191794e47ec9b1edfe57 Mon Sep 17 00:00:00 2001 From: Yuval Langer Date: Sun, 7 Sep 2014 11:19:27 +0300 Subject: [PATCH 035/164] typo `that you cat track` -> `that you can track` --- doc/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/README.md b/doc/README.md index 74a0e80c..8984c692 100644 --- a/doc/README.md +++ b/doc/README.md @@ -117,7 +117,7 @@ your `$HOME`, you will end up with a lot of repositories very quickly. `vcsh` was designed with [myrepos][myrepos], a tool to manage Multiple Repositories, in mind and the two integrate very nicely. The myrepos tool (`mr`) has native support for `vcsh` repositories and the configuration for -myrepos is just another set of files that you cat track with `vcsh` like any +myrepos is just another set of files that you can track with `vcsh` like any other. This makes setting up any new machine a breeze. It can take literally less than five minutes to go from standard installation to fully set up system. From 0bd39b20cea2833de45482e077917947c0b99d61 Mon Sep 17 00:00:00 2001 From: Yuval Langer Date: Sun, 7 Sep 2014 17:39:22 +0300 Subject: [PATCH 036/164] Rename `foo` to a meaningful name `repo_name` I get lost within all of those meaningless names. It is useful to give things meaningful names, especially in documentation. --- doc/README.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/doc/README.md b/doc/README.md index 8984c692..b14d782e 100644 --- a/doc/README.md +++ b/doc/README.md @@ -220,7 +220,7 @@ this document (see above). vcsh will check if any file it would want to create exists. If it exists, vcsh will throw a warning and exit. Move away your old config and try again. Optionally, merge your local and your global configs afterwards and push with -`vcsh foo push`. +`vcsh repo_name push`. ## Moving into a New Host @@ -351,14 +351,15 @@ Now, it's time to edit the template config and fill it with your own remotes: And then create your own stuff: - vcsh init foo - vcsh foo add bar baz quux - vcsh foo remote add origin git://quuux - vcsh foo commit - vcsh foo push - cp $XDG_CONFIG_HOME/mr/available.d/mr.vcsh $XDG_CONFIG_HOME/mr/available.d/foo.vcsh - vim $XDG_CONFIG_HOME/mr/available.d/foo.vcsh # add your own repo + vcsh init repo_name + vcsh repo_name add bar baz quux + vcsh repo_name remote add origin git://quuux + vcsh repo_name commit + vcsh repo_name push + + cp $XDG_CONFIG_HOME/mr/available.d/mr.vcsh $XDG_CONFIG_HOME/mr/available.d/repo_name.vcsh + vim $XDG_CONFIG_HOME/mr/available.d/repo_name.vcsh # add your own repo Done! @@ -427,9 +428,9 @@ Neat. After you have made some changes, for which you would normally use `git add` and `git commit`, use the vcsh wrapper (like above): - vcsh foo add bar baz quux - vcsh foo commit - vcsh foo push + vcsh repo_name add bar baz quux + vcsh repo_name commit + vcsh repo_name push ### Using vcsh without myrepos From 88dc47b049d19ca62dd29ec9d594b8a8dc858f40 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 9 Oct 2014 23:22:03 +0200 Subject: [PATCH 037/164] Release v1.20141009 --- changelog | 5 +++++ vcsh | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 3e8029ed..1c09b670 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,8 @@ +2014-10-09 Richard Hartmann + + * Display full paths in list-tracked* + * Lots of help improvements + 2014-05-08 Richard Hartmann * Revert "Introduce static manpage as part of normal repo" diff --git a/vcsh b/vcsh index e8513edb..6a81343c 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # 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.20140508' +VERSION='1.20141009' SELF=$(basename $0) fatal() { From 6334d6751373986fe72debe0cc9ffa54159761db Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Fri, 13 Jan 2012 00:39:33 +0100 Subject: [PATCH 038/164] test commit --- vcsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vcsh b/vcsh index 6a81343c..12490890 100755 --- a/vcsh +++ b/vcsh @@ -284,6 +284,16 @@ retire() { unset VCSH_DIRECTORY } +list_untracked() { + for VCSH_REPO_NAME in $(list); do + [ -n $ran_once ] && files_untracked=$(printf '%s\n' "$files_untracked" | grep -x "$files_other") + export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" + files_other="$(git ls-files --others)" + [ -z $ran_once ] && { ran_once=1; files_untracked=$files_other; } + done + echo "$files_untracked" | sort -u +} + rename() { git_dir_exists [ -d "$GIT_DIR_NEW" ] && fatal "'$GIT_DIR_NEW' exists" 54 @@ -463,6 +473,7 @@ elif [ x"$VCSH_COMMAND" = x'delete' ] || elif [ x"$VCSH_COMMAND" = x'commit' ] || [ x"$VCSH_COMMAND" = x'list' ] || [ x"$VCSH_COMMAND" = x'list-tracked' ] || + [ x"$VCSH_COMMAND" = x'list-untracked' ] || [ x"$VCSH_COMMAND" = x'pull' ] || [ x"$VCSH_COMMAND" = x'push' ]; then : From dad32b0f91c8e2cf9986ea1eb3f869e4774a963e Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Fri, 13 Jan 2012 00:43:12 +0100 Subject: [PATCH 039/164] test commit --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 12490890..15eec515 100755 --- a/vcsh +++ b/vcsh @@ -286,7 +286,7 @@ retire() { list_untracked() { for VCSH_REPO_NAME in $(list); do - [ -n $ran_once ] && files_untracked=$(printf '%s\n' "$files_untracked" | grep -x "$files_other") + [ -n $ran_once ] && files_untracked=$(printf '%s\n' "$files_untracked" | grep -Fx "$files_other") export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" files_other="$(git ls-files --others)" [ -z $ran_once ] && { ran_once=1; files_untracked=$files_other; } From 35b17e1f898e59c8e6bc25798b274881eaf98d06 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Fri, 13 Jan 2012 02:07:02 +0100 Subject: [PATCH 040/164] test commit; rewrite to use comm and two temp files to get around argument too long crap --- vcsh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vcsh b/vcsh index 15eec515..7004cdff 100755 --- a/vcsh +++ b/vcsh @@ -285,13 +285,18 @@ retire() { } list_untracked() { + temp_file_others=$(mktemp) || fatal 'Could not create temp file' + temp_file_untracked=$(mktemp) || fatal 'Could not create temp file' for VCSH_REPO_NAME in $(list); do - [ -n $ran_once ] && files_untracked=$(printf '%s\n' "$files_untracked" | grep -Fx "$files_other") + [ -n $ran_once ] && foo="$(comm -12 --nocheck-order $temp_file_others $temp_file_untracked)" + echo "$foo" > $temp_file_untracked +# [ -n $ran_once ] && files_untracked=$(printf '%s\n' "$files_untracked" | grep -Fx "$files_other") export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - files_other="$(git ls-files --others)" - [ -z $ran_once ] && { ran_once=1; files_untracked=$files_other; } + git ls-files --others | sort -u > $temp_file_others + [ -z "$ran_once" ] && { ran_once=1; cp $temp_file_others $temp_file_untracked; } done - echo "$files_untracked" | sort -u + cat $temp_file_untracked + rm $temp_file_others $temp_file_untracked || fatal 'Could not delete temp file' } rename() { From 9867819bf0fc3882b9ede33462b6d98f10b7535a Mon Sep 17 00:00:00 2001 From: Mert Dirik Date: Sun, 19 Oct 2014 03:24:04 +0300 Subject: [PATCH 041/164] 3rd try --- vcsh | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/vcsh b/vcsh index 7004cdff..b10d8095 100755 --- a/vcsh +++ b/vcsh @@ -287,16 +287,34 @@ retire() { list_untracked() { temp_file_others=$(mktemp) || fatal 'Could not create temp file' temp_file_untracked=$(mktemp) || fatal 'Could not create temp file' + temp_file_untracked_copy=$(mktemp) || fatal 'Could not create temp file' + + # create dummy git repo + temp_repo=$(mktemp -d) + ( + cd $temp_repo + git init -q + mktemp -p $(pwd) > /dev/null + git add . + git commit -q -m "dummy" + ) + + export GIT_DIR=$temp_repo/.git + git ls-files --others --directory | sort -u > $temp_file_untracked + for VCSH_REPO_NAME in $(list); do - [ -n $ran_once ] && foo="$(comm -12 --nocheck-order $temp_file_others $temp_file_untracked)" - echo "$foo" > $temp_file_untracked -# [ -n $ran_once ] && files_untracked=$(printf '%s\n' "$files_untracked" | grep -Fx "$files_other") export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - git ls-files --others | sort -u > $temp_file_others - [ -z "$ran_once" ] && { ran_once=1; cp $temp_file_others $temp_file_untracked; } + git ls-files --others --directory | ( + while read line; do + echo "$line" + printf '%s/\n' "$(echo "$line" | cut -d'/' -f1)" + done + ) | sort -u > $temp_file_others + cp $temp_file_untracked $temp_file_untracked_copy + comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked done cat $temp_file_untracked - rm $temp_file_others $temp_file_untracked || fatal 'Could not delete temp file' + rm -r $temp_file_others $temp_file_untracked $temp_file_untracked_copy $temp_repo || fatal 'Could not delete temp file' } rename() { From d946b07817ffe6e156c159e7fc6270322413e530 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 19 Oct 2014 08:34:09 +0200 Subject: [PATCH 042/164] vcsh: Make `vcsh which dontexist` exit 1 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=760882 --- vcsh | 1 + 1 file changed, 1 insertion(+) diff --git a/vcsh b/vcsh index 6a81343c..0b4c4526 100755 --- a/vcsh +++ b/vcsh @@ -351,6 +351,7 @@ use() { } which() { + [ -e "$VCSH_COMMAND_PARAMETER" ] || fatal "'$VCSH_COMMAND_PARAMETER' does not exist" 1 for VCSH_REPO_NAME in $(list); do for VCSH_FILE in $(get_files); do echo "$VCSH_FILE" | grep -q "$VCSH_COMMAND_PARAMETER" && echo "$VCSH_REPO_NAME: $VCSH_FILE" From 9f943527a41af4e68dd05ef208ba05666a37e2da Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 20 Oct 2014 22:37:06 +0200 Subject: [PATCH 043/164] vcsh: Add support for overlay functions --- doc/vcsh.1.ronn | 11 +++++++++++ vcsh | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 05da4fad..ebc9896f 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -254,6 +254,17 @@ Available hooks are , , , If you need more, vcsh is trivial to patch, but please let upstream know so we can ship them by default. +## OVERLAY SYSTEM + +`vcsh` also provides an overlay system. Similar to hooks, the recommended +locations are <$XDG_CONFIG_HOME/vcsh/overlays-available> and +<$XDG_CONFIG_HOME/vcsh/overlays-enabled>. + +Overlays follow the same rules as hooks and you are free to overwrite any +and all functions. As the overlays will be sourced and you are replacing +arbitrary functions, any and all features may stop working, or you may even +lose data. You have been warned. + ## DETAILED HOWTO AND FURTHER READING Manpages are often short and sometimes useless to glean best practices from. diff --git a/vcsh b/vcsh index 0b4c4526..301151a1 100755 --- a/vcsh +++ b/vcsh @@ -75,6 +75,7 @@ fi # Read defaults : ${VCSH_REPO_D:="$XDG_CONFIG_HOME/vcsh/repo.d"} : ${VCSH_HOOK_D:="$XDG_CONFIG_HOME/vcsh/hooks-enabled"} +: ${VCSH_OVERLAY_D:="$XDG_CONFIG_HOME/vcsh/overlays-enabled"} : ${VCSH_BASE:="$HOME"} : ${VCSH_GITIGNORE:=exact} : ${VCSH_GITATTRIBUTES:=none} @@ -511,6 +512,14 @@ check_dir "$VCSH_REPO_D" verbose "$VCSH_COMMAND begin" VCSH_COMMAND=$(echo "$VCSH_COMMAND" | sed 's/-/_/g'); export VCSH_COMMAND + +# source overlay functions +for overlay in "$VCSH_OVERLAY_D/$VCSH_COMMAND"* "$VCSH_OVERLAY_D/$VCSH_REPO_NAME.$VCSH_COMMAND"*; do + [ -r "$overlay" ] || continue + info "sourcing '$overlay'" + . "$overlay" +done + hook pre-command $VCSH_COMMAND "$@" hook post-command From b4078210a72a210c5a505b8d34ad4eb249fe735e Mon Sep 17 00:00:00 2001 From: Mert Dirik Date: Tue, 21 Oct 2014 00:25:43 +0300 Subject: [PATCH 044/164] Force temporary file/directory removal --- vcsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index b10d8095..fb1c0918 100755 --- a/vcsh +++ b/vcsh @@ -314,7 +314,8 @@ list_untracked() { comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked done cat $temp_file_untracked - rm -r $temp_file_others $temp_file_untracked $temp_file_untracked_copy $temp_repo || fatal 'Could not delete temp file' + rm -f $temp_file_others $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not delete temp files' + rm -rf $temp_repo || fatal 'Could not delete temp repo' } rename() { From 974ccb022b59ac80145a6d43ff4f11b18ae49de1 Mon Sep 17 00:00:00 2001 From: Mert Dirik Date: Tue, 21 Oct 2014 03:08:25 +0300 Subject: [PATCH 045/164] Add checks to file operations --- vcsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vcsh b/vcsh index fb1c0918..8e765c41 100755 --- a/vcsh +++ b/vcsh @@ -290,11 +290,11 @@ list_untracked() { temp_file_untracked_copy=$(mktemp) || fatal 'Could not create temp file' # create dummy git repo - temp_repo=$(mktemp -d) + temp_repo=$(mktemp -d) || fatal 'Could not create temp repo' ( - cd $temp_repo + cd $temp_repo || fatal 'Could not cd into temp repo' git init -q - mktemp -p $(pwd) > /dev/null + mktemp -q -p $(pwd) > /dev/null || fatal 'Could not create dummy file' git add . git commit -q -m "dummy" ) @@ -310,7 +310,7 @@ list_untracked() { printf '%s/\n' "$(echo "$line" | cut -d'/' -f1)" done ) | sort -u > $temp_file_others - cp $temp_file_untracked $temp_file_untracked_copy + cp $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not copy temp file' comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked done cat $temp_file_untracked From 0ea8735cfa3033e4b974bd1f9d4bbf8a7d74e8ca Mon Sep 17 00:00:00 2001 From: Mert Dirik Date: Tue, 21 Oct 2014 03:09:14 +0300 Subject: [PATCH 046/164] Check for existence of 'comm' command --- vcsh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vcsh b/vcsh index 8e765c41..cebd7986 100755 --- a/vcsh +++ b/vcsh @@ -284,7 +284,13 @@ retire() { unset VCSH_DIRECTORY } +command_exists() { + command -v "$1" >/dev/null 2>&1 || fatal "Could not find '$1' command" +} + list_untracked() { + command_exists comm + temp_file_others=$(mktemp) || fatal 'Could not create temp file' temp_file_untracked=$(mktemp) || fatal 'Could not create temp file' temp_file_untracked_copy=$(mktemp) || fatal 'Could not create temp file' From 798d70b901cf63afde2eb05794791a5c943c4c51 Mon Sep 17 00:00:00 2001 From: Mert Dirik Date: Tue, 21 Oct 2014 15:34:29 +0300 Subject: [PATCH 047/164] Don't use subshell when creating the temporary repo --- vcsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index cebd7986..279de43c 100755 --- a/vcsh +++ b/vcsh @@ -297,13 +297,13 @@ list_untracked() { # create dummy git repo temp_repo=$(mktemp -d) || fatal 'Could not create temp repo' - ( + cd $temp_repo || fatal 'Could not cd into temp repo' git init -q mktemp -q -p $(pwd) > /dev/null || fatal 'Could not create dummy file' git add . git commit -q -m "dummy" - ) + cd - > /dev/null 2>&1 || fatal 'Could not cd back' export GIT_DIR=$temp_repo/.git git ls-files --others --directory | sort -u > $temp_file_untracked From d3b04ac4495a6fe1676aa0f2f6b60a93fd6324e1 Mon Sep 17 00:00:00 2001 From: Mert Dirik Date: Tue, 21 Oct 2014 16:30:43 +0300 Subject: [PATCH 048/164] Add recursive option (-r) --- vcsh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/vcsh b/vcsh index 279de43c..e4f6f33d 100755 --- a/vcsh +++ b/vcsh @@ -30,7 +30,7 @@ fatal() { # 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 +while getopts "c:dvr" flag; do if [ x"$1" = x'-d' ] || [ x"$1" = x'--debug' ]; then set -vx VCSH_DEBUG=1 @@ -40,6 +40,8 @@ while getopts "c:dv" flag; do VCSH_VERBOSE=1 echo "verbose mode on" echo "$SELF $VERSION" + elif [ x"$1" = x'-r' ]; then + VCSH_OPTION_RECURSIVE=1 elif [ x"$1" = x'-c' ]; then VCSH_OPTION_CONFIG=$OPTARG fi @@ -304,13 +306,15 @@ list_untracked() { git add . git commit -q -m "dummy" cd - > /dev/null 2>&1 || fatal 'Could not cd back' - + + [ -z "$VCSH_OPTION_RECURSIVE" ] && directory_opt="--directory" + export GIT_DIR=$temp_repo/.git - git ls-files --others --directory | sort -u > $temp_file_untracked - + git ls-files --others "$directory_opt" | sort -u > $temp_file_untracked + for VCSH_REPO_NAME in $(list); do export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - git ls-files --others --directory | ( + git ls-files --others "$directory_opt" | ( while read line; do echo "$line" printf '%s/\n' "$(echo "$line" | cut -d'/' -f1)" @@ -320,6 +324,8 @@ list_untracked() { comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked done cat $temp_file_untracked + + unset directory_opt rm -f $temp_file_others $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not delete temp files' rm -rf $temp_repo || fatal 'Could not delete temp repo' } From 589f2baa284376cbbe5e98d5f5ff145a9441dffc Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 21 Oct 2014 23:25:42 +0200 Subject: [PATCH 049/164] vcsh: Improve error handling of clone() May fix https://github.com/RichiH/vcsh/issues/122 --- vcsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vcsh b/vcsh index 0b4c4526..cacd1b1b 100755 --- a/vcsh +++ b/vcsh @@ -148,9 +148,10 @@ clone() { git remote add origin "$GIT_REMOTE" git config branch.master.remote origin git config branch.master.merge refs/heads/master - if [ $(git ls-remote origin master 2> /dev/null | wc -l ) -lt 1 ]; then - info "remote is empty, not merging anything" - exit + VCSH_CLONE_ERROR=$(git ls-remote origin master 2>&1) + if [ -n "$VCSH_CLONE_ERROR" ]; then + rm -rf "$GIT_DIR" + fatal "$VCSH_CLONE_ERROR" 1 fi git fetch hook pre-merge From 8f53cfb08e4d2ac1491dd8f2cfe4db2734064dd5 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 7 Sep 2013 13:34:23 +0200 Subject: [PATCH 050/164] vcsh: Initial support for cloning from branches other than master --- vcsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vcsh b/vcsh index e8513edb..86a3711d 100755 --- a/vcsh +++ b/vcsh @@ -146,9 +146,9 @@ clone() { hook pre-clone init git remote add origin "$GIT_REMOTE" - git config branch.master.remote origin - git config branch.master.merge refs/heads/master - if [ $(git ls-remote origin master 2> /dev/null | wc -l ) -lt 1 ]; then + git config branch."$VCSH_BRANCH".remote origin + git config branch."$VCSH_BRANCH".merge refs/heads/$VCSH_BRANCH + if [ $(git ls-remote origin $VCSH_BRANCH 2> /dev/null | wc -l ) -lt 1 ]; then info "remote is empty, not merging anything" exit fi @@ -162,7 +162,7 @@ clone() { [ x"$VCSH_CONFLICT" = x'1' ]) && fatal "will stop after fetching and not try to merge! Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 - git merge origin/master + git merge origin/master # XXX hook post-merge hook post-clone retire From a171b8ba4a69de0bb8d0afced0807757a1b4c216 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 12 Sep 2013 23:30:27 +0200 Subject: [PATCH 051/164] vcsh: Proper quoting for "$VCSH_BRANCH" --- vcsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcsh b/vcsh index 86a3711d..69b6c4ce 100755 --- a/vcsh +++ b/vcsh @@ -147,8 +147,8 @@ clone() { init git remote add origin "$GIT_REMOTE" git config branch."$VCSH_BRANCH".remote origin - git config branch."$VCSH_BRANCH".merge refs/heads/$VCSH_BRANCH - if [ $(git ls-remote origin $VCSH_BRANCH 2> /dev/null | wc -l ) -lt 1 ]; then + git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" + if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then info "remote is empty, not merging anything" exit fi @@ -162,7 +162,7 @@ clone() { [ x"$VCSH_CONFLICT" = x'1' ]) && fatal "will stop after fetching and not try to merge! Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 - git merge origin/master # XXX + git merge origin/"$VCSH_BRANCH" hook post-merge hook post-clone retire From 21030a7f325e0496deb8084c768a74d2ad9ea15c Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Sat, 12 Oct 2013 19:49:07 +0200 Subject: [PATCH 052/164] vcsh: Create the local branch during clone This will create and checkout a local branch named after the upstream branch. It will also gracefully behave for the default `master' branch and consistently show the same message: Switched to a new branch '$VCSH_BRANCH' --- vcsh | 1 + 1 file changed, 1 insertion(+) diff --git a/vcsh b/vcsh index 69b6c4ce..edb91fac 100755 --- a/vcsh +++ b/vcsh @@ -148,6 +148,7 @@ clone() { git remote add origin "$GIT_REMOTE" git config branch."$VCSH_BRANCH".remote origin git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" + git checkout -b $VCSH_BRANCH if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then info "remote is empty, not merging anything" exit From 9e324980073d450b700cfeb1952adee2dabd0ddb Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Sat, 12 Oct 2013 20:11:32 +0200 Subject: [PATCH 053/164] vcsh: Only fetch the upstream branch during clone --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index edb91fac..898bdb54 100755 --- a/vcsh +++ b/vcsh @@ -153,7 +153,7 @@ clone() { info "remote is empty, not merging anything" exit fi - git fetch + git fetch origin "$VCSH_BRANCH" hook pre-merge git ls-tree -r --name-only origin/master | (while read object; do [ -e "$object" ] && From bc9dada76fe67f1a9ac8028372367b32b08fcdf6 Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Wed, 22 Oct 2014 18:47:36 +0200 Subject: [PATCH 054/164] vcsh: `vcsh clone [-b ] []` This is the API for an optional branch selection for `vcsh clone`. It is basically inspired by `git clone [-b|--branch ] `. I could have used the long option `--branch` too but vcsh only uses short ones. --- vcsh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 898bdb54..76502f53 100755 --- a/vcsh +++ b/vcsh @@ -98,7 +98,8 @@ help() { -v Enable verbose mode commands: - clone \\ + clone [-b ] \\ + \\ [] Clone from an existing repository commit Commit in all repositories delete Delete an existing repository @@ -431,6 +432,13 @@ case $VCSH_COMMAND in esac if [ x"$VCSH_COMMAND" = x'clone' ]; then + if [ "$2" = -b ]; then + VCSH_BRANCH="$3" + shift + shift + else + VCSH_BRANCH=master + fi [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a remote" 1 GIT_REMOTE="$2" [ -n "$3" ] && VCSH_REPO_NAME=$3 || VCSH_REPO_NAME=$(basename "${GIT_REMOTE#*:}" .git) From 67a1a55913e80ce2e97d4f7b389793f4afb33dc6 Mon Sep 17 00:00:00 2001 From: Mert Dirik Date: Thu, 23 Oct 2014 00:09:11 +0300 Subject: [PATCH 055/164] Replace temporary repository with copy based method --- vcsh | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/vcsh b/vcsh index e4f6f33d..3642ad5e 100755 --- a/vcsh +++ b/vcsh @@ -296,38 +296,29 @@ list_untracked() { temp_file_others=$(mktemp) || fatal 'Could not create temp file' temp_file_untracked=$(mktemp) || fatal 'Could not create temp file' temp_file_untracked_copy=$(mktemp) || fatal 'Could not create temp file' - - # create dummy git repo - temp_repo=$(mktemp -d) || fatal 'Could not create temp repo' - - cd $temp_repo || fatal 'Could not cd into temp repo' - git init -q - mktemp -q -p $(pwd) > /dev/null || fatal 'Could not create dummy file' - git add . - git commit -q -m "dummy" - cd - > /dev/null 2>&1 || fatal 'Could not cd back' [ -z "$VCSH_OPTION_RECURSIVE" ] && directory_opt="--directory" - export GIT_DIR=$temp_repo/.git - git ls-files --others "$directory_opt" | sort -u > $temp_file_untracked - for VCSH_REPO_NAME in $(list); do export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" git ls-files --others "$directory_opt" | ( while read line; do echo "$line" - printf '%s/\n' "$(echo "$line" | cut -d'/' -f1)" + directory_component="$(echo "$line" | cut -d'/' -f1)" + [ -d "$directory_component" ] && printf '%s/\n' "$directory_component" done ) | sort -u > $temp_file_others + if [ -z "$ran_once" ]; then + ran_once=1 + cp $temp_file_others $temp_file_untracked || fatal 'Could not copy temp file' + fi cp $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not copy temp file' comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked done cat $temp_file_untracked - unset directory_opt + unset directory_opt directory_component rm -f $temp_file_others $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not delete temp files' - rm -rf $temp_repo || fatal 'Could not delete temp repo' } rename() { From 35d1c19fd0099ffa87098e1bf7433f83a6fc2d18 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 22 Oct 2014 23:35:35 +0200 Subject: [PATCH 056/164] vcsh: Make status() show commit offsets to remote tracking branch github: Fixes richih/vcsh#123 --- vcsh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vcsh b/vcsh index 0ec2bba8..9d399d4b 100755 --- a/vcsh +++ b/vcsh @@ -314,12 +314,12 @@ status() { echo "$VCSH_REPO_NAME:" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - # TODO repos without remote tracking branch error out - remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u}) - commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) - commits_ahead=$(git log ${remote_tracking_branch}.. --oneline | wc -l) - [ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits" - [ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits" + remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && { + commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) + commits_ahead=$(git log ${remote_tracking_branch}.. --oneline | wc -l) + [ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits" + [ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits" + } git status --short --untracked-files='no' VCSH_COMMAND_RETURN_CODE=$? echo From 5432ea130bd5920174376299864988fad0e816cf Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 00:02:11 +0200 Subject: [PATCH 057/164] vcsh: Make fatal() default to `exit 1` --- vcsh | 1 + 1 file changed, 1 insertion(+) diff --git a/vcsh b/vcsh index 0b4c4526..ea748357 100755 --- a/vcsh +++ b/vcsh @@ -24,6 +24,7 @@ SELF=$(basename $0) fatal() { echo "$SELF: fatal: $1" >&2 + [ -z $2] && exit 1 exit $2 } From f39e21b79b419bc6831e67eec73afd6c571e7f5a Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 00:22:02 +0200 Subject: [PATCH 058/164] vcsh: Fix random tab --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 3642ad5e..e4143de1 100755 --- a/vcsh +++ b/vcsh @@ -316,7 +316,7 @@ list_untracked() { comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked done cat $temp_file_untracked - + unset directory_opt directory_component rm -f $temp_file_others $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not delete temp files' } From 6facf078b31be6526861303a2d6bc21e636fe139 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 00:26:30 +0200 Subject: [PATCH 059/164] vcsh: Use BSD/OS X compatible `mktemp` --- vcsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcsh b/vcsh index e4143de1..965f83dd 100755 --- a/vcsh +++ b/vcsh @@ -293,9 +293,9 @@ command_exists() { list_untracked() { command_exists comm - temp_file_others=$(mktemp) || fatal 'Could not create temp file' - temp_file_untracked=$(mktemp) || fatal 'Could not create temp file' - temp_file_untracked_copy=$(mktemp) || fatal 'Could not create temp file' + temp_file_others=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' + temp_file_untracked=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' + temp_file_untracked_copy=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' [ -z "$VCSH_OPTION_RECURSIVE" ] && directory_opt="--directory" From 099b25a8a6b0950a6694672094ac2c0f89b0d1cb Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 00:27:06 +0200 Subject: [PATCH 060/164] vcsh: Remove extra function --- vcsh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vcsh b/vcsh index 965f83dd..83bb2676 100755 --- a/vcsh +++ b/vcsh @@ -286,12 +286,8 @@ retire() { unset VCSH_DIRECTORY } -command_exists() { - command -v "$1" >/dev/null 2>&1 || fatal "Could not find '$1' command" -} - list_untracked() { - command_exists comm + command -v 'comm' >/dev/null 2>&1 || fatal "Could not find 'comm'" temp_file_others=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' temp_file_untracked=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' From de1c75a12e9f0f586b1973d3866ad4707d263a08 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 00:40:54 +0200 Subject: [PATCH 061/164] vcsh: Add support for `vcsh list-untracked -r` --- vcsh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/vcsh b/vcsh index 83bb2676..a374f05b 100755 --- a/vcsh +++ b/vcsh @@ -30,7 +30,7 @@ fatal() { # 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:dvr" flag; do +while getopts "c:dv" flag; do if [ x"$1" = x'-d' ] || [ x"$1" = x'--debug' ]; then set -vx VCSH_DEBUG=1 @@ -40,8 +40,6 @@ while getopts "c:dvr" flag; do VCSH_VERBOSE=1 echo "verbose mode on" echo "$SELF $VERSION" - elif [ x"$1" = x'-r' ]; then - VCSH_OPTION_RECURSIVE=1 elif [ x"$1" = x'-c' ]; then VCSH_OPTION_CONFIG=$OPTARG fi @@ -293,7 +291,15 @@ list_untracked() { temp_file_untracked=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' temp_file_untracked_copy=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' - [ -z "$VCSH_OPTION_RECURSIVE" ] && directory_opt="--directory" + # Hack in support for `vcsh list-untracked -r` + directory_opt="--directory" + shift 1 + while getopts "r" flag; do + if [ x"$1" = x'-r' ]; then + unset directory_opt + fi + shift 1 + done for VCSH_REPO_NAME in $(list); do export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" From 3a72a809b8681ed08ec45065089a5bd7d1b8cf4d Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 00:44:36 +0200 Subject: [PATCH 062/164] vcsh: list_untracked(): Avoid `cut`; speed up `-r` Avoid spawning `cut` and speed recursive mode up from "takes several seconds on a current machine" to "instant". Thanks to Thorsten Glaser. --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index a374f05b..1d947d1a 100755 --- a/vcsh +++ b/vcsh @@ -306,7 +306,7 @@ list_untracked() { git ls-files --others "$directory_opt" | ( while read line; do echo "$line" - directory_component="$(echo "$line" | cut -d'/' -f1)" + directory_component=${line%%/*} [ -d "$directory_component" ] && printf '%s/\n' "$directory_component" done ) | sort -u > $temp_file_others From fe122a264bc6ff40d3a03af6264ee1f2677fc261 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 00:56:10 +0200 Subject: [PATCH 063/164] _vcsh: Add completion for `list-untracked` and `status` --- _vcsh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/_vcsh b/_vcsh index a33551be..53eaada4 100644 --- a/_vcsh +++ b/_vcsh @@ -43,6 +43,10 @@ function _vcsh-list-tracked-by () { (( CURRENT == 2 )) && __vcsh_repositories } +function _vcsh-list-untracked () { + _nothing +} + function _vcsh-pull () { _nothing } @@ -66,6 +70,10 @@ function _vcsh-run () { fi } +function _vcsh-status () { + (( CURRENT == 2 )) && __vcsh_repositories +} + function _vcsh-upgrade () { (( CURRENT == 2 )) && __vcsh_repositories } @@ -97,6 +105,7 @@ function _vcsh () { "list:list all local vcsh repositories" "list-tracked:list all files tracked by vcsh" "list-tracked-by:list files tracked by a repository" + "list-untracked:list all files not tracked by vcsh" "pull:pull from all vcsh remotes" "push:push to vcsh remotes" "rename:rename a repository" From 09eef208e8d62408b0b7a1fd5d4cb04715b49358 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 00:57:01 +0200 Subject: [PATCH 064/164] Add documentation for `list-untracked` --- doc/vcsh.1.ronn | 9 +++++++++ vcsh | 1 + 2 files changed, 10 insertions(+) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 05da4fad..2d0a7abf 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -21,6 +21,8 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` list-tracked-by +`vcsh` list-untracked + `vcsh` pull `vcsh` push @@ -110,6 +112,13 @@ an interactive user. * list-tracked-by: List files tracked by a repository. +* list-untracked: + List all files NOT tracked by vcsh. + + By default, the file list is shallow and stops at directory levels where + possible. If you prefer to get a list of all files, append `-r` for + recursive mode. + * pull: Pull from all vcsh remotes. diff --git a/vcsh b/vcsh index 1d947d1a..a19aceb3 100755 --- a/vcsh +++ b/vcsh @@ -109,6 +109,7 @@ help() { list-tracked List all files tracked by vcsh list-tracked-by \\ List files tracked by a repository + list-untracked List all files not tracked by vcsh pull Pull from all vcsh remotes push Push to vcsh remotes rename \\ From 6480c1913a9853176fe527079680242dbf4d40a4 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 20:16:36 +0200 Subject: [PATCH 065/164] vcsh.1.ronn: Make the warning even more scary --- doc/vcsh.1.ronn | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index ebc9896f..4138c23d 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -261,9 +261,16 @@ locations are <$XDG_CONFIG_HOME/vcsh/overlays-available> and <$XDG_CONFIG_HOME/vcsh/overlays-enabled>. Overlays follow the same rules as hooks and you are free to overwrite any -and all functions. As the overlays will be sourced and you are replacing -arbitrary functions, any and all features may stop working, or you may even -lose data. You have been warned. +and all functions. Same as hooks, you can use global or repository-specific +overlays by using either <$VCSH_OVERLAY_D/$VCSH_COMMAND> or +<$VCSH_OVERLAY_D/$VCSH_REPO_NAME.$VCSH_COMMAND>. + +Please note that nothing stops you from, e.g. overwriting `status()` in +<$VCSH_OVERLAY_D/commit>. As the overlays will be sourced and you are +replacing arbitrary functions, any and all features may stop working, or you +may even lose data. + +You have been warned. ## DETAILED HOWTO AND FURTHER READING From 65b97e13fe2638f587c13521e2970a037d09eab2 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 20:37:29 +0200 Subject: [PATCH 066/164] vcsh: Allow `vcsh list-untracked ` --- doc/vcsh.1.ronn | 5 ++++- vcsh | 47 +++++++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 2d0a7abf..f82a8776 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -21,7 +21,7 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` list-tracked-by -`vcsh` list-untracked +`vcsh` list-untracked [<-r>] [] `vcsh` pull @@ -119,6 +119,9 @@ an interactive user. possible. If you prefer to get a list of all files, append `-r` for recursive mode. + If you want to list files not tracked by a specific repository, simply + append the repository's name last. + * pull: Pull from all vcsh remotes. diff --git a/vcsh b/vcsh index a19aceb3..044bdf08 100755 --- a/vcsh +++ b/vcsh @@ -109,7 +109,8 @@ help() { list-tracked List all files tracked by vcsh list-tracked-by \\ List files tracked by a repository - list-untracked List all files not tracked by vcsh + list-untracked \\ + [<-r>] [] List all files not tracked by all or one repositories pull Pull from all vcsh remotes push Push to vcsh remotes rename \\ @@ -292,7 +293,7 @@ list_untracked() { temp_file_untracked=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' temp_file_untracked_copy=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' - # Hack in support for `vcsh list-untracked -r` + # Hack in support for `vcsh list-untracked -r`... directory_opt="--directory" shift 1 while getopts "r" flag; do @@ -301,29 +302,39 @@ list_untracked() { fi shift 1 done + # ...and parse for a potential parameter afterwards. As we shifted things out of $* in during getops, we need to look at $1 + VCSH_REPO_NAME=$1; export VCSH_REPO_NAME - for VCSH_REPO_NAME in $(list); do - export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - git ls-files --others "$directory_opt" | ( - while read line; do - echo "$line" - directory_component=${line%%/*} - [ -d "$directory_component" ] && printf '%s/\n' "$directory_component" - done - ) | sort -u > $temp_file_others - if [ -z "$ran_once" ]; then - ran_once=1 - cp $temp_file_others $temp_file_untracked || fatal 'Could not copy temp file' - fi - cp $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not copy temp file' - comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked - done + if [ -n "$VCSH_REPO_NAME" ]; then + list_untracked_helper $VCSH_REPO_NAME + else + for VCSH_REPO_NAME in $(list); do + list_untracked_helper $VCSH_REPO_NAME + done + fi cat $temp_file_untracked unset directory_opt directory_component rm -f $temp_file_others $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not delete temp files' } +list_untracked_helper() { + export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" + git ls-files --others "$directory_opt" | ( + while read line; do + echo "$line" + directory_component=${line%%/*} + [ -d "$directory_component" ] && printf '%s/\n' "$directory_component" + done + ) | sort -u > $temp_file_others + if [ -z "$ran_once" ]; then + ran_once=1 + cp $temp_file_others $temp_file_untracked || fatal 'Could not copy temp file' + fi + cp $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not copy temp file' + comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked +} + rename() { git_dir_exists [ -d "$GIT_DIR_NEW" ] && fatal "'$GIT_DIR_NEW' exists" 54 From c03340ae79c2230828c3b3e15a314e167f637d2e Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 20:45:06 +0200 Subject: [PATCH 067/164] vcsh: Factor out code from status() into status_helper() --- vcsh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/vcsh b/vcsh index 9480b485..54026cf0 100755 --- a/vcsh +++ b/vcsh @@ -361,22 +361,23 @@ run() { status() { if [ -n "$VCSH_REPO_NAME" ]; then - GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - use - git status --short --untracked-files='no' - VCSH_COMMAND_RETURN_CODE=$? + status_helper $VCSH_REPO_NAME else for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME:" - GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - use - git status --short --untracked-files='no' - VCSH_COMMAND_RETURN_CODE=$? + status_helper $VCSH_REPO_NAME echo done fi } +status_helper() { + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + use + git status --short --untracked-files='no' + VCSH_COMMAND_RETURN_CODE=$? +} + upgrade() { hook pre-upgrade # fake-bare repositories are not bare, actually. Set this to false From 9d34717651df1d89b32257c5a74d7a16c955cbac Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 20:46:48 +0200 Subject: [PATCH 068/164] vcsh: Move list_untracked() into correct place --- vcsh | 60 ++++++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/vcsh b/vcsh index 54026cf0..c2b6ff47 100755 --- a/vcsh +++ b/vcsh @@ -259,36 +259,6 @@ list_tracked_by() { sed 's/[,\&]/\\&/g')," | sort -u } -pull() { - hook pre-pull - for VCSH_REPO_NAME in $(list); do - printf '%s: ' "$VCSH_REPO_NAME" - GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - use - git pull - VCSH_COMMAND_RETURN_CODE=$? - echo - done - hook post-pull -} - -push() { - hook pre-push - for VCSH_REPO_NAME in $(list); do - printf '%s: ' "$VCSH_REPO_NAME" - GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - use - git push - VCSH_COMMAND_RETURN_CODE=$? - echo - done - hook post-push -} - -retire() { - unset VCSH_DIRECTORY -} - list_untracked() { command -v 'comm' >/dev/null 2>&1 || fatal "Could not find 'comm'" @@ -338,6 +308,36 @@ list_untracked_helper() { comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked } +pull() { + hook pre-pull + for VCSH_REPO_NAME in $(list); do + printf '%s: ' "$VCSH_REPO_NAME" + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + use + git pull + VCSH_COMMAND_RETURN_CODE=$? + echo + done + hook post-pull +} + +push() { + hook pre-push + for VCSH_REPO_NAME in $(list); do + printf '%s: ' "$VCSH_REPO_NAME" + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + use + git push + VCSH_COMMAND_RETURN_CODE=$? + echo + done + hook post-push +} + +retire() { + unset VCSH_DIRECTORY +} + rename() { git_dir_exists [ -d "$GIT_DIR_NEW" ] && fatal "'$GIT_DIR_NEW' exists" 54 From 712cef9c4d816ff5960945f46f3a0a03e8921325 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 23 Oct 2014 21:02:17 +0200 Subject: [PATCH 069/164] vcsh: Replace `list-tracked-by` with `list-tracked ` Also, refactor list_tracked_by() to re-use code --- doc/vcsh.1.ronn | 9 ++++++--- vcsh | 25 +++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 9827d4ff..c91f6466 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -17,9 +17,7 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` list -`vcsh` list-tracked - -`vcsh` list-tracked-by +`vcsh` list-tracked [] `vcsh` list-untracked [<-r>] [] @@ -109,9 +107,14 @@ an interactive user. * list-tracked: List all files tracked by vcsh. + If you want to list files tracked by a specific repository, simply + append the repository's name last. + * list-tracked-by: List files tracked by a repository. + This is a legacy command; you should use `list-tracked ` instead. + * list-untracked: List all files NOT tracked by vcsh. diff --git a/vcsh b/vcsh index c2b6ff47..58ecb7f3 100755 --- a/vcsh +++ b/vcsh @@ -108,9 +108,8 @@ help() { help Display this help text init Initialize a new repository list List all repositories - list-tracked List all files tracked by vcsh - list-tracked-by \\ - List files tracked by a repository + list-tracked \\ + [] List all files tracked all or one repositories list-untracked \\ [<-r>] [] List all files not tracked by all or one repositories pull Pull from all vcsh remotes @@ -247,16 +246,22 @@ get_files() { } list_tracked() { - for VCSH_REPO_NAME in $(list); do - get_files - done | sed "s,^,$(printf '%s\n' "$VCSH_BASE/" | \ - sed 's/[,\&]/\\&/g')," | sort -u + VCSH_REPO_NAME=$2; export VCSH_REPO_NAME + if [ -n "$VCSH_REPO_NAME" ]; then + get_files | list_tracked_helper + else + for VCSH_REPO_NAME in $(list); do + get_files + done | list_tracked_helper + fi +} + +list_tracked_helper() { + sed "s,^,$(printf '%s\n' "$VCSH_BASE/" | sed 's/[,\&]/\\&/g')," | sort -u } list_tracked_by() { - use - git ls-files | sed "s,^,$(printf '%s\n' "$VCSH_BASE/" | \ - sed 's/[,\&]/\\&/g')," | sort -u + list_tracked $2 } list_untracked() { From 4e015a2e8ec5c3d8e3d6b266f883ea72b7011896 Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Fri, 24 Oct 2014 11:09:22 +0200 Subject: [PATCH 070/164] vcsh: Fail fast if the clone branch is not valid Also fixed the last hardcoded reference to the master branch. --- vcsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index 76502f53..200cab2b 100755 --- a/vcsh +++ b/vcsh @@ -147,16 +147,16 @@ clone() { hook pre-clone init git remote add origin "$GIT_REMOTE" + git checkout -b "$VCSH_BRANCH" || return $? git config branch."$VCSH_BRANCH".remote origin git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" - git checkout -b $VCSH_BRANCH if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then info "remote is empty, not merging anything" exit fi git fetch origin "$VCSH_BRANCH" hook pre-merge - git ls-tree -r --name-only origin/master | (while read object; do + git ls-tree -r --name-only origin/"$VCSH_BRANCH" | (while read object; do [ -e "$object" ] && error "'$object' exists." && VCSH_CONFLICT=1 From 0d43d6fb9186a776c55f51e00fcf557e2e5f7c57 Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Fri, 24 Oct 2014 11:22:41 +0200 Subject: [PATCH 071/164] doc/vcsh.1.ronn: Document clone [-b `branch`] --- doc/vcsh.1.ronn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 05da4fad..e7688825 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -5,7 +5,7 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` [] -`vcsh` clone [] +`vcsh` clone [-b ] [] `vcsh` delete @@ -86,6 +86,9 @@ an interactive user. If you need to clone a bundle of repositories, look into the `post-clone-retired` hook. + You can also use a single git repository with several branches. Use the `-b` + option to specify a branch at clone time, the default is `master`. + * commit: Commit in all repositories From 753682e70d01730f4d7adbcab3d2928286f3c6be Mon Sep 17 00:00:00 2001 From: mirabilos Date: Fri, 24 Oct 2014 11:52:02 +0200 Subject: [PATCH 072/164] permit "-b " to come later on the command line --- vcsh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/vcsh b/vcsh index 200cab2b..4ab17bfd 100755 --- a/vcsh +++ b/vcsh @@ -432,18 +432,28 @@ case $VCSH_COMMAND in esac if [ x"$VCSH_COMMAND" = x'clone' ]; then + VCSH_BRANCH= if [ "$2" = -b ]; then - VCSH_BRANCH="$3" + VCSH_BRANCH=$3 shift shift - else - VCSH_BRANCH=master fi [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify a remote" 1 GIT_REMOTE="$2" - [ -n "$3" ] && VCSH_REPO_NAME=$3 || VCSH_REPO_NAME=$(basename "${GIT_REMOTE#*:}" .git) + [ -n "$VCSH_BRANCH" ] || if [ "$3" = -b ]; then + VCSH_BRANCH=$4 + shift + shift + fi + if [ -n "$3" ]; then + VCSH_REPO_NAME=$3 + [ -z "$VCSH_BRANCH" ] && [ "$4" = -b ] && VCSH_BRANCH=$5 + else + VCSH_REPO_NAME=$(basename "${GIT_REMOTE#*:}" .git) + fi [ -z "$VCSH_REPO_NAME" ] && fatal "$VCSH_COMMAND: could not determine repository name" 1 export VCSH_REPO_NAME + [ -n "$VCSH_BRANCH" ] || VCSH_BRANCH=master GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR elif [ "$VCSH_COMMAND" = 'version' ]; then echo "$SELF $VERSION" From 11a4aef2d1663b1b3790ad34788227f9d299e1d9 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Fri, 24 Oct 2014 22:19:08 +0200 Subject: [PATCH 073/164] vcsh: support repo-specific config files --- vcsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vcsh b/vcsh index 58ecb7f3..2e96300c 100755 --- a/vcsh +++ b/vcsh @@ -573,6 +573,9 @@ check_dir "$VCSH_REPO_D" verbose "$VCSH_COMMAND begin" VCSH_COMMAND=$(echo "$VCSH_COMMAND" | sed 's/-/_/g'); export VCSH_COMMAND +# Source repo-specific configuration file +[ -r "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" ] && . "$XDG_CONFIG_HOME/vcsh/config.d/$VCSH_REPO_NAME" + # source overlay functions for overlay in "$VCSH_OVERLAY_D/$VCSH_COMMAND"* "$VCSH_OVERLAY_D/$VCSH_REPO_NAME.$VCSH_COMMAND"*; do [ -r "$overlay" ] || continue From 094c9de21caa66d6fa1ffe5700954fa2087f497c Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Fri, 9 May 2014 10:14:49 +0200 Subject: [PATCH 074/164] Use cowsay from the PATH instead --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9e3d5a22..ca6ebe68 100644 --- a/Makefile +++ b/Makefile @@ -47,4 +47,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 + @ which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..." From 7161ee4adc3f462f20ab9b55404ecf6968f2753f Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 25 Oct 2014 21:25:49 +0200 Subject: [PATCH 075/164] Release v1.20141025 --- CONTRIBUTORS | 4 ++++ changelog | 14 ++++++++++++++ vcsh | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 07456f9c..d7a33947 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -6,6 +6,7 @@ Eric Bouchut Dridi Boukelmoune Rob Cornish Vincent Demeester +Mert Dirik Jeff Fein-Worton Thomas Ferris Nicolaisen martin f. krafft @@ -17,6 +18,7 @@ Valentin Haenel Richard Hartmann Gregor Jasny Errietta Kostala +Yuval Langer Caleb Maclennan Markus Martin mek-apelsin @@ -26,10 +28,12 @@ Corey Quinn Pavlos Ratis Dewey Sasser Gernot Schulz +Aaron Schumacher Andrew Schwartzmeyer Dato Simó Alexander Skurikhin Jonathan Sternberg Frank Terbeck +mirabilos Aaron VonderHaar Tony diff --git a/changelog b/changelog index 1c09b670..badf4457 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,17 @@ +2014-10-25 Richard Hartmann + + * Release 1.20141025 + * `vcsh which dontexist` exits 1 + * `vcsh status` shows commits ahead/behind remote tracking branch + * Support overlay functions + * Support `vcsh list-untracked`, optionally recursively + * Support `vcsh list-untracked $repo` + * Improve error handling of clone() + * Rename `list-tracked-by` to `list-tracked ` + * Support repo-specific config files + * Various minor improvements + * More moo + 2014-10-09 Richard Hartmann * Display full paths in list-tracked* diff --git a/vcsh b/vcsh index 4464c85c..cf7d1a71 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # 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.20141009' +VERSION='1.20141025' SELF=$(basename $0) fatal() { From bad560c81296408c539da798f4f589f5fae4f723 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 25 Oct 2014 23:22:54 +0200 Subject: [PATCH 076/164] vcsh: FIX fatal() --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index af67e180..faba42ce 100755 --- a/vcsh +++ b/vcsh @@ -24,7 +24,7 @@ SELF=$(basename $0) fatal() { echo "$SELF: fatal: $1" >&2 - [ -z $2] && exit 1 + [ -z $2 ] && exit 1 exit $2 } From be1c81ee11c7c97d20dcb63b4f8d46febcbc875f Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 25 Oct 2014 23:23:05 +0200 Subject: [PATCH 077/164] vcsh: Improve clone() error handling --- vcsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index faba42ce..63e726ea 100755 --- a/vcsh +++ b/vcsh @@ -154,7 +154,8 @@ clone() { git config branch."$VCSH_BRANCH".remote origin git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then - info "remote is empty, not merging anything" + info "remote is empty, not merging anything. + You should add files to your new repository." exit fi git fetch origin "$VCSH_BRANCH" From 36fc049881253a38f0b72d6d6aeb01c1295b8a2c Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 26 Oct 2014 00:24:07 +0200 Subject: [PATCH 078/164] Release 1.20141026 --- changelog | 6 ++++++ vcsh | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index badf4457..9cc6c16f 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +2014-10-26 Richard Hartmann + + * Release 1.20141026 + * FIX fatal() + * Improve error handling of clone() + 2014-10-25 Richard Hartmann * Release 1.20141025 diff --git a/vcsh b/vcsh index 63e726ea..0f2c5af7 100755 --- a/vcsh +++ b/vcsh @@ -19,7 +19,7 @@ # 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.20141025' +VERSION='1.20141026' SELF=$(basename $0) fatal() { From dd7e32f2cbc2ad60bee86d8c3f5dffd436d360be Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 26 Oct 2014 01:04:13 +0200 Subject: [PATCH 079/164] Fix tests --- t/000-tear-env.t | 2 +- t/300-add.t | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/t/000-tear-env.t b/t/000-tear-env.t index afe261a8..6cb384f1 100644 --- a/t/000-tear-env.t +++ b/t/000-tear-env.t @@ -9,7 +9,7 @@ use Test::Most; chdir 't' or die $!; if (!-d 'etc') { - plan skip_all => 'No need to tear previous env.'; + plan skip_all => 'No need to tear down previous env.'; } ok rm_rf 'etc'; diff --git a/t/300-add.t b/t/300-add.t index 6c8b9cdf..58843c87 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -12,21 +12,24 @@ chdir 't/etc/' or die $!; $ENV{'HOME'} = abs_path ('.vcsh_home'); +chdir '.vcsh_home' or die $!; + eval { touch 'a'; }; die $@ if $@; -system ("./vcsh test1 add 'a'"); +system (".././vcsh test1 add 'a'"); -my $output = `./vcsh status`; +my $output = `.././vcsh status`; diag $output; ok $output eq "test1: -A a -", 'Adding a file worksl'; +A a + +", 'Adding a file works'; done_testing; From 8a02ff317d8767da2b826ad84d5c02236c38703d Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 1 Nov 2014 07:19:59 +0100 Subject: [PATCH 080/164] t/100-init.t: Update test to match new output --- t/100-init.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/100-init.t b/t/100-init.t index b7268684..f2b3a051 100644 --- a/t/100-init.t +++ b/t/100-init.t @@ -16,7 +16,7 @@ ok $output eq "", 'No repos set up yet.'; $output = `./vcsh init test1`; -ok $output eq "Initialized empty Git repository in " . $ENV{'HOME'} . "/.config/vcsh/repo.d/test1.git/\n"; +ok $output eq "Initialized empty shared Git repository in " . $ENV{'HOME'} . "/.config/vcsh/repo.d/test1.git/\n"; $output = `./vcsh status`; From ae830175f5c0e4896e54d2b140fc09b2e95b5b7a Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 1 Nov 2014 21:13:54 +0100 Subject: [PATCH 081/164] t/300-add.t: Get rid of useless diag() --- t/300-add.t | 2 -- 1 file changed, 2 deletions(-) diff --git a/t/300-add.t b/t/300-add.t index 58843c87..24d9a8ae 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -24,8 +24,6 @@ system (".././vcsh test1 add 'a'"); my $output = `.././vcsh status`; -diag $output; - ok $output eq "test1: A a From acf23397d3e19170d5d335e7b213920fe9d3db72 Mon Sep 17 00:00:00 2001 From: Mathias Svensson Date: Mon, 12 Jan 2015 09:13:32 +0100 Subject: [PATCH 082/164] Fixed typo in vcsh.1.ronn --- doc/vcsh.1.ronn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 1d432c3a..cd73ca8b 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -17,7 +17,7 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` list -`vcsh` list-tracked [] +`vcsh` list-tracked [] `vcsh` list-untracked [<-r>] [] From 13314340640e3ad23d9b39cf91695615e8a17c33 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 11 Feb 2015 19:49:46 +0100 Subject: [PATCH 083/164] Makefile: Add `prove` to make test --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ca6ebe68..d9396248 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,8 @@ purge: uninstall rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(ZSHDIR) test: - @if which git > /dev/null ; then :; else echo "'git' not found, exiting..."; exit 1; fi + @if which git > /dev/null; then : ; else echo "'git' not found, exiting..."; exit 1; fi + @if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi moo: @ which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..." From 0f751fa01fb830163b378c9559fb6eae8cba4b46 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 11 Feb 2015 19:51:50 +0100 Subject: [PATCH 084/164] Add pre-commit hook into tools/ --- tools/hooks/pre-commit | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100755 tools/hooks/pre-commit diff --git a/tools/hooks/pre-commit b/tools/hooks/pre-commit new file mode 100755 index 00000000..ddb0550d --- /dev/null +++ b/tools/hooks/pre-commit @@ -0,0 +1,7 @@ +#!/bin/sh + +# Unfortunately, Git decided to set those two during pre-commit +unset GIT_DIR +unset GIT_INDEX_FILE + +prove From baabd32f2b2ac183013dd4a2bad7d6f2eeca777d Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 11 Feb 2015 20:10:46 +0100 Subject: [PATCH 085/164] Makefile: Delete correct doc dir Seems not a lot of people `make purge`... --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d9396248..21be0527 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ uninstall: purge: uninstall rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(PREFIX)/bin/ rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(PREFIX)/share/man/man1/ - rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(DOCDIR_PREFIX) + rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(DOCDIR) rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(ZSHDIR) test: From 2e13fbee53bebdd23978c760e544cd71ffd688d7 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 15:28:40 +0100 Subject: [PATCH 086/164] CONTRIBUTORS: Update --- CONTRIBUTORS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index d7a33947..cf286198 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -11,6 +11,7 @@ Jeff Fein-Worton Thomas Ferris Nicolaisen martin f. krafft Alessandro Ghedini +Dennis Gilmore Thorsten Glaser G.raud Mikhail Gusarov @@ -33,6 +34,7 @@ Andrew Schwartzmeyer Dato Simó Alexander Skurikhin Jonathan Sternberg +Mathias Svensson Frank Terbeck mirabilos Aaron VonderHaar From 57d96733295ca2f7627c6b56b231a84ead74dd1c Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 15:41:19 +0100 Subject: [PATCH 087/164] Makefile: Formatting --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 21be0527..b9154e7f 100644 --- a/Makefile +++ b/Makefile @@ -44,8 +44,8 @@ purge: uninstall rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(ZSHDIR) test: - @if which git > /dev/null; then : ; else echo "'git' not found, exiting..."; exit 1; fi - @if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi + @if which git > /dev/null; then : ; else echo "'git' not found, exiting..." ; exit 1; fi + @if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi moo: - @ which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..." + @which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..." From 4cb8aba0524ab88f7c5903a74761f3afdc5d910d Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 16:05:28 +0100 Subject: [PATCH 088/164] Initial support for Travis CI --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..53cebb08 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: perl +install: + - apt-get install git ruby-ronn +script: + - make test From f8797c958c8d7b33d204d6f04c4d01e897b8ea9d Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 16:33:48 +0100 Subject: [PATCH 089/164] .travis.yml: %s/^\t/ / --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 53cebb08..46e5dfb2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: perl install: - - apt-get install git ruby-ronn + - apt-get install git ruby-ronn script: - - make test + - make test From de2dae3f098322537efa91a80001add0de1e1822 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 16:39:08 +0100 Subject: [PATCH 090/164] .travis.yml: Use sudo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 46e5dfb2..6c85d5ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: perl install: - - apt-get install git ruby-ronn + - sudo apt-get install git ruby-ronn script: - make test From 1a7ec512ee5ec4516662f5aaf3c23bded83cd6d9 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 16:47:42 +0100 Subject: [PATCH 091/164] .travis.yml: Add build dep on libshell-command-perl --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6c85d5ad..471e4e2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: perl install: - - sudo apt-get install git ruby-ronn + - sudo apt-get install git ruby-ronn libshell-command-perl script: - make test From 69dfedd1027e29733eefd7be8997b409951afdf4 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 17:08:16 +0100 Subject: [PATCH 092/164] .travis.yml: Use built-in system for Perl deps --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 471e4e2d..617de6af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,8 @@ language: perl +before_install: + - cpanm Shell::Command + - cpanm Test::Most install: - - sudo apt-get install git ruby-ronn libshell-command-perl + - sudo apt-get install git ruby-ronn script: - make test From 7c35ece683f3b9a2907ebc45947bde4099596793 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 17:30:02 +0100 Subject: [PATCH 093/164] README.md: Add Travis CI build state --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 763b7c46..9803293a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -vcsh - Version Control System for $HOME - multiple Git repositories in $HOME +vcsh - Version Control System for $HOME - multiple Git repositories in $HOME [![Build Status](https://travis-ci.org/RichiH/vcsh.svg)](https://travis-ci.org/RichiH/vcsh) # Index From e3790a198453cccba3024b5909ade333c125fed7 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 17:31:16 +0100 Subject: [PATCH 094/164] README.md: Formatting --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9803293a..28f3076b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -vcsh - Version Control System for $HOME - multiple Git repositories in $HOME [![Build Status](https://travis-ci.org/RichiH/vcsh.svg)](https://travis-ci.org/RichiH/vcsh) +vcsh - Version Control System for $HOME - multiple Git repositories in $HOME +[![Build Status](https://travis-ci.org/RichiH/vcsh.svg)](https://travis-ci.org/RichiH/vcsh) # Index From 05fc1329e7aae571e92727dfa9653e0863be6497 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 17:40:58 +0100 Subject: [PATCH 095/164] .travis.yml: Less spam --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 617de6af..9f447180 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,3 +6,7 @@ install: - sudo apt-get install git ruby-ronn script: - make test +notifications: + email: + on_success: change + on_failure: always From e052f1aa9eb4c92d8b1ed825461c94c51616b5d6 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 17:48:38 +0100 Subject: [PATCH 096/164] .travis.yml: moo Needs more cowbell --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9f447180..e27671ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,10 +2,13 @@ language: perl before_install: - cpanm Shell::Command - cpanm Test::Most + - apt-get moo install: - sudo apt-get install git ruby-ronn script: - make test +after_script: + - make moo notifications: email: on_success: change From fbb40d76e1e3adcd6466c1a8f1e1b562e785f38c Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 23 Feb 2015 19:08:01 +0100 Subject: [PATCH 097/164] .travis.yml: moo dependencies --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e27671ae..cedf4fae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ before_install: - cpanm Test::Most - apt-get moo install: - - sudo apt-get install git ruby-ronn + - sudo apt-get install cowsay git ruby-ronn script: - make test after_script: From d37468d945fe652fdd4812294f53fb769b3eb134 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 24 Feb 2015 20:08:28 +0100 Subject: [PATCH 098/164] README.md: Use build tag for master --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 28f3076b..f885b4a3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ vcsh - Version Control System for $HOME - multiple Git repositories in $HOME -[![Build Status](https://travis-ci.org/RichiH/vcsh.svg)](https://travis-ci.org/RichiH/vcsh) + +[![Build Status](https://travis-ci.org/RichiH/vcsh.svg?branch=master)](https://travis-ci.org/RichiH/vcsh) # Index From 6448c9a84c6ea0abe9a958b57333a798ba875f4f Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Fri, 27 Feb 2015 09:58:43 +0100 Subject: [PATCH 099/164] vcsh stat --terse only shows repositories with changes, which makes it suitable to be run during login shell startup. --- vcsh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/vcsh b/vcsh index 0f2c5af7..2f502619 100755 --- a/vcsh +++ b/vcsh @@ -119,7 +119,8 @@ help() { Rename repository run \\ Use this repository - status [] Show statuses of all/one vcsh repositories + status \\ + [--terse] [] Show statuses of all/one vcsh repositories upgrade Upgrade repository to currently recommended settings version Print version information which Find substring in name of any tracked file @@ -367,19 +368,23 @@ run() { } status() { + if [ -t 1 ]; then + COLORING="-c color.status=always" + fi if [ -n "$VCSH_REPO_NAME" ]; then status_helper $VCSH_REPO_NAME else for VCSH_REPO_NAME in $(list); do - echo "$VCSH_REPO_NAME:" - status_helper $VCSH_REPO_NAME - echo + STATUS=$(status_helper $VCSH_REPO_NAME "$COLORING") + [ -n "$STATUS" -o -z "$VCSH_STATUS_TERSE" ] && echo "$VCSH_REPO_NAME:" + [ -n "$STATUS" ] && echo "$STATUS" + [ -z "$VCSH_STATUS_TERSE" ] && echo done fi } status_helper() { - GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR + GIT_DIR=$VCSH_REPO_D/$1.git; export GIT_DIR use remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && { commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) @@ -387,7 +392,7 @@ status_helper() { [ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits" [ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits" } - git status --short --untracked-files='no' + git $2 status --short --untracked-files='no' VCSH_COMMAND_RETURN_CODE=$? } @@ -554,6 +559,11 @@ elif [ x"$VCSH_COMMAND" = x'commit' ] || [ x"$VCSH_COMMAND" = x'push' ]; then : elif [ x"$VCSH_COMMAND" = x'status' ]; then + if [ x"$2" = x'--terse' ]; then + VCSH_STATUS_TERSE=1 + export VCSH_STATUS_TERSE + shift + fi VCSH_REPO_NAME=$2; export VCSH_REPO_NAME elif [ -n "$2" ]; then VCSH_COMMAND='run'; export VCSH_COMMAND From 6910f91e58bd8ad8b0436c577bf38b6ccb9a2860 Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Mon, 2 Mar 2015 19:17:40 +0100 Subject: [PATCH 100/164] Add test for terse status output --- t/300-add.t | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/300-add.t b/t/300-add.t index 24d9a8ae..bec8e7d7 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -29,5 +29,11 @@ A a ", 'Adding a file works'; +my $output = `.././vcsh status --terse`; + +ok $output eq "test1: +A a +", 'Terse output works'; + done_testing; From c040eb7b500fdca74e28022cfba86180b714207f Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Mon, 2 Mar 2015 19:24:08 +0100 Subject: [PATCH 101/164] Fix tests under git 2.2 'branches' directory was obsolete and finally removed in recent git versions. --- t/100-init.t | 1 - 1 file changed, 1 deletion(-) diff --git a/t/100-init.t b/t/100-init.t index f2b3a051..b25499e5 100644 --- a/t/100-init.t +++ b/t/100-init.t @@ -25,7 +25,6 @@ ok $output eq "test1:\n\n", 'Our new repo is there'; chdir $ENV{"HOME"} . '/.config/vcsh/repo.d/test1.git/' or die $!; ok -f 'HEAD'; -ok -d 'branches'; ok -f 'config'; ok -f 'description'; ok -d 'hooks'; From 00e3e4ee67e7724e8b90f32abc67c05ac37720b7 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Fri, 3 Apr 2015 19:36:10 +0200 Subject: [PATCH 102/164] vcsh: Implement skeleton of `vcsh foreach` No help, completion, or other related updates --- vcsh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vcsh b/vcsh index 0f2c5af7..a5c3f487 100755 --- 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' ] || From bcca0cb6d41727819fe0e2ced837d322f67972c7 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 13 Apr 2015 07:11:53 +0200 Subject: [PATCH 103/164] doc/INSTALL.md: Specify how to install as user --- doc/INSTALL.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 29c98891..65fc5f3b 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -14,6 +14,12 @@ There are no other dependencies other than `git`, `ronn` and a POSIX shell. sudo make install +## Installing without root privileges ## + + make install DESTDIR=/home/myuser/local + +or simply copy the shell script into any place you like, e.g. `~/bin` + # Uninstalling # From d921399d97e499b69ed5c9ed98cef69e61704791 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 13 Apr 2015 09:16:27 +0200 Subject: [PATCH 104/164] vcsh: Fix foreach() --- vcsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index a5c3f487..6ffd9643 100755 --- a/vcsh +++ b/vcsh @@ -217,9 +217,10 @@ enter() { foreach() { hook pre-foreach for VCSH_REPO_NAME in $(list); do + echo "$VCSH_REPO_NAME:" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - "$@" + git "$@" done hook post-foreach } From 65c7cdcd62055286a254bb0d3ce6cc4459673dc0 Mon Sep 17 00:00:00 2001 From: Eli Young Date: Tue, 14 Apr 2015 16:46:43 -0700 Subject: [PATCH 105/164] vcsh: list_untracked(): remove --nocheck-order `--nocheck-order` is only supported by GNU `comm`, but it isn't necessary anyway because we sort the inputs first. --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 0f2c5af7..51f2d212 100755 --- a/vcsh +++ b/vcsh @@ -312,7 +312,7 @@ list_untracked_helper() { cp $temp_file_others $temp_file_untracked || fatal 'Could not copy temp file' fi cp $temp_file_untracked $temp_file_untracked_copy || fatal 'Could not copy temp file' - comm -12 --nocheck-order $temp_file_others $temp_file_untracked_copy > $temp_file_untracked + comm -12 $temp_file_others $temp_file_untracked_copy > $temp_file_untracked } pull() { From 6e46f0490d63afe2fa8d3420eae1b31c524f4b95 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Wed, 6 May 2015 15:34:49 +0200 Subject: [PATCH 106/164] Update copyright info --- doc/vcsh.1.ronn | 2 +- vcsh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index cd73ca8b..19daed5f 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -339,7 +339,7 @@ This manpage and `vcsh` itself were written by Richard "RichiH" Hartmann. ## COPYRIGHT -Copyright 2011-2013 Richard Hartmann +Copyright 2011-2015 Richard Hartmann Licensed under the GNU GPL version 2 or higher. diff --git a/vcsh b/vcsh index 51f2d212..f3224b70 100755 --- a/vcsh +++ b/vcsh @@ -1,7 +1,7 @@ #!/bin/sh # This program is licensed under the GNU GPL version 2 or later. -# (c) Richard "RichiH" Hartmann , 2011-2014 +# (c) Richard "RichiH" Hartmann , 2011-2015 # For details, see LICENSE. To submit patches, you have to agree to # license your code under the GNU GPL version 2 or later. From 620f88afcf0806fe5e522887f224ac608b28ffd8 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 18 May 2015 09:07:13 +0200 Subject: [PATCH 107/164] t/300-add.t: Fix warning t/300-add.t ........ "my" variable $output masks earlier declaration in same scope at t/300-add.t line 32. --- t/300-add.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/300-add.t b/t/300-add.t index bec8e7d7..4acd0a2c 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -29,7 +29,7 @@ A a ", 'Adding a file works'; -my $output = `.././vcsh status --terse`; +$output = `.././vcsh status --terse`; ok $output eq "test1: A a From 6c3fa632c62fc3e381ba8404692d24cfad290ad7 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 18 May 2015 09:19:58 +0200 Subject: [PATCH 108/164] vcsh: Prepare status() for vcsh longopts --- vcsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vcsh b/vcsh index 2f502619..a630f976 100755 --- a/vcsh +++ b/vcsh @@ -377,7 +377,7 @@ status() { for VCSH_REPO_NAME in $(list); do STATUS=$(status_helper $VCSH_REPO_NAME "$COLORING") [ -n "$STATUS" -o -z "$VCSH_STATUS_TERSE" ] && echo "$VCSH_REPO_NAME:" - [ -n "$STATUS" ] && echo "$STATUS" + [ -n "$STATUS" ] && echo "$STATUS" [ -z "$VCSH_STATUS_TERSE" ] && echo done fi @@ -385,6 +385,7 @@ status() { status_helper() { GIT_DIR=$VCSH_REPO_D/$1.git; export GIT_DIR + VCSH_GIT_OPTIONS=$2 use remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && { commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) @@ -392,7 +393,7 @@ status_helper() { [ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits" [ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits" } - git $2 status --short --untracked-files='no' + git ${VCSH_GIT_OPTIONS} status --short --untracked-files='no' VCSH_COMMAND_RETURN_CODE=$? } @@ -560,8 +561,7 @@ elif [ x"$VCSH_COMMAND" = x'commit' ] || : elif [ x"$VCSH_COMMAND" = x'status' ]; then if [ x"$2" = x'--terse' ]; then - VCSH_STATUS_TERSE=1 - export VCSH_STATUS_TERSE + VCSH_STATUS_TERSE=1; export VCSH_STATUS_TERSE shift fi VCSH_REPO_NAME=$2; export VCSH_REPO_NAME From d5c11e43b9e6e8fb25206af2a56da6381a4a00e4 Mon Sep 17 00:00:00 2001 From: Florian Engel Date: Mon, 25 May 2015 20:38:39 +0200 Subject: [PATCH 109/164] t/100-init.t: Fix failure due to locale --- t/100-init.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/100-init.t b/t/100-init.t index f2b3a051..f8cb5ef2 100644 --- a/t/100-init.t +++ b/t/100-init.t @@ -14,7 +14,7 @@ my $output = `./vcsh status`; ok $output eq "", 'No repos set up yet.'; -$output = `./vcsh init test1`; +$output = `LC_ALL=C ./vcsh init test1`; ok $output eq "Initialized empty shared Git repository in " . $ENV{'HOME'} . "/.config/vcsh/repo.d/test1.git/\n"; From 87df0c6008bb726924da6812f536322bb36ff948 Mon Sep 17 00:00:00 2001 From: Mikhail Gusarov Date: Thu, 20 Aug 2015 12:02:36 +0200 Subject: [PATCH 110/164] Fix broken list-tracked-by -- list_tracked expects repository at $2 --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 8bfafab1..d9877b9f 100755 --- a/vcsh +++ b/vcsh @@ -264,7 +264,7 @@ list_tracked_helper() { } list_tracked_by() { - list_tracked $2 + list_tracked '' $2 } list_untracked() { From eca56c3347364f2dbf754f4ffa871069a9f26c7d Mon Sep 17 00:00:00 2001 From: Don Date: Mon, 21 Sep 2015 17:49:26 -0400 Subject: [PATCH 111/164] vcsh: Always fast forward initial merge Ignore `merge.ff = no` if set in .gitconfig. --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 8bfafab1..4ea31258 100755 --- a/vcsh +++ b/vcsh @@ -169,7 +169,7 @@ clone() { [ x"$VCSH_CONFLICT" = x'1' ]) && fatal "will stop after fetching and not try to merge! Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 - git merge origin/"$VCSH_BRANCH" + git -c merge.ff=true merge origin/"$VCSH_BRANCH" hook post-merge hook post-clone retire From 6d3e9d21d1bfa0a024bbf5758c6f6e55086deac8 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 29 Nov 2015 12:41:37 +0100 Subject: [PATCH 112/164] vcsh: Default to `git ls-files --exclude-standard` github: Closes richih/vcsh#181 --- doc/vcsh.1.ronn | 12 +++++++----- vcsh | 12 ++++++++---- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 19daed5f..2bf8a77e 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -19,7 +19,7 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` list-tracked [] -`vcsh` list-untracked [<-r>] [] +`vcsh` list-untracked [<-a>] [<-r>] [] `vcsh` pull @@ -121,12 +121,14 @@ an interactive user. * list-untracked: List all files NOT tracked by vcsh. + `-a`: Show all files. + By default, the `git ls-files --exclude-standard` is called. + + `-r`: Recursive mode. By default, the file list is shallow and stops at directory levels where - possible. If you prefer to get a list of all files, append `-r` for - recursive mode. + possible. - If you want to list files not tracked by a specific repository, simply - append the repository's name last. + `$repo`: List files not tracked by this specific repository. * pull: Pull from all vcsh remotes. diff --git a/vcsh b/vcsh index 8bfafab1..4da3547d 100755 --- a/vcsh +++ b/vcsh @@ -112,7 +112,8 @@ help() { list-tracked \\ [] List all files tracked all or one repositories list-untracked \\ - [<-r>] [] List all files not tracked by all or one repositories + [<-a>] [<-r>] + [] List all files not tracked by all or one repositories pull Pull from all vcsh remotes push Push to vcsh remotes rename \\ @@ -275,10 +276,13 @@ list_untracked() { temp_file_untracked_copy=$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX") || fatal 'Could not create temp file' # Hack in support for `vcsh list-untracked -r`... + exclude_standard_opt='--exclude-standard' directory_opt="--directory" shift 1 - while getopts "r" flag; do - if [ x"$1" = x'-r' ]; then + while getopts "ar" flag; do + if [ x"$1" = x'-a' ]; then + unset exclude_standard_opt + elif [ x"$1" = x'-r' ]; then unset directory_opt fi shift 1 @@ -301,7 +305,7 @@ list_untracked() { list_untracked_helper() { export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" - git ls-files --others "$directory_opt" | ( + git ls-files --others $exclude_standard_opt "$directory_opt" | ( while read line; do echo "$line" directory_component=${line%%/*} From 9cf8f5c46b230abd912657aeac276e4a2ce38ce0 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 29 Nov 2015 13:33:45 +0100 Subject: [PATCH 113/164] vcsh: Fix regression introduced in d946b07817ffe6e github: Closes richih/vcsh#168 --- vcsh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/vcsh b/vcsh index 8bfafab1..ff256dad 100755 --- a/vcsh +++ b/vcsh @@ -425,12 +425,16 @@ use() { } which() { - [ -e "$VCSH_COMMAND_PARAMETER" ] || fatal "'$VCSH_COMMAND_PARAMETER' does not exist" 1 - for VCSH_REPO_NAME in $(list); do + output=$(for VCSH_REPO_NAME in $(list); do for VCSH_FILE in $(get_files); do echo "$VCSH_FILE" | grep -q "$VCSH_COMMAND_PARAMETER" && echo "$VCSH_REPO_NAME: $VCSH_FILE" done - done | sort -u + done | sort -u) + if [ -z "$output" ]; then + fatal "'$VCSH_COMMAND_PARAMETER' does not exist" 1 + else + echo "$output" + fi } write_gitignore() { From f208e3d44c625878a2fafbf7037ab6350432b83c Mon Sep 17 00:00:00 2001 From: Felix Eckhofer Date: Tue, 16 Jun 2015 01:46:28 +0200 Subject: [PATCH 114/164] Speed up `which` by avoiding a loop --- vcsh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vcsh b/vcsh index 8bfafab1..11370f89 100755 --- a/vcsh +++ b/vcsh @@ -427,9 +427,7 @@ use() { which() { [ -e "$VCSH_COMMAND_PARAMETER" ] || fatal "'$VCSH_COMMAND_PARAMETER' does not exist" 1 for VCSH_REPO_NAME in $(list); do - for VCSH_FILE in $(get_files); do - echo "$VCSH_FILE" | grep -q "$VCSH_COMMAND_PARAMETER" && echo "$VCSH_REPO_NAME: $VCSH_FILE" - done + get_files | grep -- "$VCSH_COMMAND_PARAMETER" | sed "s/^/$VCSH_REPO_NAME: /" done | sort -u } From b40cd1a7fe1c45bd1f7f7f80802b157a41f97dfe Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 29 Nov 2015 21:40:41 +0100 Subject: [PATCH 115/164] vcsh: Handle Git older than 2.x We will fetch more data than needed with Git 1.8, but other than that... --- vcsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index c30b12d1..d77f7cc8 100755 --- a/vcsh +++ b/vcsh @@ -159,7 +159,12 @@ clone() { You should add files to your new repository." exit fi - git fetch origin "$VCSH_BRANCH" + GIT_VERSION_MAJOR=$(git --version | sed -n 's/.* \([0-9]\)\..*/\1/p' ) + if [ 2 -ge "$GIT_VERSION_MAJOR" ];then + git fetch origin "$VCSH_BRANCH" + else + git fetch origin + fi hook pre-merge git ls-tree -r --name-only origin/"$VCSH_BRANCH" | (while read object; do [ -e "$object" ] && From 9f245df98e8118d8ae829ac201bb62eca3938dd8 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 19 Dec 2015 08:05:31 +0100 Subject: [PATCH 116/164] _vcsh: Remove stale completion --- _vcsh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/_vcsh b/_vcsh index 53eaada4..35651eb6 100644 --- a/_vcsh +++ b/_vcsh @@ -36,10 +36,6 @@ function _vcsh-list () { } function _vcsh-list-tracked () { - _nothing -} - -function _vcsh-list-tracked-by () { (( CURRENT == 2 )) && __vcsh_repositories } From 2cc7ffcd61352b55d7c010c7524a739b3fe13c80 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 19 Dec 2015 11:38:20 +0100 Subject: [PATCH 117/164] Document `vcsh foreach` --- _vcsh | 5 +++++ doc/vcsh.1.ronn | 7 +++++++ vcsh | 14 +++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/_vcsh b/_vcsh index 53eaada4..6562dc52 100644 --- a/_vcsh +++ b/_vcsh @@ -23,6 +23,10 @@ function _vcsh-enter () { (( CURRENT == 2 )) && __vcsh_repositories } +function _vcsh-foreach () { + _dispatch git git +} + function _vcsh-help () { _nothing } @@ -100,6 +104,7 @@ function _vcsh () { "commit:commit in all repositories" "delete:delete an existing repository" "enter:enter repository; spawn new <\$SHELL>" + "foreach:execute for all repos" "help:display help" "init:initialize an empty repository" "list:list all local vcsh repositories" diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 2bf8a77e..d5ee0dc5 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -11,6 +11,8 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` enter +`vcsh` foreach [-g] + `vcsh` help `vcsh` init @@ -98,6 +100,11 @@ an interactive user. * enter: Enter repository; spawn new <$SHELL>. +* foreach: + Execute git command for every vcsh repository. + + `-g`: Execute in general context. + * help: Display help. diff --git a/vcsh b/vcsh index 18faf4c1..06f6c331 100755 --- a/vcsh +++ b/vcsh @@ -106,6 +106,8 @@ help() { commit Commit in all repositories delete Delete an existing repository enter Enter repository; spawn new instance of \$SHELL + foreach [<-g>] + Execute a command for every repository help Display this help text init Initialize a new repository list List all repositories @@ -218,11 +220,21 @@ enter() { foreach() { hook pre-foreach + + # We default to prefixing `git` to all commands passed to foreach, but + # allow running in general context with -g + command_prefix=git + while getopts "g" flag; do + if [ x"$1" = x'-g' ]; then + unset command_prefix + fi + shift 1 + done for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME:" GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - git "$@" + $command_prefix "$@" done hook post-foreach } From 29b6c287d196c01091d6fbadf511aa387d74e2a2 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 19 Dec 2015 11:39:26 +0100 Subject: [PATCH 118/164] _vcsh: Remove list-tracked-by completely --- _vcsh | 1 - 1 file changed, 1 deletion(-) diff --git a/_vcsh b/_vcsh index 35651eb6..73a04a59 100644 --- a/_vcsh +++ b/_vcsh @@ -100,7 +100,6 @@ function _vcsh () { "init:initialize an empty repository" "list:list all local vcsh repositories" "list-tracked:list all files tracked by vcsh" - "list-tracked-by:list files tracked by a repository" "list-untracked:list all files not tracked by vcsh" "pull:pull from all vcsh remotes" "push:push to vcsh remotes" From 2c13ac4b6501fac484aef891a92a7e736401ebe9 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 19 Dec 2015 16:28:54 +0100 Subject: [PATCH 119/164] vcsh: Fix condition in clone() --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d77f7cc8..98dd71ee 100755 --- a/vcsh +++ b/vcsh @@ -160,7 +160,7 @@ clone() { exit fi GIT_VERSION_MAJOR=$(git --version | sed -n 's/.* \([0-9]\)\..*/\1/p' ) - if [ 2 -ge "$GIT_VERSION_MAJOR" ];then + if [ 1 -lt "$GIT_VERSION_MAJOR" ];then git fetch origin "$VCSH_BRANCH" else git fetch origin From 3e6f33668ac3507812168b6118bcb05bee572c8c Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 19 Dec 2015 16:59:56 +0100 Subject: [PATCH 120/164] .travis.yml: Try to work around Travis CI Seems their infrastructure migration went not quite as expected... --- .travis.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index cedf4fae..283e17ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,13 @@ language: perl -before_install: - - cpanm Shell::Command - - cpanm Test::Most - - apt-get moo -install: - - sudo apt-get install cowsay git ruby-ronn +sudo: false +addons: + apt: + packages: + - cowsay + - git + - libshell-command-perl + - libtest-most-perl + - ruby-ronn script: - make test after_script: From 5245aa481f117049480de35d6b8eb984701ae72f Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 22 Dec 2015 21:44:47 +0100 Subject: [PATCH 121/164] Revert ".travis.yml: Try to work around Travis CI" This reverts commit 3e6f33668ac3507812168b6118bcb05bee572c8c. --- .travis.yml | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 283e17ee..cedf4fae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,10 @@ language: perl -sudo: false -addons: - apt: - packages: - - cowsay - - git - - libshell-command-perl - - libtest-most-perl - - ruby-ronn +before_install: + - cpanm Shell::Command + - cpanm Test::Most + - apt-get moo +install: + - sudo apt-get install cowsay git ruby-ronn script: - make test after_script: From 4dde85340f627e187dad582610e881314404ab53 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 22 Dec 2015 21:45:08 +0100 Subject: [PATCH 122/164] .travis.yml: Fix Travis CI Turns out you need to `apt-get update` all of a sudden... --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cedf4fae..be5a1d79 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ before_install: - cpanm Test::Most - apt-get moo install: + - sudo apt-get update - sudo apt-get install cowsay git ruby-ronn script: - make test From cd83d7718b378f58bff84c9d32e8dc71f585f360 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 29 Dec 2015 16:18:33 +0100 Subject: [PATCH 123/164] Revert "t/100-init.t: Fix failure due to locale" This reverts commit d5c11e43b9e6e8fb25206af2a56da6381a4a00e4. --- t/100-init.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/100-init.t b/t/100-init.t index 80a10c9e..b25499e5 100644 --- a/t/100-init.t +++ b/t/100-init.t @@ -14,7 +14,7 @@ my $output = `./vcsh status`; ok $output eq "", 'No repos set up yet.'; -$output = `LC_ALL=C ./vcsh init test1`; +$output = `./vcsh init test1`; ok $output eq "Initialized empty shared Git repository in " . $ENV{'HOME'} . "/.config/vcsh/repo.d/test1.git/\n"; From 6622c3b35cda7d1d94d25ba53b7895ab621b5210 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 29 Dec 2015 17:32:07 +0100 Subject: [PATCH 124/164] Handle the French locale in reproducible builds slightly less hamfistedly Thanks to Matt S Trout --- t/100-init.t | 2 ++ 1 file changed, 2 insertions(+) diff --git a/t/100-init.t b/t/100-init.t index b25499e5..74facc02 100644 --- a/t/100-init.t +++ b/t/100-init.t @@ -1,5 +1,7 @@ #!/usr/bin/perl +BEGIN { $ENV{LC_ALL} = 'C' } + use strict; use warnings; From d2617e58f540f3c4ee43149b32a233cf55371029 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 29 Dec 2015 23:58:40 +0100 Subject: [PATCH 125/164] vcsh: Pass options through to commit --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 98e0acd3..e77ca08d 100755 --- a/vcsh +++ b/vcsh @@ -190,7 +190,7 @@ commit() { echo "$VCSH_REPO_NAME: " GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - git commit --untracked-files=no --quiet + git commit --untracked-files=no --quiet $@ VCSH_COMMAND_RETURN_CODE=$? echo done From a82dfd998413a033234b6e604200331e64f8528f Mon Sep 17 00:00:00 2001 From: Jochen Keil Date: Sun, 14 Feb 2016 22:02:33 +0100 Subject: [PATCH 126/164] Fix write_gitignore for git version >= 2.7 As of git version 2.7 it is no longer necessary to include parent directories in the list of files not to be ignored. This fixes #195. --- vcsh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/vcsh b/vcsh index 98e0acd3..d4e1ba0e 100755 --- a/vcsh +++ b/vcsh @@ -476,14 +476,21 @@ write_gitignore() { use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 + local GIT_VERSION=$(git --version) + local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\)\..*/\1/p') + local GIT_VERSION_MINOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\)\.\([0-9]\)\..*/\2/p') OLDIFS=$IFS IFS=$(printf '\n\t') gitignores=$(for file in $(git ls-files); do - while true; do - echo "$file"; new=${file%/*} - [ x"$file" = x"$new" ] && break - file=$new - done; + if [ $GIT_VERSION_MAJOR -ge 2 -a $GIT_VERSION_MINOR -ge 7 ]; then + echo "$file"; + else + while true; do + echo "$file"; new=${file%/*} + [ x"$file" = x"$new" ] && break + file=$new + done; + fi done | sort -u) # Contrary to GNU mktemp, mktemp on BSD/OSX requires a template for temp files From 6909ac8d1d9df4544d5f0584682d37e43ed354d9 Mon Sep 17 00:00:00 2001 From: Don March Date: Sat, 26 Mar 2016 14:12:07 -0400 Subject: [PATCH 127/164] Fix git version parsing when there are spaces --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index f9bea25d..de1b419f 100755 --- a/vcsh +++ b/vcsh @@ -476,7 +476,7 @@ write_gitignore() { use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 - local GIT_VERSION=$(git --version) + local GIT_VERSION="$(git --version)" local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\)\..*/\1/p') local GIT_VERSION_MINOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\)\.\([0-9]\)\..*/\2/p') OLDIFS=$IFS From ac191fb2de266e9209f5662c202be24be473edd0 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Mon, 20 Jun 2016 02:08:10 +0530 Subject: [PATCH 128/164] Fix documentation for running git commands Fixes #204 --- doc/vcsh.1.ronn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index d5ee0dc5..45b8c831 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -41,7 +41,7 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` write-gitignore -`vcsh` +`vcsh` `vcsh` @@ -173,7 +173,7 @@ an interactive user. Write .gitignore.d/ via `git ls-files`. * : - Shortcut to run `vcsh` on a repo. Will prepend `git` to . + Shortcut to run `git` commands on a repo. Will prepend `git` to . * : Shortcut to run `vcsh enter `. From b1c523b171975e5e0b7d800ba2f59fc66ef74fd4 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Mon, 11 Jul 2016 14:37:30 +0530 Subject: [PATCH 129/164] Fail the command if a hook script fails Currently vcsh commands succeed even if a hook script fails. This is not the right behavior in my opinion. The user should know when a hook fails rather than silently continuing even though it may not make sense. --- vcsh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index de1b419f..985feb1e 100755 --- a/vcsh +++ b/vcsh @@ -248,11 +248,17 @@ git_dir_exists() { [ -d "$GIT_DIR" ] || fatal "no repository found for '$VCSH_REPO_NAME'" 12 } +# $1: message +die () { + >&2 echo -e $1 + exit 1 +} + hook() { for hook in "$VCSH_HOOK_D/$1"* "$VCSH_HOOK_D/$VCSH_REPO_NAME.$1"*; do [ -x "$hook" ] || continue verbose "executing '$hook'" - "$hook" + "$hook" || die "Hook [$hook] failed" done } From c0b61b8edcc876426d5abd3255a83836ca895129 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Thu, 17 Nov 2016 12:22:48 +0000 Subject: [PATCH 130/164] Fix commit. Commit is currently broken. This fixes it by shifting the command line arguments to remove "commit" and by correctly quoting "$@". --- vcsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index de1b419f..a798e7d0 100755 --- a/vcsh +++ b/vcsh @@ -186,11 +186,12 @@ clone() { commit() { hook pre-commit + shift # remove the "commit" command. for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME: " GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR use - git commit --untracked-files=no --quiet $@ + git commit --untracked-files=no --quiet "$@" VCSH_COMMAND_RETURN_CODE=$? echo done From a6c9dc49e9e9749b7dd3b659934193ca61eccae9 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Sat, 8 Jul 2017 07:49:45 +0200 Subject: [PATCH 131/164] Fix parsing of Git version numbers The Git minor version now has two digits, so fix the regexp parsing it. We'll also anticipate the future and handle the time when the major version hits 10 and parse accordingly Signed-off-by: martin f. krafft --- vcsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcsh b/vcsh index de1b419f..543a75e0 100755 --- a/vcsh +++ b/vcsh @@ -162,7 +162,7 @@ clone() { You should add files to your new repository." exit fi - GIT_VERSION_MAJOR=$(git --version | sed -n 's/.* \([0-9]\)\..*/\1/p' ) + GIT_VERSION_MAJOR=$(git --version | sed -n 's/.* \([0-9]\+\)\..*/\1/p' ) if [ 1 -lt "$GIT_VERSION_MAJOR" ];then git fetch origin "$VCSH_BRANCH" else @@ -477,8 +477,8 @@ write_gitignore() { use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 local GIT_VERSION="$(git --version)" - local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\)\..*/\1/p') - local GIT_VERSION_MINOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\)\.\([0-9]\)\..*/\2/p') + local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\+\)\..*/\1/p') + local GIT_VERSION_MINOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\+\)\.\([0-9]\+\)\..*/\2/p') OLDIFS=$IFS IFS=$(printf '\n\t') gitignores=$(for file in $(git ls-files); do From b99d26914007cd902b92c5fe0524a233d778a724 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 16 Jul 2017 18:17:05 +0000 Subject: [PATCH 132/164] completion: Pass GIT_DIR to _git. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This enables file completion at «vcsh foo add ». --- _vcsh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/_vcsh b/_vcsh index 3022c612..bc1a7b95 100644 --- a/_vcsh +++ b/_vcsh @@ -95,6 +95,9 @@ function _vcsh () { local state vcshcommand local -a args subcommands + local VCSH_REPO_D + : ${VCSH_REPO_D:="${XDG_CONFIG_HOME:-"$HOME/.config"}/vcsh/repo.d"} + subcommands=( "clone:clone an existing repository" "commit:commit in all repositories" @@ -135,7 +138,7 @@ function _vcsh () { if ! (( ${+functions[_vcsh-$vcshcommand]} )); then # There is no handler function, so this is probably the name # of a repository. Act accordingly. - _dispatch git git + GIT_DIR=$VCSH_REPO_D/$words[1].git _dispatch git git else curcontext="${curcontext%:*:*}:vcsh-${vcshcommand}:" _call_function ret _vcsh-${vcshcommand} From 5b1b551418efe890bec37aa79d3d16346d96d0f0 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 16 Jul 2017 18:19:28 +0000 Subject: [PATCH 133/164] completion: Return the correct error code from __vcsh_*. --- _vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_vcsh b/_vcsh index 3022c612..77ff976b 100644 --- a/_vcsh +++ b/_vcsh @@ -138,7 +138,7 @@ function _vcsh () { _dispatch git git else curcontext="${curcontext%:*:*}:vcsh-${vcshcommand}:" - _call_function ret _vcsh-${vcshcommand} + _call_function ret _vcsh-${vcshcommand} && (( ret )) fi fi fi From 1a4ff3158b1034b51d102e7253115d514325c430 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sun, 16 Jul 2017 18:25:25 +0000 Subject: [PATCH 134/164] completion: Set the context correctly in 'foreach'. --- _vcsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_vcsh b/_vcsh index 3022c612..96ae6120 100644 --- a/_vcsh +++ b/_vcsh @@ -24,7 +24,7 @@ function _vcsh-enter () { } function _vcsh-foreach () { - _dispatch git git + _dispatch vcsh-foreach git } function _vcsh-help () { @@ -135,6 +135,7 @@ function _vcsh () { if ! (( ${+functions[_vcsh-$vcshcommand]} )); then # There is no handler function, so this is probably the name # of a repository. Act accordingly. + # FIXME: this may want to use '_dispatch vcsh git' _dispatch git git else curcontext="${curcontext%:*:*}:vcsh-${vcshcommand}:" From 12d208c25fef8a67da18d54077a0b67e0bf4e862 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 17 Jul 2017 08:20:13 -0500 Subject: [PATCH 135/164] Do not use shared Git repositories Shared repositories were created using `git init --shared=0600` with the intent of keeping configuration data private. Git reports an error if "shared" repositories are created with private permissions. (Due to an apparent bug, the error was not reported before git-2.13.2.) Instead of creating a shared repository, use `umask 0077` to make created files accessible only to the current user. The umask setting is inherited by child processes and respected by Git. --- t/100-init.t | 2 +- vcsh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/t/100-init.t b/t/100-init.t index 74facc02..15ce922f 100644 --- a/t/100-init.t +++ b/t/100-init.t @@ -18,7 +18,7 @@ ok $output eq "", 'No repos set up yet.'; $output = `./vcsh init test1`; -ok $output eq "Initialized empty shared Git repository in " . $ENV{'HOME'} . "/.config/vcsh/repo.d/test1.git/\n"; +ok $output eq "Initialized empty Git repository in " . $ENV{'HOME'} . "/.config/vcsh/repo.d/test1.git/\n"; $output = `./vcsh status`; diff --git a/vcsh b/vcsh index de1b419f..57a465cd 100755 --- a/vcsh +++ b/vcsh @@ -22,6 +22,9 @@ VERSION='1.20141026' SELF=$(basename $0) +# Ensure all files created are accessible only to the current user. +umask 0077 + fatal() { echo "$SELF: fatal: $1" >&2 [ -z $2 ] && exit 1 @@ -261,7 +264,7 @@ init() { [ ! -e "$GIT_DIR" ] || fatal "'$GIT_DIR' exists" 10 mkdir -p "$VCSH_BASE" || fatal "could not create '$VCSH_BASE'" 50 cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 - git init --shared=0600 + git init --shared=false upgrade hook post-init } From e47baf02e1679514f0157a8c732dafb90e388f3b Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 17 Jul 2017 14:49:22 +0000 Subject: [PATCH 136/164] docs: Clarify what 'enter' does. --- doc/vcsh.1.ronn | 2 +- vcsh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 45b8c831..a25bf65b 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -98,7 +98,7 @@ an interactive user. Delete an existing repository. * enter: - Enter repository; spawn new <$SHELL>. + Enter repository; spawn new <$SHELL> with <$GIT_DIR> set. * foreach: Execute git command for every vcsh repository. diff --git a/vcsh b/vcsh index de1b419f..ff0ec2bb 100755 --- a/vcsh +++ b/vcsh @@ -106,6 +106,7 @@ help() { commit Commit in all repositories delete Delete an existing repository enter Enter repository; spawn new instance of \$SHELL + with \$GIT_DIR set. foreach [<-g>] Execute a command for every repository help Display this help text From a952800661456fd5eb1801168380b7210d581371 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Thu, 20 Jul 2017 17:32:20 +0000 Subject: [PATCH 137/164] Fix: list-tracked in subdir would print invalid paths Fixes #230 --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index de1b419f..183eb179 100755 --- a/vcsh +++ b/vcsh @@ -274,7 +274,7 @@ list() { get_files() { GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR - git ls-files + git ls-files --full-name } list_tracked() { From 6d52838acbe4b4e0c39ac7a4d526624af88fdbac Mon Sep 17 00:00:00 2001 From: Roland Hopferwieser Date: Wed, 23 Aug 2017 17:27:07 +0200 Subject: [PATCH 138/164] Add bash-completion --- _vcsh_bash | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 _vcsh_bash diff --git a/_vcsh_bash b/_vcsh_bash new file mode 100644 index 00000000..3cfe88a6 --- /dev/null +++ b/_vcsh_bash @@ -0,0 +1,138 @@ +# bash completion for vcsh. + +# run git command +# based on bash_completion:_command_offset() +_vcsh_git_command () { + local word_offset=$1 + for (( i=0; i < $word_offset; i++ )); do + for (( j=0; j <= ${#COMP_LINE}; j++ )); do + [[ "$COMP_LINE" == "${COMP_WORDS[i]}"* ]] && break + COMP_LINE=${COMP_LINE:1} + ((COMP_POINT--)) + done + COMP_LINE=${COMP_LINE#"${COMP_WORDS[i]}"} + ((COMP_POINT-=${#COMP_WORDS[i]})) + done + COMP_LINE="git $COMP_LINE" + ((COMP_POINT+=4)) + + # shift COMP_WORDS elements and adjust COMP_CWORD + for (( i=1; i <= COMP_CWORD - $word_offset + 1; i++ )); do + COMP_WORDS[i]=${COMP_WORDS[i+$word_offset-1]} + done + for (( i; i <= COMP_CWORD; i++ )); do + unset 'COMP_WORDS[i]' + done + COMP_WORDS[0]=git + ((COMP_CWORD -= $word_offset - 1)) + + local cspec=$( complete -p git 2>/dev/null ) + if [[ -n $cspec ]]; then + if [[ ${cspec#* -F } != $cspec ]]; then + local func=${cspec#*-F } + func=${func%% *} + + if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then + $func git "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" "${COMP_WORDS[${#COMP_WORDS[@]}-2]}" + else + $func git "${COMP_WORDS[${#COMP_WORDS[@]}-1]}" + fi + + # restore initial compopts + local opt + while [[ $cspec == *" -o "* ]]; do + # FIXME: should we take "+o opt" into account? + cspec=${cspec#*-o } + opt=${cspec%% *} + compopt -o $opt + cspec=${cspec#$opt} + done + fi + fi +} + +_vcsh () { + local cur prev words cword OPTS + _init_completion -n = || return + + local repos cmds + repos=( $(command vcsh list) ) + cmds="clone delete enter foreach help init list list-tracked list-untracked + pull push rename run status upgrade version which write-gitignore" + + local subcword cmd subcmd + for (( subcword=1; subcword < ${#words[@]}-1; subcword++ )); do + [[ -n $cmd && ${words[subcword]} != -* ]] && subcmd=${words[subcword]} && break + [[ ${words[subcword]} != -* ]] && cmd=${words[subcword]} + done + + if [[ -z $cmd ]]; then + case $prev in + -c) + COMPREPLY=( $(compgen -f -- $cur) ) + return + ;; + esac + + case $cur in + -*) + OPTS='-c -d -h -v' + COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) ) + return + ;; + esac + COMPREPLY=( $(compgen -W "${repos[*]} ${cmds[*]}" -- $cur) ) + return 0 + fi + + case $cmd in + help|init|list|pull|push|version|which) + return + ;; + + list-untracked) + [[ $cur == -* ]] && \ + COMPREPLY=( $(compgen -W '-a -r' -- $cur) ) && return + ;;& + + run) + if [[ -n $subcmd && -n "${repos[$subcmd]}" ]]; then + _command_offset $(( $subcword+1 )) + return + fi + ;;& + + delete|enter|list-tracked|list-untracked|rename|run|status|upgrade|write-gitignore) + # return repos + if [[ -z $subcmd ]]; then + COMPREPLY=( $(compgen -W "${repos[*]}" -- $cur) ) + return + fi + return + ;; + + clone) + [[ $cur == -* ]] && \ + COMPREPLY=( $(compgen -W '-b' -- $cur) ) + return + ;; + + foreach) + [[ $cur == -* ]] \ + && COMPREPLY=( $(compgen -W "-g" -- $cur) ) && return + _vcsh_git_command $subcword + return + ;; + + esac + + # git command on repository + if [[ -n "${repos[$cmd]}" ]]; then + _vcsh_git_command $subcword + fi + return 0 +} + +complete -F _vcsh vcsh + +# vim: ft=sh: From 5500082fe5642f0da5d08614407c0986e0154052 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Mon, 28 Aug 2017 01:03:53 +0000 Subject: [PATCH 139/164] completion: Complete only external commands for 'run'. The difference is easiest to see when the following style is in effect: . zstyle ':completion:*' group-name '' --- _vcsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/_vcsh b/_vcsh index 1661e19d..9aca0f97 100644 --- a/_vcsh +++ b/_vcsh @@ -63,10 +63,12 @@ function _vcsh-rename () { function _vcsh-run () { (( CURRENT == 2 )) && __vcsh_repositories - if (( CURRENT >= 3 )); then + (( CURRENT == 3 )) && _command_names -e + if (( CURRENT >= 4 )); then + # see _precommand in zsh words=( "${(@)words[3,-1]}" ) (( CURRENT -= 2 )) - _complete + _normal fi } From b469b65f0110f09dec06a7061975947647716332 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Tue, 29 Aug 2017 08:12:44 +0100 Subject: [PATCH 140/164] Fix version processing on BSD systems. BSD systems ship with the original sed; lacking a host of GNU extensions. However both GNU sed and POSIX sed support the -E flag for extended regular expressions which are close to the change this is replacing. See the descriptions of extended REs in IEEE Std 1003.2 (aka POSIX.2) or re_format(7) on BSD systems. What matters for this is that the + operator works and that it and the grouping operators no longer need to be escaped. --- vcsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcsh b/vcsh index f06f5b45..d1d26edd 100755 --- a/vcsh +++ b/vcsh @@ -166,7 +166,7 @@ clone() { You should add files to your new repository." exit fi - GIT_VERSION_MAJOR=$(git --version | sed -n 's/.* \([0-9]\+\)\..*/\1/p' ) + GIT_VERSION_MAJOR=$(git --version | sed -E -n 's/.* ([0-9]+)\..*/\1/p' ) if [ 1 -lt "$GIT_VERSION_MAJOR" ];then git fetch origin "$VCSH_BRANCH" else @@ -482,8 +482,8 @@ write_gitignore() { use cd "$VCSH_BASE" || fatal "could not enter '$VCSH_BASE'" 11 local GIT_VERSION="$(git --version)" - local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\+\)\..*/\1/p') - local GIT_VERSION_MINOR=$(echo $GIT_VERSION | sed -n 's/.* \([0-9]\+\)\.\([0-9]\+\)\..*/\2/p') + local GIT_VERSION_MAJOR=$(echo $GIT_VERSION | sed -E -n 's/.* ([0-9]+)\..*/\1/p') + local GIT_VERSION_MINOR=$(echo $GIT_VERSION | sed -E -n 's/.* ([0-9]+)\.([0-9]+)\..*/\2/p') OLDIFS=$IFS IFS=$(printf '\n\t') gitignores=$(for file in $(git ls-files); do From 27e3144e572a5468665be0013fe04421d041595d Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 15 Sep 2017 09:50:25 +0100 Subject: [PATCH 141/164] correct spelling mistakes --- changelog | 2 +- doc/README.md | 2 +- doc/vcsh.1.ronn | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/changelog b/changelog index 9cc6c16f..5e657e04 100644 --- a/changelog +++ b/changelog @@ -201,7 +201,7 @@ 2011-11-19 Richard Hartmann * Bugfixes - * Improve XDG compability + * Improve XDG compatibility 2011-11-18 Richard Hartmann diff --git a/doc/README.md b/doc/README.md index b14d782e..8b9b2446 100644 --- a/doc/README.md +++ b/doc/README.md @@ -293,7 +293,7 @@ Note the portage package for myrepos still has the old project name: vcsh is available via this [AUR](https://aur.archlinux.org/packages/vcsh/) package. Likewise myrepos is available [here](https://aur.archlinux.org/packages/myrepos/). -You may install both useing your favorite AUR helper. e.g. with yaourt: +You may install both using your favorite AUR helper. e.g. with yaourt: yaourt -Sya myrepos vcsh diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index a25bf65b..16c4f367 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -338,7 +338,7 @@ config files, all of which were soft-linked into <$HOME>. Martin F. Krafft aka madduck came up with the concept of fake bare Git repositories. -vcsh was initally written by madduck. This version is a re-implementation from +vcsh was initially written by madduck. This version is a re-implementation from scratch with a lot more features. madduck graciously agreed to let the author take over the name. From e72b0961e6b0271dd28a182f586a6e1499e9f037 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aryel=20Mota=20G=C3=B3is?= Date: Sat, 14 Apr 2018 17:36:41 -0300 Subject: [PATCH 142/164] Update status_helper Use git config to avoid paths cluttered with '..', as in: RichiH/myrepos@eabad02ab25169b9658d87fbdebd32a3ac86b317 That functionality was removed in order to use vcsh status: RichiH/myrepos@c6a37fa0d2309fe6a16948ec33b7ad78899dec53 Since vcsh is supposed to have its worktree in $HOME, having paths relative to the current working directory is meaningless and just distracts me --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d1d26edd..3eb8e7e2 100755 --- a/vcsh +++ b/vcsh @@ -422,7 +422,7 @@ status() { status_helper() { GIT_DIR=$VCSH_REPO_D/$1.git; export GIT_DIR - VCSH_GIT_OPTIONS=$2 + VCSH_GIT_OPTIONS="-c status.relativePaths=false $2" use remote_tracking_branch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2> /dev/null) && { commits_behind=$(git log ..${remote_tracking_branch} --oneline | wc -l) From 269b297e72a387f71bcb3779e728ba859099b3a5 Mon Sep 17 00:00:00 2001 From: arndtc Date: Tue, 26 Mar 2019 17:51:50 -0600 Subject: [PATCH 143/164] Fixed debug function in Cygwin on Windows 10 The debug function was causing a bad exit code when calling vcsh from mr on Windows 10. --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d1d26edd..870186a5 100755 --- a/vcsh +++ b/vcsh @@ -139,7 +139,7 @@ help() { } debug() { - [ -n "$VCSH_DEBUG" ] && echo "$SELF: debug: $@" + if [ -n "$VCSH_DEBUG" ]; then echo "$SELF: debug: $@"; fi } verbose() { From 06ec458ca587225479229634a2942dbaa02bf9a9 Mon Sep 17 00:00:00 2001 From: soulofmischief <30357883+soulofmischief@users.noreply.github.com> Date: Mon, 20 May 2019 16:07:25 -0500 Subject: [PATCH 144/164] Fix typo in Config section $VCSH_VCSH_WORKTREE -> $VCSH_WORKTREE --- doc/vcsh.1.ronn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 16c4f367..6e19ef8b 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -220,7 +220,7 @@ Interesting knobs you can turn: Defaults to . -* <$VCSH_VCSH_WORKTREE>: +* <$VCSH_WORKTREE>: Can be , or . will set an absolute path; defaulting to <$HOME>. From dbc9c077403b805406b9be289621dbe41ae2e94b Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 29 Mar 2021 16:56:19 +0200 Subject: [PATCH 145/164] Release v1.20190619 Signed-off-by: Richard Hartmann --- changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog b/changelog index 5e657e04..a8aae0cd 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +2021-03-29 Richard Hartmann + + * Release 1.20190619 + * Various bugfixes + * This is a safe harbour release. + * @alerque is now a co-maintainer + 2014-10-26 Richard Hartmann * Release 1.20141026 From e8b2148def384a82fcea1cc985f89db07550d4d5 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 29 Mar 2021 22:17:40 +0300 Subject: [PATCH 146/164] Drop Travis CI config Travis reduced support for open-source projects :( --- .travis.yml | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index be5a1d79..00000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: perl -before_install: - - cpanm Shell::Command - - cpanm Test::Most - - apt-get moo -install: - - sudo apt-get update - - sudo apt-get install cowsay git ruby-ronn -script: - - make test -after_script: - - make moo -notifications: - email: - on_success: change - on_failure: always From 330d15ae9f9687a56e6c4664458d66d3d54713e3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 29 Mar 2021 22:43:32 +0300 Subject: [PATCH 147/164] Add GitHub Actions workflow to run test suite --- .github/workflows/test.yml | 20 ++++++++++++++++++++ README.md | 3 +-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..e3a674d1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,20 @@ +name: Test +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install build dependencies + run: | + sudo apt-get install ruby-ronn + - name: Install perl test dependencies + uses: perl-actions/install-with-cpanm@v1.1 + with: + install: | + Shell::Command + Test::Most + - name: Run tests + run: | + make test diff --git a/README.md b/README.md index f885b4a3..0022d344 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ vcsh - Version Control System for $HOME - multiple Git repositories in $HOME -[![Build Status](https://travis-ci.org/RichiH/vcsh.svg?branch=master)](https://travis-ci.org/RichiH/vcsh) - +[![Test Status](https://github.com/RichiH/vcsh/actions/workflows/test.yml/badge.svg)](https://github.com/RichiH/vcsh/actions/workflows/test.yml) # Index From b491cb8084a229a7196077d8d045fb7ca2d1f881 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 29 Mar 2021 22:45:05 +0300 Subject: [PATCH 148/164] =?UTF-8?q?Cows=20=E2=80=98moo=E2=80=99,=20but=20l?= =?UTF-8?q?eave=20them=20to=20chew=20the=20cud=20in=20peace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 3 --- doc/INSTALL.md | 4 ---- 2 files changed, 7 deletions(-) diff --git a/Makefile b/Makefile index b9154e7f..40924588 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,3 @@ purge: uninstall test: @if which git > /dev/null; then : ; else echo "'git' not found, exiting..." ; exit 1; fi @if which prove > /dev/null; then prove; else echo "'prove' not found; not running tests"; fi - -moo: - @which cowsay >/dev/null 2>&1 && cowsay "I hope you're happy now..." diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 65fc5f3b..727e14e8 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -44,8 +44,4 @@ To clean up the generated manpage, run make clean -and if you are bored, I suggest - - make moo - [1]: http://rtomayko.github.io/ronn/ From 4726057bdf2aa69012baf227a67df0ab97730f3a Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Mon, 29 Mar 2021 23:26:15 +0100 Subject: [PATCH 149/164] Alias commit to ci (#238) Mercurial, subversion and a common git alias for commit is "ci". The PR adds that alias. Note that all of those also alias checkout as "co" so this current case statement is a bit confusing. That said it doesn't make a huge amount of sense to do vcsh checkout so it's fine if this stays if people have it in muscle memory. --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index d1d26edd..47d8972c 100755 --- a/vcsh +++ b/vcsh @@ -534,7 +534,7 @@ VCSH_COMMAND=$1; export VCSH_COMMAND case $VCSH_COMMAND in clon|clo|cl) VCSH_COMMAND=clone;; - commi|comm|com|co) VCSH_COMMAND=commit;; + commi|comm|com|co|ci) VCSH_COMMAND=commit;; delet|dele|del|de) VCSH_COMMAND=delete;; ente|ent|en) VCSH_COMMAND=enter;; hel|he) VCSH_COMMAND=help;; From b6398def47085dbb86bfbbf0aace4205c89980f3 Mon Sep 17 00:00:00 2001 From: Kevin Lyda Date: Tue, 29 Aug 2017 09:35:31 +0100 Subject: [PATCH 150/164] Add editor modeline This will make sure people have a better chance of following the code style of this file. --- vcsh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vcsh b/vcsh index d1d26edd..ab98612d 100755 --- a/vcsh +++ b/vcsh @@ -672,3 +672,14 @@ $VCSH_COMMAND "$@" hook post-command verbose "$VCSH_COMMAND end, exiting" exit $VCSH_COMMAND_RETURN_CODE + +# +# Editor modelines - https://www.wireshark.org/tools/modelines.html +# +# Local variables: +# indent-tabs-mode: t +# End: +# +# vi: set noexpandtab: +# :noTabs=false: +# From 7c40d6f7707d194b6ae83664c5aba4dec440c3f5 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Fri, 15 Sep 2017 09:50:25 +0100 Subject: [PATCH 151/164] Correct spelling mistakes and typos in docs --- changelog | 2 +- doc/README.md | 2 +- doc/vcsh.1.ronn | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/changelog b/changelog index 9cc6c16f..5e657e04 100644 --- a/changelog +++ b/changelog @@ -201,7 +201,7 @@ 2011-11-19 Richard Hartmann * Bugfixes - * Improve XDG compability + * Improve XDG compatibility 2011-11-18 Richard Hartmann diff --git a/doc/README.md b/doc/README.md index b14d782e..8b9b2446 100644 --- a/doc/README.md +++ b/doc/README.md @@ -293,7 +293,7 @@ Note the portage package for myrepos still has the old project name: vcsh is available via this [AUR](https://aur.archlinux.org/packages/vcsh/) package. Likewise myrepos is available [here](https://aur.archlinux.org/packages/myrepos/). -You may install both useing your favorite AUR helper. e.g. with yaourt: +You may install both using your favorite AUR helper. e.g. with yaourt: yaourt -Sya myrepos vcsh diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index a25bf65b..6e19ef8b 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -220,7 +220,7 @@ Interesting knobs you can turn: Defaults to . -* <$VCSH_VCSH_WORKTREE>: +* <$VCSH_WORKTREE>: Can be , or . will set an absolute path; defaulting to <$HOME>. @@ -338,7 +338,7 @@ config files, all of which were soft-linked into <$HOME>. Martin F. Krafft aka madduck came up with the concept of fake bare Git repositories. -vcsh was initally written by madduck. This version is a re-implementation from +vcsh was initially written by madduck. This version is a re-implementation from scratch with a lot more features. madduck graciously agreed to let the author take over the name. From 95c12ab219cdcf2f2d05bc80ad880be81a351edf Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Mar 2021 10:29:58 +0300 Subject: [PATCH 152/164] Replace file level modeline with project level EditorConfig --- .editorconfig | 9 +++++++++ vcsh | 11 ----------- 2 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..32d78adb --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[vcsh] +indent_style = tab +trim_trailing_whitespace = true diff --git a/vcsh b/vcsh index ab98612d..d1d26edd 100755 --- a/vcsh +++ b/vcsh @@ -672,14 +672,3 @@ $VCSH_COMMAND "$@" hook post-command verbose "$VCSH_COMMAND end, exiting" exit $VCSH_COMMAND_RETURN_CODE - -# -# Editor modelines - https://www.wireshark.org/tools/modelines.html -# -# Local variables: -# indent-tabs-mode: t -# End: -# -# vi: set noexpandtab: -# :noTabs=false: -# From 536f9196d825f1aca1406316e4bbedaa3215b3ba Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Mar 2021 11:22:08 +0300 Subject: [PATCH 153/164] Add EditorConfig lint workflow to GH Actions --- .github/workflows/lint.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..917862ab --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,10 @@ +name: Lint +on: [push, pull_request] +jobs: + editor-config: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Lint code style + uses: editorconfig-checker/action-editorconfig-checker@v1.0.0 From e636440c25071e2792a1b64c5d74e10057466d6a Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Mar 2021 11:28:50 +0300 Subject: [PATCH 154/164] Normalize indent style to please linter Long term I think these offending lines I had to ignore can be refactored other ways, but for now at least we can see when other PRs introduce mixed indentation formats. --- vcsh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/vcsh b/vcsh index 47d8972c..7e3a7ec4 100755 --- a/vcsh +++ b/vcsh @@ -94,6 +94,7 @@ if [ ! "x$VCSH_WORKTREE" = 'xabsolute' ] && [ ! "x$VCSH_WORKTREE" = 'xrelative' fi +# editorconfig-checker-disable help() { echo "usage: $SELF @@ -137,6 +138,7 @@ help() { Shortcut to run git commands directly Shortcut to enter repository" >&2 } +# editorconfig-checker-enable debug() { [ -n "$VCSH_DEBUG" ] && echo "$SELF: debug: $@" @@ -163,7 +165,7 @@ clone() { git config branch."$VCSH_BRANCH".merge refs/heads/"$VCSH_BRANCH" if [ $(git ls-remote origin "$VCSH_BRANCH" 2> /dev/null | wc -l ) -lt 1 ]; then info "remote is empty, not merging anything. - You should add files to your new repository." + You should add files to your new repository." # editorconfig-checker-disable-line exit fi GIT_VERSION_MAJOR=$(git --version | sed -E -n 's/.* ([0-9]+)\..*/\1/p' ) @@ -180,7 +182,7 @@ clone() { done [ x"$VCSH_CONFLICT" = x'1' ]) && fatal "will stop after fetching and not try to merge! - Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 + Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 # editorconfig-checker-disable-line git -c merge.ff=true merge origin/"$VCSH_BRANCH" hook post-merge hook post-clone @@ -190,7 +192,7 @@ clone() { commit() { hook pre-commit - shift # remove the "commit" command. + shift # remove the "commit" command. for VCSH_REPO_NAME in $(list); do echo "$VCSH_REPO_NAME: " GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR @@ -548,7 +550,7 @@ case $VCSH_COMMAND in versio|versi|vers|ver|ve) VCSH_COMMAND=version;; which|whi|wh) VCSH_COMMAND=which;; write|writ|wri|wr) VCSH_COMMAND=write-gitignore;; -esac +esac if [ x"$VCSH_COMMAND" = x'clone' ]; then VCSH_BRANCH= @@ -583,30 +585,30 @@ elif [ x"$VCSH_COMMAND" = x'which' ]; then [ -n "$3" ] && fatal "$VCSH_COMMAND: too many parameters" 1 VCSH_COMMAND_PARAMETER=$2; export VCSH_COMMAND_PARAMETER elif [ x"$VCSH_COMMAND" = x'delete' ] || - [ x"$VCSH_COMMAND" = x'enter' ] || - [ x"$VCSH_COMMAND" = x'init' ] || - [ x"$VCSH_COMMAND" = x'list-tracked-by' ] || - [ x"$VCSH_COMMAND" = x'rename' ] || - [ x"$VCSH_COMMAND" = x'run' ] || - [ x"$VCSH_COMMAND" = x'upgrade' ] || - [ x"$VCSH_COMMAND" = x'write-gitignore' ]; then + [ x"$VCSH_COMMAND" = x'enter' ] || + [ x"$VCSH_COMMAND" = x'init' ] || + [ x"$VCSH_COMMAND" = x'list-tracked-by' ] || + [ x"$VCSH_COMMAND" = x'rename' ] || + [ x"$VCSH_COMMAND" = x'run' ] || + [ x"$VCSH_COMMAND" = x'upgrade' ] || + [ x"$VCSH_COMMAND" = x'write-gitignore' ]; then [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify repository to work on" 1 [ x"$VCSH_COMMAND" = x'rename' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a target name" 1 [ x"$VCSH_COMMAND" = x'run' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a command" 1 VCSH_REPO_NAME=$2; export VCSH_REPO_NAME GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ 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; } + 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' ] || - [ x"$VCSH_COMMAND" = x'list-untracked' ] || - [ x"$VCSH_COMMAND" = x'pull' ] || - [ x"$VCSH_COMMAND" = x'push' ]; then + [ x"$VCSH_COMMAND" = x'list' ] || + [ x"$VCSH_COMMAND" = x'list-tracked' ] || + [ x"$VCSH_COMMAND" = x'list-untracked' ] || + [ x"$VCSH_COMMAND" = x'pull' ] || + [ x"$VCSH_COMMAND" = x'push' ]; then : elif [ x"$VCSH_COMMAND" = x'status' ]; then if [ x"$2" = x'--terse' ]; then From fef6158d5def00b93e1ab8510c16d3c4a0ba310a Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Tue, 30 Mar 2021 17:17:33 +0000 Subject: [PATCH 155/164] Port ZSH completion fixes (#271) The change to __vcsh_repositories will require users to update zstyle settings, if anyone has created such zstyle settings. Ported (by Daniel Shahaf) from the following zsh upstream commit: commit 13fc579343b24d298fb8905933b6000d7fcda114 Author: Oliver Kiddle Date: Tue Oct 14 23:03:40 2014 +0200 33467: correct return status on functions and numerous other minor fixes With this change, our completion is a superset of zsh's _vcsh, so the latter may be removed. See issue #270. Co-authored-by: Oliver Kiddle --- _vcsh | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/_vcsh b/_vcsh index 9aca0f97..72924ce2 100644 --- a/_vcsh +++ b/_vcsh @@ -1,10 +1,9 @@ #compdef vcsh function __vcsh_repositories () { - local expl local -a repos - repos=( ${(f)"$(command vcsh list)"} ) - _describe -t repos 'repositories' repos + repos=( ${(f)"$(_call_program repositories vcsh list)"} ) + _describe -t repositories 'repository' repos } function __vcsh_not_implemented_yet () { @@ -56,9 +55,11 @@ function _vcsh-push () { } function _vcsh-rename () { - (( CURRENT == 2 )) && __vcsh_repositories - (( CURRENT == 3 )) && _message "new repository name" - (( CURRENT > 3 )) && _nothing + case $CURRENT in + 2) __vcsh_repositories ;; + 3) _message "new repository name" ;; + *) _nothing ;; + esac } function _vcsh-run () { @@ -93,7 +94,7 @@ function _vcsh-write-gitignore () { } function _vcsh () { - local curcontext="${curcontext}" + local curcontext="${curcontext}" ret=1 local state vcshcommand local -a args subcommands @@ -129,25 +130,26 @@ function _vcsh () { '*:: :->subcommand_or_options_or_repo' ) - _arguments -C ${args} && return + _arguments -C ${args} && ret=0 if [[ ${state} == "subcommand_or_options_or_repo" ]]; then if (( CURRENT == 1 )); then - _describe -t subcommands 'vcsh sub-commands' subcommands - __vcsh_repositories + _describe -t subcommands 'vcsh sub-commands' subcommands && ret=0 + __vcsh_repositories && ret=0 else vcshcommand="${words[1]}" if ! (( ${+functions[_vcsh-$vcshcommand]} )); then # There is no handler function, so this is probably the name # of a repository. Act accordingly. # FIXME: this may want to use '_dispatch vcsh git' - GIT_DIR=$VCSH_REPO_D/$words[1].git _dispatch git git + GIT_DIR=$VCSH_REPO_D/$words[1].git _dispatch git git && ret=0 else curcontext="${curcontext%:*:*}:vcsh-${vcshcommand}:" _call_function ret _vcsh-${vcshcommand} && (( ret )) fi fi fi + return ret } _vcsh "$@" From 832cfb0dba0d8c32ab3b8aff0faa4fd5a16c158a Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Wed, 31 Mar 2021 06:57:36 +1300 Subject: [PATCH 156/164] Make arg to write-gitignore optional (#245) Co-authored-by: Caleb Maclennan --- doc/vcsh.1.ronn | 5 +++-- vcsh | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/vcsh.1.ronn b/doc/vcsh.1.ronn index 6e19ef8b..c1021ae6 100644 --- a/doc/vcsh.1.ronn +++ b/doc/vcsh.1.ronn @@ -39,7 +39,7 @@ vcsh(1) - Version Control System for $HOME - multiple Git repositories in $HOME `vcsh` which -`vcsh` write-gitignore +`vcsh` write-gitignore [] `vcsh` @@ -170,7 +170,8 @@ an interactive user. Find in name of any tracked file. * write-gitignore: - Write .gitignore.d/ via `git ls-files`. + Write .gitignore.d/ via `git ls-files`. If is not specified but + we're withing a vcsh repository, use that. * : Shortcut to run `git` commands on a repo. Will prepend `git` to . diff --git a/vcsh b/vcsh index 7e3a7ec4..2ee44490 100755 --- a/vcsh +++ b/vcsh @@ -133,7 +133,7 @@ help() { version Print version information which Find substring in name of any tracked file write-gitignore \\ - Write .gitignore.d/ via git ls-files + [] Write .gitignore.d/ via git ls-files Shortcut to run git commands directly Shortcut to enter repository" >&2 @@ -592,11 +592,14 @@ elif [ x"$VCSH_COMMAND" = x'delete' ] || [ x"$VCSH_COMMAND" = x'run' ] || [ x"$VCSH_COMMAND" = x'upgrade' ] || [ x"$VCSH_COMMAND" = x'write-gitignore' ]; then - [ -z "$2" ] && fatal "$VCSH_COMMAND: please specify repository to work on" 1 + if [ -z "$2" ]; then + [ -z "$VCSH_REPO_NAME" ] && fatal "$VCSH_COMMAND: please specify repository to work on" 1 + else + VCSH_REPO_NAME=$2; export VCSH_REPO_NAME + fi + GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ x"$VCSH_COMMAND" = x'rename' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a target name" 1 [ x"$VCSH_COMMAND" = x'run' ] && [ -z "$3" ] && fatal "$VCSH_COMMAND: please specify a command" 1 - VCSH_REPO_NAME=$2; export VCSH_REPO_NAME - GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ 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 From 22099c456ea606929aed592e44f70c3ab01416c3 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Mon, 11 Jul 2016 14:15:57 +0530 Subject: [PATCH 157/164] Use git read-tree (dry run) to detect conflicts (#210) ls-tree does not account for sparse checkout settings and therefore reports spurious conflicts if an existing file in the worktree conflicts with a file in the repository which is not even being checked out. On the other hand, read-tree takes care of sparse checkout settings. --- vcsh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/vcsh b/vcsh index 2ee44490..973f74f9 100755 --- a/vcsh +++ b/vcsh @@ -175,13 +175,8 @@ clone() { git fetch origin fi hook pre-merge - git ls-tree -r --name-only origin/"$VCSH_BRANCH" | (while read object; do - [ -e "$object" ] && - error "'$object' exists." && - VCSH_CONFLICT=1 - done - [ x"$VCSH_CONFLICT" = x'1' ]) && - fatal "will stop after fetching and not try to merge! + git read-tree -n -mu origin/"$VCSH_BRANCH" \ + || fatal "will stop after fetching and not try to merge! Once this situation has been resolved, run 'vcsh $VCSH_REPO_NAME pull' to finish cloning." 17 # editorconfig-checker-disable-line git -c merge.ff=true merge origin/"$VCSH_BRANCH" hook post-merge From abe4ae64da7c7fb96d72b3cc468afc1a1d83c1fb Mon Sep 17 00:00:00 2001 From: Noah Birnel Date: Sun, 15 Nov 2015 18:43:02 -0800 Subject: [PATCH 158/164] =?UTF-8?q?Remove=20=E2=80=98test=E2=80=99=20targe?= =?UTF-8?q?t=20from=20=E2=80=98install=E2=80=99=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b9154e7f..df633ffb 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ all=test manpages all: $(all) -install: all +install: manpages install -d $(DESTDIR)$(PREFIX)/bin install -m 0755 $(self) $(DESTDIR)$(PREFIX)/bin install -d $(DESTDIR)$(PREFIX)/share/man/man1 From 4cb22db1730eed49db101c297426570939bfdebd Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Mar 2021 22:41:27 +0300 Subject: [PATCH 159/164] Decouple build targets from test target --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index df633ffb..dc2b199d 100644 --- a/Makefile +++ b/Makefile @@ -6,11 +6,11 @@ RONN ?= ronn self=vcsh manpages=$(self).1 -all=test manpages +all=manpages all: $(all) -install: manpages +install: all install -d $(DESTDIR)$(PREFIX)/bin install -m 0755 $(self) $(DESTDIR)$(PREFIX)/bin install -d $(DESTDIR)$(PREFIX)/share/man/man1 From c0d7264ea5c594b26395b98d8b3d750daf6df0e7 Mon Sep 17 00:00:00 2001 From: Noah Birnel Date: Sun, 15 Nov 2015 18:43:02 -0800 Subject: [PATCH 160/164] Clarify README/INSTALL --- README.md | 16 +++++++++------- doc/INSTALL.md | 13 ++++++++++++- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f885b4a3..88acfaf7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ vcsh - Version Control System for $HOME - multiple Git repositories in $HOME 1. [30 Second How-to](#30-second-how-to) 2. [Introduction](#introduction) -3. [Contact](#contact) +3. [Installation](#installation) +4. [Contact](#contact) # 30 Second How-to @@ -47,12 +48,6 @@ For example, you may not need to have your `mplayer` configuration on a server or available to root and you may want to maintain different configuration for `ssh` on your personal and your work machines. -A lot of modern UNIX-based systems offer packages for `vcsh`. In case yours -does not, read [INSTALL.md](doc/INSTALL.md) for install instructions or -[PACKAGING.md](doc/PACKAGING.md) to create a package yourself. If you do end -up packaging `vcsh` please let us know so we can give you your own packaging -branch in the upstream repository. - ## Talks Some people found it useful to look at slides and videos explaining how `vcsh` @@ -60,6 +55,13 @@ works instead of working through the docs. All slides, videos, and further information can be found [on the author's talk page][talks]. +# Installation + +A lot of modern UNIX-based systems offer packages for `vcsh`. In case yours +does not, read [INSTALL.md](doc/INSTALL.md) for install instructions or +[PACKAGING.md](doc/PACKAGING.md) to create a package yourself. If you do end +up packaging `vcsh` please let us know so we can give you your own packaging +branch in the upstream repository. # Contact diff --git a/doc/INSTALL.md b/doc/INSTALL.md index 65fc5f3b..e6c6c028 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -44,7 +44,18 @@ To clean up the generated manpage, run make clean -and if you are bored, I suggest +To run the test suite, run + + make test + +To run the test suite, you will need `perl`, +and the modules `Test::Most` and `Shell::Command`. + +To install the perl modules, run + + cpan install 'Test::Most' 'Shell::Command'. + +If you are bored, I suggest make moo From 72aab0b39d7265acb8b2990e9f7a236fd71399f7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Wed, 31 Mar 2021 17:11:16 +0300 Subject: [PATCH 161/164] =?UTF-8?q?Catch=20=E2=80=98help=E2=80=99=20as=20v?= =?UTF-8?q?alid=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vcsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index 448ea8d7..ba289e24 100755 --- a/vcsh +++ b/vcsh @@ -571,6 +571,8 @@ if [ x"$VCSH_COMMAND" = x'clone' ]; then export VCSH_REPO_NAME [ -n "$VCSH_BRANCH" ] || VCSH_BRANCH=master GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR +elif [ "$VCSH_COMMAND" = 'help' ]; then + help && exit elif [ "$VCSH_COMMAND" = 'version' ]; then echo "$SELF $VERSION" git version @@ -627,8 +629,8 @@ elif [ -n "$VCSH_COMMAND" ]; then GIT_DIR=$VCSH_REPO_D/$VCSH_REPO_NAME.git; export GIT_DIR [ -d "$GIT_DIR" ] || { help; exit 1; } else - # $1 is empty, or 'help' - help && exit + # $1 is empty + help && exit 1 fi # Did we receive a directory instead of a name? From c8d366b59eff67be357afd25a2297d43d895fa53 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 1 Apr 2021 11:54:49 +0300 Subject: [PATCH 162/164] Anchor file paths to $HOME in status output --- t/300-add.t | 4 ++-- vcsh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/t/300-add.t b/t/300-add.t index 4acd0a2c..7a74159e 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -25,14 +25,14 @@ system (".././vcsh test1 add 'a'"); my $output = `.././vcsh status`; ok $output eq "test1: -A a +A ~/a ", 'Adding a file works'; $output = `.././vcsh status --terse`; ok $output eq "test1: -A a +A ~/a ", 'Terse output works'; done_testing; diff --git a/vcsh b/vcsh index 3eb8e7e2..ef2b3a43 100755 --- a/vcsh +++ b/vcsh @@ -430,7 +430,7 @@ status_helper() { [ ${commits_behind} -ne 0 ] && echo "Behind $remote_tracking_branch by $commits_behind commits" [ ${commits_ahead} -ne 0 ] && echo "Ahead of $remote_tracking_branch by $commits_ahead commits" } - git ${VCSH_GIT_OPTIONS} status --short --untracked-files='no' + git ${VCSH_GIT_OPTIONS} status --short --untracked-files='no' | sed -E 's@([^ ] +)@\1~/@' VCSH_COMMAND_RETURN_CODE=$? } From d157e585cf8ba6b6a17d60cf56297b3f928af055 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 1 Apr 2021 12:44:03 +0300 Subject: [PATCH 163/164] Populate test runner's Git config to suppress warnings in output --- t/001-setup-env.t | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/t/001-setup-env.t b/t/001-setup-env.t index fb59f058..43a2be8b 100644 --- a/t/001-setup-env.t +++ b/t/001-setup-env.t @@ -3,6 +3,7 @@ use strict; use warnings; +use Cwd 'abs_path'; use Test::Most; system ("mkdir -p t/etc"); @@ -16,4 +17,9 @@ chdir 't/etc/' or die $!; system ("ln -s '../../vcsh'"); ok !$?; +$ENV{'HOME'} = abs_path ('.vcsh_home'); + +system ("git config --global init.defaultBranch test"); +ok !$?; + done_testing; From 4f070d38b96cf3378cdb78984073ceed22f58563 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 2 Apr 2021 10:32:48 +0300 Subject: [PATCH 164/164] Override XDG_CONFIG_HOME in test fixtures Co-authored-by: Richard Hartmann --- t/001-setup-env.t | 1 + t/100-init.t | 1 + t/300-add.t | 1 + t/950-delete.t | 1 + 4 files changed, 4 insertions(+) diff --git a/t/001-setup-env.t b/t/001-setup-env.t index 43a2be8b..b50313b9 100644 --- a/t/001-setup-env.t +++ b/t/001-setup-env.t @@ -18,6 +18,7 @@ system ("ln -s '../../vcsh'"); ok !$?; $ENV{'HOME'} = abs_path ('.vcsh_home'); +$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'}.'/.config'; system ("git config --global init.defaultBranch test"); ok !$?; diff --git a/t/100-init.t b/t/100-init.t index 15ce922f..c8984281 100644 --- a/t/100-init.t +++ b/t/100-init.t @@ -11,6 +11,7 @@ use Test::Most; chdir 't/etc/' or die $!; $ENV{'HOME'} = abs_path ('.vcsh_home'); +$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'}.'/.config'; my $output = `./vcsh status`; diff --git a/t/300-add.t b/t/300-add.t index 7a74159e..c7e9d2f4 100644 --- a/t/300-add.t +++ b/t/300-add.t @@ -11,6 +11,7 @@ use Test::Most; chdir 't/etc/' or die $!; $ENV{'HOME'} = abs_path ('.vcsh_home'); +$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'}.'/.config'; chdir '.vcsh_home' or die $!; diff --git a/t/950-delete.t b/t/950-delete.t index cd078714..012586b7 100644 --- a/t/950-delete.t +++ b/t/950-delete.t @@ -9,6 +9,7 @@ use Test::Most; chdir 't/etc/' or die $!; $ENV{'HOME'} = abs_path ('.vcsh_home'); +$ENV{'XDG_CONFIG_HOME'} = $ENV{'HOME'}.'/.config'; system ("echo 'Yes, do as I say' | ./vcsh delete test1");