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 [ -n "$VCSH_DEBUG" ] && set -x
7 [ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config"
8 [ -z "$VCSH_BASE" ] && VCSH_BASE="$XDG_CONFIG_HOME/vcsh/repo.d"
9 for check_directory in "$VCSH_BASE"
11 if [ ! -d "$check_directory" ]; then
12 if [ -e "$check_directory" ]; then
13 echo "$SELF: error: $check_directory exists but is not a directory" >&2
16 mkdir -p "$check_directory" || (echo "$SELF: error: could not create $check_directory" >&2; exit 2)
22 [ -n "$VCSH_DEBUG" ] && echo "$SELF: debug: $1"
26 if [ -n "$VCSH_DEBUG" ] || [ -n "$VCSH_VERBOSE" ]; then echo "$SELF: verbose: $1"; fi
29 # use <repo> Use this repository
31 # exit Exit vcsh mode" >&2
33 echo "usage: $SELF <args>
35 help Display this help
40 <command> Use this repository
42 init <repo> Initialize a new repository
44 [<repo>] Clone from an existing repository
46 <repo> Seed .gitignore.d/<repo> from git ls-files" >&2
52 GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
54 if [ ! -d "$GIT_DIR" ]; then
55 echo E: no repository found for "$REPO_NAME" >&2
60 export GIT_WORK_TREE="$(git config --get core.worktree)"
61 export VCSH_DIRECTORY="$REPO_NAME"
66 verbose "init() begin"
68 echo "$SELF: fatal: $GIT_DIR exists" &&
70 export GIT_WORK_TREE="$HOME"
71 mkdir -p "$GIT_WORK_TREE"
72 cd "$GIT_WORK_TREE" ||
73 (echo "$SELF: fatal: could not enter $GIT_WORK_TREE" &&
77 git config core.worktree "$GIT_WORK_TREE"
87 if [ "$1" = 'help' ] || [ "$#" -eq 0 ]; then
92 elif [ "$1" = 'list' ]; then
94 for i in "$VCSH_BASE"/*.git; do
95 echo $(basename "$i" .git)
100 elif [ "$1" = 'run' ]; then
109 #elif [ "$1" = 'use' ]; then
110 # verbose "use begin"
111 # if [ -n "$ZSH_VERSION" ]; then
112 # if [ -o NO_IGNORE_EOF ]; then
113 # export VCSH_NO_IGNORE_EOF=1
121 # bindkey '^d' 'vcsh_exit'
124 # [ -n "$ZSH_VERSION" ] && [ "$USER" = richih ] && buildPS1
128 elif [ "$1" = 'clone' ]; then
129 verbose "clone begin"
132 [ -z "$REPO_NAME" ] && REPO_NAME=$(basename "$GIT_REMOTE" .git)
134 export GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
137 git remote add origin "$GIT_REMOTE"
138 git config branch.master.remote origin
139 git config branch.master.merge refs/heads/master
141 for object in $(git ls-tree -r origin/master | awk '{print $4}'); do
143 echo "$SELF: error: $object exists." &&
146 [ "$VCSH_CONFLICT" = '1' ] &&
147 echo "$SELF: fatal: will stop after fetching and not try to merge!\n" &&
148 echo " Once this situation has been resolved, run 'vcsh run <foo> git pull' to finish cloning.\n" &&
150 git merge origin/master
151 # vcsh use $REPO_NAME
154 elif [ "$1" = 'init' ]; then
156 [ -z $2 ] && help && echo && echo "$SELF $1: please specify repository to work on" && return 0
157 export REPO_NAME="$2"
158 export GIT_DIR="$VCSH_BASE/$REPO_NAME.git"
160 # vcsh use "$REPO_NAME"
163 #elif [ "$1" = 'exit' ]; then
164 # verbose "exit begin"
165 # if [ -n "$ZSH_VERSION" ] && [ "$VCSH_NO_IGNORE_EOF" = '1' ]; then
166 # unset VCSH_NO_IGNORE_EOF
167 # setopt NO_IGNORE_EOF
170 # [ -n "$ZSH_VERSION" ] && [ "$USER" = richih ] && buildPS1
174 elif [ "$1" = 'seed-gitignore' ]; then
175 verbose "seed-gitignore begin"
176 [ -z $2 ] && help && echo && echo "$SELF $1: please specify repository to work on" && return 0
178 files=$(git ls-files)
179 gitignores=$(for file in $(git ls-files); do
181 echo $file; new="${file%/*}"
182 [ "$file" = "$new" ] && break
185 done | sort -u | sed 's/^/!/')
186 [ -e .gitignore.d/$2 ] &&
187 echo "$SELF: .gitignore.d/$2 exists, moving it to .gitignore.d/$2.bak" &&
188 mv -f .gitignore.d/$2 .gitignore.d/$2.bak
189 echo '*' > .gitignore.d/$2
190 for gitignore in $gitignores; do
191 echo $gitignore >> .gitignore.d/$2
195 verbose "defaulting to calling help()"