All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 [ "$VCSH_DEBUG" = '1' ] && set -x
7 [ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
8 for check_directory in $XDG_CONFIG_HOME $XDG_CONFIG_HOME/vcsh $XDG_CONFIG_HOME/vcsh/repo.d
10 if [ ! -d "$check_directory" ]; then
11 if [ -e "$check_directory" ]; then
12 echo "$SELF: error: $check_directory exists but is not a directory" >&2
15 mkdir $check_directory || (echo "$SELF: error: could not create $check_directory" >&2; exit 2)
20 VCSH_BASE="$XDG_CONFIG_HOME/vcsh/repo.d"
23 [ "$VCSH_DEBUG" = '1' ] && echo "$SELF: debug: $1"
27 if [ "$VCSH_DEBUG" = '1' ] || [ "$VCSH_VERBOSE" = '1' ]; then echo "$SELF: verbose: $1"; fi
30 # use <repo> Use this repository
32 echo "usage: $SELF <args>
34 help Display this help
39 <command> Use this repository
41 init Initialize a new repository
43 [<repo>] Clone from an existing repository
45 exit Exit vcsh mode" >&2
51 GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
53 if [ ! -d "$GIT_DIR" ]; then
54 echo E: no repository found for "$REPO_NAME" >&2
59 export GIT_WORK_TREE="$(git config --get core.worktree)"
60 export VCSH_DIRECTORY="$REPO_NAME"
65 verbose "init() begin"
67 echo "$SELF: fatal: $GIT_DIR exists" &&
69 export GIT_WORK_TREE="$HOME"
70 mkdir -p $GIT_WORK_TREE
72 (echo "$SELF: fatal: could not enter $GIT_WORK_TREE" &&
76 git config core.worktree $GIT_WORK_TREE
86 if [ "$1" = 'help' ] || [ "$#" -eq 0 ]; then
91 elif [ "$1" = 'list' ]; then
93 for i in $VCSH_BASE/*.git; do
94 echo $(basename $i .git)
99 elif [ "$1" = 'run' ]; then
108 #elif [ "$1" = 'use' ]; then
109 # verbose "use begin"
110 # if [ -n "$ZSH_VERSION" ]; then
111 # if [ -o NO_IGNORE_EOF ]; then
112 # export VCSH_NO_IGNORE_EOF=1
120 # bindkey '^d' 'vcsh_exit'
123 # [ -n "$ZSH_VERSION" ] && [ "$USER" = richih ] && buildPS1
127 elif [ "$1" = 'clone' ]; then
128 verbose "clone begin"
131 [ -z "$REPO_NAME" ] && REPO_NAME=$(basename $GIT_REMOTE .git)
133 export GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
136 git remote add origin $GIT_REMOTE
137 git config branch.master.remote origin
138 git config branch.master.merge refs/heads/master
140 for object in $(git ls-tree -r origin/master | awk '{print $4}'); do
142 echo "$SELF: error: $object exists." &&
145 [ "$VCSH_CONFLICT" = '1' ] &&
146 echo "$SELF: fatal: will stop after fetching and not try to merge!\n" &&
148 git merge origin/master
149 # vcsh use $REPO_NAME
152 elif [ "$1" = 'init' ]; then
154 export REPO_NAME="$2"
155 export GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
157 # vcsh use $REPO_NAME
160 elif [ "$1" = 'exit' ]; then
162 if [ -n "$ZSH_VERSION" ] && [ "$VCSH_NO_IGNORE_EOF" = '1' ]; then
163 unset VCSH_NO_IGNORE_EOF
167 [ -n "$ZSH_VERSION" ] && [ "$USER" = richih ] && buildPS1
172 verbose "defaulting to calling help()"