Skip to content

Commit 54baefd

Browse files
Greg Brockmangitster
Greg Brockman
authored andcommitted
Add sample commands for git-shell
Provide a 'list' command to view available bare repositories ending in .git and a 'help command to display usage. Also add documentation in a README Signed-off-by: Greg Brockman <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e69164d commit 54baefd

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

contrib/git-shell-commands/README

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Sample programs callable through git-shell. Place a directory named
2+
'git-shell-commands' in the home directory of a user whose shell is
3+
git-shell. Then anyone logging in as that user will be able to run
4+
executables in the 'git-shell-commands' directory.
5+
6+
Provided commands:
7+
8+
help: Prints out the names of available commands. When run
9+
interactively, git-shell will automatically run 'help' on startup,
10+
provided it exists.
11+
12+
list: Displays any bare repository whose name ends with ".git" under
13+
user's home directory. No other git repositories are visible,
14+
although they might be clonable through git-shell. 'list' is designed
15+
to minimize the number of calls to git that must be made in finding
16+
available repositories; if your setup has additional repositories that
17+
should be user-discoverable, you may wish to modify 'list'
18+
accordingly.

contrib/git-shell-commands/help

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/sh
2+
3+
if tty -s
4+
then
5+
echo "Run 'help' for help, or 'exit' to leave. Available commands:"
6+
else
7+
echo "Run 'help' for help. Available commands:"
8+
fi
9+
10+
cd "$(dirname "$0")"
11+
12+
for cmd in *
13+
do
14+
case "$cmd" in
15+
help) ;;
16+
*) [ -f "$cmd" ] && [ -x "$cmd" ] && echo "$cmd" ;;
17+
esac
18+
done

contrib/git-shell-commands/list

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
3+
print_if_bare_repo='
4+
if "$(git --git-dir="$1" rev-parse --is-bare-repository)" = true
5+
then
6+
printf "%s\n" "${1#./}"
7+
fi
8+
'
9+
10+
find -type d -name "*.git" -exec sh -c "$print_if_bare_repo" -- \{} \; -prune 2>/dev/null

0 commit comments

Comments
 (0)