From 58a4a5240a50ffd8081afe3d1bc04934fb0f3f14 Mon Sep 17 00:00:00 2001 From: Dewey Sasser Date: Tue, 4 Mar 2014 11:55:31 -0500 Subject: [PATCH 1/3] Added a trivial wrapper around vcsh to allow management of files in arbitrary directories in the file system. See README-vcsha.md for details. --- README-vcsha.md | 36 ++++++++++++++++++++++++++++++++++++ vcsha | 30 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100755 README-vcsha.md create mode 100755 vcsha diff --git a/README-vcsha.md b/README-vcsha.md new file mode 100755 index 00000000..f12b68d2 --- /dev/null +++ b/README-vcsha.md @@ -0,0 +1,36 @@ +Introduction +============ + +An add-on to allow VCSH (https://github.com/RichiH/vcsh) to manage +arbitrary directories. + +VCSH is a tool that allows you to manage files in your $HOME in +multiple different git repositories. + +This script is an addition that allow you to apply the same kind of +management to files in arbitrary directories *NOT* under $HOME. + + +Use +=== + +VCSHA attempts to be anaogous to the way git locates its repositories. + +Use `vcsha init` in a directory to mark it for management by vcsha. + +After that, use vcsha just as you would use vcsh but you will be +managing files underneath the marked directoriy. + +Details +======= + +As it stands, VCSH really wants to only manage files under $HOME. +However, it has a mechanism (enviornment variable "VCSH_BASE" (see +https://github.com/RichiH/vcsh/issues/112)) to work on other +directories. + +This script uses a marker directory ".vcsha" in the file system to +locate a vcsh managed directory, sets VCSH_BASE and XDG_CONFIG_HOME +appropriately, then delegates all interesting work to vcsh. + +This is useless without VCSH and is a fairly trivial addition to VCSH. diff --git a/vcsha b/vcsha new file mode 100755 index 00000000..4b805395 --- /dev/null +++ b/vcsha @@ -0,0 +1,30 @@ +#!/bin/sh + +# Purpose: wrap vcsh to allow management of arbitrary directories + +finddir() { + ( + while [ `pwd` != / ] ; do + if [ -d .vcsha ] ; then + pwd + fi + cd .. + done + ) +} + +if [ "$1" = "init" -a "$#" -eq 1 ] ; then + mkdir .vcsha + exit 0 +fi + +dir=`finddir` + +if [ -z "$dir" ] ; then + echo "Not in a vcsha repository. Use vcsha init to create a repository" + exit 1 +fi + +export VCSH_BASE="$dir" +export XDG_CONFIG_HOME="$dir" +exec vcsh "$@" From da9a89e99f683917dc46d2a726fd7d41834e331d Mon Sep 17 00:00:00 2001 From: Dewey Sasser Date: Tue, 4 Mar 2014 13:13:59 -0500 Subject: [PATCH 2/3] Added a manpage for vcsha --- Makefile | 11 +++++++-- doc/vcsha.1.ronn | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 2 deletions(-) create mode 100755 doc/vcsha.1.ronn diff --git a/Makefile b/Makefile index b40c618f..d2a1621f 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,8 @@ ZSHDIR=$(PREFIX)/share/zsh/vendor-completions RONN ?= ronn self=vcsh -manpages=$(self).1 +vcsha=vcsha +manpages=$(self).1 $(vcsha).1 all=test all: $(all) @@ -13,6 +14,7 @@ all: $(all) install: all install -d $(DESTDIR)$(PREFIX)/bin install -m 0755 $(self) $(DESTDIR)$(PREFIX)/bin + install -m 0755 $(vcsha) $(DESTDIR)$(PREFIX)/bin install -d $(DESTDIR)$(PREFIX)/share/man/man1 install -m 0644 $(manpages) $(DESTDIR)$(PREFIX)/share/man/man1 install -d $(DESTDIR)$(DOCDIR) @@ -26,12 +28,17 @@ manpages: $(manpages) $(self).1: doc/$(self).1.ronn $(RONN) < doc/$(self).1.ronn > $(self).1 || rm $(self).1 +$(vcsha).1: doc/$(self).1.ronn + $(RONN) < doc/$(self).1.ronn > $(self).1 || rm $(self).1 + clean: - rm -rf $(self).1 + rm -rf $(self).1 $(vcsha).a uninstall: rm -rf $(DESTDIR)$(PREFIX)/bin/$(self) + rm -rf $(DESTDIR)$(PREFIX)/bin/$(vcsha) rm -rf $(DESTDIR)$(PREFIX)/share/man/man1/$(self).1 + rm -rf $(DESTDIR)$(PREFIX)/share/man/man1/$(vcsha).1 rm -rf $(DESTDIR)$(DOCDIR) rm -rf $(DESTDIR)$(ZSHDIR)/_$(self) diff --git a/doc/vcsha.1.ronn b/doc/vcsha.1.ronn new file mode 100755 index 00000000..5b4e76c7 --- /dev/null +++ b/doc/vcsha.1.ronn @@ -0,0 +1,59 @@ +vcsha(1) - Use vcsh(1) on arbitrary directories +=============================================== + +## SYSTEM +`vcsha` init + +`vcsha` + +## DESCRIPTION + +This script is an addition that allow you to apply vcsh to files in +arbitrary directories *NOT* under $HOME. + +## OPTIONS + +none + +## COMMANDS + +* init: + initialize the current directory for vcsh operations. NOTE: if + `init` is passed any arguments, the whole command line will be + passed through to vcsh and have different results. + +* any vcsh command + See `vcsh`(1) for commands and options. + +## ENVIRONMENT + +Sets $VCSH_BASE and $XDG_CONFIG_HOME to the directory found for vcsha +operations. + +## CONFIG + +Similar to git, `vcsha` will examine the directory tree from the +current directory to the root directory for a ".vcsha" marker +subdirectory. If found, the directory containing ".vcsha" will be +taken to be the base of all `vcsh`(1) operations and the environment +variables will be set to that the directory containing .vcsha. `vcsha +init` is a convenience method for creating this directory. + +## AUTHOR + +This manpage and `vcsha` were written by Dewey Sasser. The script is +a trivial wrapper around the excellent work by Richard "RichiH" +Hartmann. + +## COPYRIGHT + +Copyright 2014 Dewey Sasser + +Licensed under the GNU GPL version 2 or higher. + +https://github.com/RichiH/vcsh + +## SEE ALSO + +`vcsh`(1) + From 891e8c70e85a77896da7eba7ff625ffd2902a48b Mon Sep 17 00:00:00 2001 From: Dewey Sasser Date: Tue, 4 Mar 2014 13:23:01 -0500 Subject: [PATCH 3/3] Updated makefile to include vcsha --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 Makefile diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index d2a1621f..5ac89eda --- a/Makefile +++ b/Makefile @@ -28,11 +28,11 @@ manpages: $(manpages) $(self).1: doc/$(self).1.ronn $(RONN) < doc/$(self).1.ronn > $(self).1 || rm $(self).1 -$(vcsha).1: doc/$(self).1.ronn - $(RONN) < doc/$(self).1.ronn > $(self).1 || rm $(self).1 +$(vcsha).1: doc/$(vcsha).1.ronn + $(RONN) < doc/$(vcsha).1.ronn > $(vcsha).1 || rm $(vcsha).1 clean: - rm -rf $(self).1 $(vcsha).a + rm -rf $(self).1 $(vcsha).1 uninstall: rm -rf $(DESTDIR)$(PREFIX)/bin/$(self)