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.
6 [ -z $XDG_CONFIG_HOME ] && XDG_CONFIG_HOME="$HOME/.config"
7 for dir in $XDG_CONFIG_HOME $XDG_CONFIG_HOME/vcsh $XDG_CONFIG_HOME/vcsh/repo.d
10 if [ ! -d $dir ]; then
12 echo "$SELF: error: $dir exists but is not a directory" >&2
15 mkdir $dir || (echo "$SELF: error: could not create $dir" >&2; return 2)
19 VCSH_BASE="$XDG_CONFIG_HOME/vcsh/repo.d"
22 echo "usage: $SELF <args>
24 help Display this help
28 use <repo> Use this repository
30 <command> Use this repository
32 init Initialize a new repository
34 [<repo>] Clone from an existing repository
36 exit Exit vcsh mode" >&2
41 GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
43 if [ ! -d "$GIT_DIR" ]; then
44 echo E: no repository found for "$REPO_NAME" >&2
49 export GIT_WORK_TREE="$(git config --get core.worktree)"
50 export VCSH_DIRECTORY="$REPO_NAME"
55 echo "$SELF: fatal: $GIT_DIR exists" &&
57 export GIT_WORK_TREE="$HOME"
58 mkdir -p $GIT_WORK_TREE
60 (echo "$SELF: fatal: could not enter $GIT_WORK_TREE" &&
64 git config core.worktree $GIT_WORK_TREE
73 if [ "$1" = 'help' ] || [ $# -eq 0 ]; then
78 elif [ "$1" = 'list' ]; then
79 for i in $VCSH_BASE/*.git; do
80 echo $(basename $i .git)
84 elif [ "$1" = 'run' ]; then
91 elif [ "$1" = 'use' ]; then
92 if [[ -o NO_IGNORE_EOF ]]; then
93 export VCSH_NO_IGNORE_EOF=1
95 vcsh_exit() {vcsh exit; zle reset-prompt;}
97 bindkey '^d' 'vcsh_exit'
103 elif [ "$1" = 'clone' ]; then
106 [[ -z $REPO_NAME ]] && REPO_NAME=$(basename $GIT_REMOTE .git)
108 export GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
111 git remote add origin $GIT_REMOTE
112 git config branch.master.remote origin
113 git config branch.master.merge refs/heads/master
115 for i in $(git ls-tree -r origin/master | awk '{print $4}'); do
117 echo "$SELF: error: $i exists." &&
120 [[ -n $CONFLICT ]] &&
121 echo "$SELF: fatal: will stop after fetching and not try to merge!\n" &&
123 git merge origin/master
126 elif [ "$1" = 'init' ]; then
127 export REPO_NAME="$2"
128 export GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
132 elif [ "$1" = 'exit' ]; then
133 if [[ $VCSH_NO_IGNORE_EOF -gt 0 ]]; then
134 unset VCSH_NO_IGNORE_EOF