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.
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 echo "usage: $SELF <args>
25 help Display this help
29 use <repo> Use this repository
31 <command> Use this repository
33 init Initialize a new repository
35 [<repo>] Clone from an existing repository
37 exit Exit vcsh mode" >&2
42 GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
44 if [ ! -d "$GIT_DIR" ]; then
45 echo E: no repository found for "$REPO_NAME" >&2
50 export GIT_WORK_TREE="$(git config --get core.worktree)"
51 export VCSH_DIRECTORY="$REPO_NAME"
56 echo "$SELF: fatal: $GIT_DIR exists" &&
58 export GIT_WORK_TREE="$HOME"
59 mkdir -p $GIT_WORK_TREE
61 (echo "$SELF: fatal: could not enter $GIT_WORK_TREE" &&
65 git config core.worktree $GIT_WORK_TREE
74 if [ "$1" = 'help' ] || [ $# -eq 0 ]; then
79 elif [ "$1" = 'list' ]; then
80 for i in $VCSH_BASE/*.git; do
81 echo $(basename $i .git)
85 elif [ "$1" = 'run' ]; then
92 elif [ "$1" = 'use' ]; then
93 if [[ -o NO_IGNORE_EOF ]]; then
94 export VCSH_NO_IGNORE_EOF=1
96 vcsh_exit() {vcsh exit; zle reset-prompt;}
98 bindkey '^d' 'vcsh_exit'
104 elif [ "$1" = 'clone' ]; then
107 [[ -z $REPO_NAME ]] && REPO_NAME=$(basename $GIT_REMOTE .git)
109 export GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
112 git remote add origin $GIT_REMOTE
113 git config branch.master.remote origin
114 git config branch.master.merge refs/heads/master
116 for i in $(git ls-tree -r origin/master | awk '{print $4}'); do
118 echo "$SELF: error: $i exists." &&
121 [[ -n $CONFLICT ]] &&
122 echo "$SELF: fatal: will stop after fetching and not try to merge!\n" &&
124 git merge origin/master
127 elif [ "$1" = 'init' ]; then
128 export REPO_NAME="$2"
129 export GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
133 elif [ "$1" = 'exit' ]; then
134 if [[ $VCSH_NO_IGNORE_EOF -gt 0 ]]; then
135 unset VCSH_NO_IGNORE_EOF