summaryrefslogtreecommitdiff
path: root/git-repo
diff options
context:
space:
mode:
Diffstat (limited to 'git-repo')
-rwxr-xr-xgit-repo54
1 files changed, 31 insertions, 23 deletions
diff --git a/git-repo b/git-repo
index ea047bf..6ce356f 100755
--- a/git-repo
+++ b/git-repo
@@ -62,7 +62,6 @@ do_list() {
}
_create_repo() {
- local label=$1
local shared=$2
local group=$3
local is_public=$4
@@ -82,12 +81,12 @@ _create_repo() {
read -r -p 'Set Description: '
local repo_desc=$REPLY
- read -r -p "Create $label in $repo_dir Ok? (y/N)"
+ read -r -p "Create $repo_name in $repo_dir Ok? (y/N)"
test "$REPLY" == "y" || exit 1
mkdir -p "$repo_dir"
git init -q --bare --shared="$shared" "$repo_dir"
- git config receive.denyNonFastforwards false
+ GIT_DIR="$repo_dir" git config receive.denyNonFastforwards false
chgrp -R "$group" "$repo_dir"
echo "$repo_desc" > "$repo_dir/description"
@@ -96,7 +95,7 @@ _create_repo() {
echo "created $repo_dir/PUBLIC to expose via cgit"
fi
- echo "done creating $label in $repo_dir"
+ echo "done creating $repo_name in $repo_dir"
echo "use 'git repo show $repo_dir' for details"
return 0
}
@@ -165,15 +164,16 @@ _do_make() {
local repo_dir_mode=$3
local repo_is_public=$4
test -f "$repo_path/HEAD" || { echo "$repo_path is not a git repository"; exit 1; }
- set -x
git init -q --bare --shared="$repo_file_mode" "$repo_path"
find "$repo_path" -type d -exec chown "$USER:share" \{\} \;
find "$repo_path" -type d -exec chmod "$repo_dir_mode" \{\} \;
find "$repo_path" -type f -exec chmod "$repo_file_mode" \{\} \;
if $repo_is_public; then
touch "$repo_path/PUBLIC"
+ else
+ rm -f "$repo_path/PUBLIC"
fi
- set +x
+ do_list "$repo_path"
}
do_make_public() {
@@ -188,23 +188,8 @@ do_make_private() {
_do_make "$1" 0600 0700 false
}
-case "$1" in
- list) do_list "$2" ;;
- create-public) do_create_public ;;
- create-shared) do_create_shared ;;
- create-private) do_create_private ;;
- make-public) do_make_public "$2" ;;
- make-shared) do_make_shared "$2" ;;
- make-private) do_make_private "$2" ;;
- show)
- shift
- do_show "$@"
- ;;
- mirror) do_mirror "$2" ;;
- *)
- cat <<HERE
-Unknown subcommand: '$1'
-
+do_help() {
+ cat <<HERE
Subcommands of git repo:
list [<dir>] List infos (optional: only below <dir>)
show <dir...> Show Commands for repo <dir>
@@ -230,5 +215,28 @@ Subcommands of git repo:
☛ For limited ssh-access with current user configure ~/.ssh/authorized_keys with:
command=\"git shell -c \\\"\$SSH_ORIGINAL_COMMAND\\\"\",no-port-forwarding,no-agent-forwarding,no-X11-forwarding,no-pty ssh-rsa AAAAB3.....
HERE
+}
+
+case "$1" in
+ list) do_list "$2" ;;
+ create-public) do_create_public ;;
+ create-shared) do_create_shared ;;
+ create-private) do_create_private ;;
+ make-public) do_make_public "$2" ;;
+ make-shared) do_make_shared "$2" ;;
+ make-private) do_make_private "$2" ;;
+ show)
+ shift
+ do_show "$@"
+ ;;
+ mirror) do_mirror "$2" ;;
+ help)
+ do_help
+ ;;
+ *)
+ cat <<HERE
+Unknown subcommand: '$1'
+HERE
+ do_help
;;
esac