From 2409943638ea22ccdbccd8cd98356ca7e2679320 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 29 Dec 2013 17:22:24 +0100 Subject: [PATCH 01/16] Release v1.20131229 --- changelog | 7 +++++++ vcsh | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index b0bac5d..dc578c6 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +2013-12-29 Richard Hartmann + + * Release 1.20131229 + * Fix mktemp bug (GitHub issue #99) + * Make code more resilient and efficient + * Improve output + 2013-12-14 Richard Hartmann * Release 1.20131214 diff --git a/vcsh b/vcsh index 74b185e..9f413f6 100755 --- a/vcsh +++ b/vcsh @@ -16,7 +16,7 @@ [ -n "$VCSH_DEBUG" ] && set -vx SELF=$(basename $0) -VERSION='1.20131214.git-HEAD' +VERSION='1.20131229' fatal() { echo "$SELF: fatal: $1" >&2 -- 2.39.5 From e3165b45a31d715d5f499222bcacad1527de9c9e Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 29 Dec 2013 17:25:25 +0100 Subject: [PATCH 02/16] sh: Bump version to 1.20131229.git-HEAD --- vcsh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 9f413f6..5d502e7 100755 --- a/vcsh +++ b/vcsh @@ -15,8 +15,12 @@ # This should always be the first line of code to facilitate debugging [ -n "$VCSH_DEBUG" ] && set -vx + +# If '.git-HEAD' is appended to the version, you are seeing an unreleased +# version of vcsh; the master branch is supposed to be clean at all times +# so you can most likely just use it nonetheless +VERSION='1.20131229.git-HEAD' SELF=$(basename $0) -VERSION='1.20131229' fatal() { echo "$SELF: fatal: $1" >&2 -- 2.39.5 From e437aa97b3952531dbadac2fcc34b9bd48c2a86b Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 29 Dec 2013 17:41:12 +0100 Subject: [PATCH 03/16] .gitignore: Ignore .swp Opening Vim in $PWD without a file name (think scratch pad) will open .swp, which is not matched by *.swp --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 7567c75..4dec9bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vcsh.1 *.patch *.swp +.swp *.bak -- 2.39.5 From 75c4c554eefbefb714fabd356933858edbce3b1e Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Mon, 6 Jan 2014 03:06:40 +0100 Subject: [PATCH 04/16] Update CONTRIBUTORS --- CONTRIBUTORS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 2dad8ed..9ccbd87 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3,19 +3,25 @@ Auto-generated from tools/list_CONTRIBUTORS. Eric Bouchut Dridi Boukelmoune +Rob Cornish Vincent Demeester Thomas Ferris Nicolaisen martin f. krafft Alessandro Ghedini +Mikhail Gusarov Valentin Haenel Richard Hartmann Gregor Jasny Caleb Maclennan +Markus Martin mek-apelsin Evan Pitstick Dieter Plaetinck Corey Quinn +Pavlos Ratis Gernot Schulz Alexander Skurikhin Jonathan Sternberg Frank Terbeck +Aaron VonderHaar +Tony -- 2.39.5 From e220a617bcd54e5fd324e21e418fff7c3c3f170a Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 21 Jan 2014 15:56:15 +0100 Subject: [PATCH 05/16] vcsh: Initialize repos with --shared=0600 Configurations and other dotdir content may be highly confidential. Ensure we're not leaking/exposing information by making vcsh repositories user-accessible, only. Thanks to Enrico Zini for realizing this was a problem. --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 5d502e7..993c8ed 100755 --- a/vcsh +++ b/vcsh @@ -221,7 +221,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 + git init --shared=0600 upgrade hook post-init } -- 2.39.5 From b4bee06a2de5d74f9b1de64ffbb464e235a3194a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dato=20Sim=C3=B3?= Date: Mon, 23 Sep 2013 22:13:54 +0100 Subject: [PATCH 06/16] vcsh: strip host part from GIT_REMOTE when inferring VCSH_REPO_NAME MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit `vcsh clone` does: VCSH_REPO_NAME=$(basename "${GIT_REMOTE}" .git) Typically, most remote paths will have a non-empty directory component, so using basename works well in all common cases. However, when doing something like: % vcsh clone example.org:repo.git VCSH_REPO_NAME will be set to "example.org:repo" instead of "repo". This also happens when using url..insteadOf, à-la: % vcsh clone v:repo Stripping everything up to the first colon in the remote URL fixes the issue. N.B.: remote URLs with protocol (e.g. http://, git://, or ssh://) do not exhibit this problem, and are unaffected by this change. Conflicts: vcsh --- vcsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vcsh b/vcsh index 5d502e7..5d5628e 100755 --- a/vcsh +++ b/vcsh @@ -416,7 +416,7 @@ esac if [ "$VCSH_COMMAND" = '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" -- 2.39.5 From deec8de709a933763e7344c3a7be54ae0be5577c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Dato=20Sim=C3=B3?= Date: Mon, 23 Sep 2013 21:47:43 +0100 Subject: [PATCH 07/16] vcsh: don't allow `clone` to choke on filenames with spaces By replacing the "for" loop with a "while" loop, it is easy to read line-oriented output without worrying about spaces. However, now the loop executes in a subshell, and VCSH_CONFLICT won't be available in the parent shell. In this case, a trivial, portable solution is to have the comparison as the last command in the subshell. --- vcsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcsh b/vcsh index 5d5628e..6ce5320 100755 --- a/vcsh +++ b/vcsh @@ -152,12 +152,12 @@ clone() { exit fi git fetch - for object in $(git ls-tree -r origin/master | awk '{print $4}'); do + git ls-tree -r --name-only origin/master | (while read object; do [ -e "$object" ] && error "'$object' exists." && VCSH_CONFLICT=1 done - [ "$VCSH_CONFLICT" = '1' ] && + [ "$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 git merge origin/master -- 2.39.5 From 890dbdede9545f927385bfd798f34831df3fc537 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 4 Feb 2014 23:16:03 +0100 Subject: [PATCH 08/16] Update CONTRIBUTORS --- CONTRIBUTORS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9ccbd87..cbb144a 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -12,6 +12,7 @@ Mikhail Gusarov Valentin Haenel Richard Hartmann Gregor Jasny +Errietta Kostala Caleb Maclennan Markus Martin mek-apelsin @@ -20,6 +21,7 @@ Dieter Plaetinck Corey Quinn Pavlos Ratis Gernot Schulz +Dato Simó Alexander Skurikhin Jonathan Sternberg Frank Terbeck -- 2.39.5 From 49a6af92db204536f6752583c1c24a34c1070c8c Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 19 Oct 2013 19:11:52 -0600 Subject: [PATCH 09/16] add hooks to enable auto handing of merge conflicts These hooks before and after the actual checkout process will enable a pair of hook scripts to automatically handle conflicts and potentially allow the checkout of repositories over existing file sets --- doc/hooks | 6 ++++++ vcsh | 2 ++ 2 files changed, 8 insertions(+) diff --git a/doc/hooks b/doc/hooks index 54ff795..30cd373 100644 --- a/doc/hooks +++ b/doc/hooks @@ -14,6 +14,12 @@ Available hooks are: * post-enter * pre-init * post-init +* pre-merge + Use this hook to detect and handle merge conflicts before vcsh's native code + finds and errors on them. This is useful for allowing clones on top of existing + files. +* post-merge + Use this hook to finish handling any merge conflicts found in the pre-merge hook. * pre-pull * post-pull * pre-push diff --git a/vcsh b/vcsh index 6ce5320..a6d8213 100755 --- a/vcsh +++ b/vcsh @@ -152,6 +152,7 @@ clone() { exit fi git fetch + hook pre-merge git ls-tree -r --name-only origin/master | (while read object; do [ -e "$object" ] && error "'$object' exists." && @@ -161,6 +162,7 @@ clone() { 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 + hook post-merge hook post-clone retire hook post-clone-retired -- 2.39.5 From bca2d01e18e69ae7b602950ee640a08ea1c8cef0 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 19 Oct 2013 19:35:10 -0600 Subject: [PATCH 10/16] add sample hooks that allow cloning over extant files Cloning a repo over an existing set of files would usually cause a merge conflict that aborts the process and requires manual intervention. This pair of hooks handles that case by manually moving the extant objects out of the way, completing the checktout, then restoring them to their original places. The resulting state is a set of unstaged local changes. --- doc/hooks | 4 ++-- doc/sample_hooks/post-merge-unclobber | 10 ++++++++++ doc/sample_hooks/pre-merge-unclobber | 11 +++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 doc/sample_hooks/post-merge-unclobber create mode 100755 doc/sample_hooks/pre-merge-unclobber diff --git a/doc/hooks b/doc/hooks index 30cd373..282ee86 100644 --- a/doc/hooks +++ b/doc/hooks @@ -15,11 +15,11 @@ Available hooks are: * pre-init * post-init * pre-merge - Use this hook to detect and handle merge conflicts before vcsh's native code + Use this hook to detect and handle merge conflicts before vcsh's native code finds and errors on them. This is useful for allowing clones on top of existing files. * post-merge - Use this hook to finish handling any merge conflicts found in the pre-merge hook. + Use this hook to finish handling any merge conflicts found in the pre-merge hook. * pre-pull * post-pull * pre-push diff --git a/doc/sample_hooks/post-merge-unclobber b/doc/sample_hooks/post-merge-unclobber new file mode 100755 index 0000000..017a13f --- /dev/null +++ b/doc/sample_hooks/post-merge-unclobber @@ -0,0 +1,10 @@ +#!/bin/sh + +# This finds objects that the pre-merge script moved out of the way to +# avoid conflicts when running git clone and moves them back to their +# original places. The result is that the git repository gets checked out +# and the extant objects end up back in the working directory. Git now +# sees these as un-staged changes to the working branch and you can deal +# with them by adding them or reverting. + +find -name '*.vcsh-unclobber' -execdir rename .vcsh-unclobber '' {} \; diff --git a/doc/sample_hooks/pre-merge-unclobber b/doc/sample_hooks/pre-merge-unclobber new file mode 100755 index 0000000..93a7319 --- /dev/null +++ b/doc/sample_hooks/pre-merge-unclobber @@ -0,0 +1,11 @@ +#!/bin/sh + +# This code does amost exactly what the native VCSH sanity checking code +# does except that on finding a potential merge conflict, it moves the +# extant object out of the way temporarily. The merge then happens cleanly +# as far as git knows, and a post-merge hook can figure out what to do with +# the extant versions of the objects. + +for object in $(git ls-tree -r origin/master | awk '{print $4}'); do + [ -e "$object" ] && mv "$object" "$object.vcsh-unclobber" +done -- 2.39.5 From 62896f1b8dcf9a04f94c44170063ef274326fa4c Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sat, 8 Feb 2014 17:00:47 +0100 Subject: [PATCH 11/16] doc/sample_hooks/: Cleanups --- doc/sample_hooks/post-merge-unclobber | 10 +++++----- doc/sample_hooks/pre-merge-unclobber | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/sample_hooks/post-merge-unclobber b/doc/sample_hooks/post-merge-unclobber index 017a13f..23c757c 100755 --- a/doc/sample_hooks/post-merge-unclobber +++ b/doc/sample_hooks/post-merge-unclobber @@ -1,10 +1,10 @@ #!/bin/sh # This finds objects that the pre-merge script moved out of the way to -# avoid conflicts when running git clone and moves them back to their -# original places. The result is that the git repository gets checked out -# and the extant objects end up back in the working directory. Git now -# sees these as un-staged changes to the working branch and you can deal -# with them by adding them or reverting. +# avoid conflicts when running `vcsh clone` and moves them back to their +# original places. The result is that the Git repository gets checked out +# without error and the pre-existing files end up back in the working +# directory. Git and thus vcsh now see these as un-staged changes to the +# working branch and you can deal with them as usual. find -name '*.vcsh-unclobber' -execdir rename .vcsh-unclobber '' {} \; diff --git a/doc/sample_hooks/pre-merge-unclobber b/doc/sample_hooks/pre-merge-unclobber index 93a7319..5261096 100755 --- a/doc/sample_hooks/pre-merge-unclobber +++ b/doc/sample_hooks/pre-merge-unclobber @@ -1,10 +1,10 @@ #!/bin/sh -# This code does amost exactly what the native VCSH sanity checking code -# does except that on finding a potential merge conflict, it moves the -# extant object out of the way temporarily. The merge then happens cleanly -# as far as git knows, and a post-merge hook can figure out what to do with -# the extant versions of the objects. +# This code does amost exactly what the native vcsh sanity checking code +# does except that on finding a potential merge conflict, it moves existing +# files out of the way temporarily. Merging (part of `vcsh clone`) happens +# cleanly, and a post-merge hook can be used to figure out what to do with +# the now-renamed files. for object in $(git ls-tree -r origin/master | awk '{print $4}'); do [ -e "$object" ] && mv "$object" "$object.vcsh-unclobber" -- 2.39.5 From 056f86ae9a3c25fd2e0b74ac6b81d9b0d5630818 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Sun, 9 Feb 2014 19:08:18 +0100 Subject: [PATCH 12/16] Introduce static manpage as part of normal repo GitHub: fixes RichiH/vcsh#104 --- .gitignore | 1 - Makefile | 2 +- vcsh.1 | 334 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 335 insertions(+), 2 deletions(-) create mode 100644 vcsh.1 diff --git a/.gitignore b/.gitignore index 4dec9bf..d7b62d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -vcsh.1 *.patch *.swp .swp diff --git a/Makefile b/Makefile index 4ae8d88..b40c618 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ RONN ?= ronn self=vcsh manpages=$(self).1 -all=test manpages +all=test all: $(all) diff --git a/vcsh.1 b/vcsh.1 new file mode 100644 index 0000000..967aee8 --- /dev/null +++ b/vcsh.1 @@ -0,0 +1,334 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "VCSH" "1" "February 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_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) -- 2.39.5 From 9b40ea328d5dab1dd5a0d5ed653bacb577a24aed Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 13 Feb 2014 00:39:21 +0100 Subject: [PATCH 13/16] vcsh: Pass along exit code If `git foo` exits 13, it would be prudent for vcsh to exit 13, as well. Start with support for `vcsh pull`. --- vcsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vcsh b/vcsh index a6d8213..b78235b 100755 --- a/vcsh +++ b/vcsh @@ -257,6 +257,7 @@ pull() { export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" use git pull + VCSH_COMMAND_RETURN_CODE=$? echo done hook post-pull @@ -295,6 +296,7 @@ run() { hook pre-run use "$@" + VCSH_COMMAND_RETURN_CODE=$? hook post-run } @@ -499,3 +501,4 @@ hook pre-command $VCSH_COMMAND "$@" hook post-command verbose "$VCSH_COMMAND end, exiting" +exit $VCSH_COMMAND_RETURN_CODE -- 2.39.5 From a5872a1580e7d3c9d2104d45fc74d8c1ab001f1e Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Thu, 13 Feb 2014 23:32:31 +0100 Subject: [PATCH 14/16] vcsh: Fix up the rest of the (relevant) git calls --- vcsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/vcsh b/vcsh index b78235b..068c618 100755 --- a/vcsh +++ b/vcsh @@ -175,6 +175,7 @@ commit() { export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" use git commit --untracked-files=no --quiet + VCSH_COMMAND_RETURN_CODE=$? echo done hook post-commit @@ -270,6 +271,7 @@ push() { export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" use git push + VCSH_COMMAND_RETURN_CODE=$? echo done hook post-push @@ -305,12 +307,14 @@ status() { export GIT_DIR="$VCSH_REPO_D/$VCSH_REPO_NAME.git" 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" use git status --short --untracked-files='no' + VCSH_COMMAND_RETURN_CODE=$? echo done fi -- 2.39.5 From 3c2288b6e459e70c0601afaca67b6c32b497b3ac Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Fri, 21 Feb 2014 21:35:16 +0100 Subject: [PATCH 15/16] vcsh: Support per-repo .gitattributes --- vcsh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vcsh b/vcsh index 577d235..a6653fc 100755 --- a/vcsh +++ b/vcsh @@ -334,9 +334,11 @@ 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" git config vcsh.vcsh 'true' use [ -e "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitignore.d/$VCSH_REPO_NAME" + [ -e "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" ] && git add -f "$VCSH_BASE/.gitattributes.d/$VCSH_REPO_NAME" hook post-upgrade } @@ -498,6 +500,7 @@ check_dir() { check_dir "$VCSH_REPO_D" [ ! "x$VCSH_GITIGNORE" = 'xnone' ] && check_dir "$VCSH_BASE/.gitignore.d" +check_dir "$VCSH_BASE/.gitattributes.d" verbose "$VCSH_COMMAND begin" export VCSH_COMMAND=$(echo $VCSH_COMMAND | sed 's/-/_/g') -- 2.39.5 From c2802e6be31b38797a1e8a96a7653adfa5948fc0 Mon Sep 17 00:00:00 2001 From: Richard Hartmann Date: Tue, 4 Mar 2014 20:32:22 +0100 Subject: [PATCH 16/16] 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 a6653fc..fcb3aa4 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') -- 2.39.5