git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Brockman <gdb@MIT.EDU>
To: j.sixt@viscovery.net, gitster@pobox.com, avarab@gmail.com,
	jrnieder@gmail.com, git@vger.kernel.org
Cc: Greg Brockman <gdb@mit.edu>
Subject: [PATCH 3/3] Add sample commands for git-shell
Date: Wed, 21 Jul 2010 11:15:55 -0400	[thread overview]
Message-ID: <1279725355-23016-4-git-send-email-gdb@mit.edu> (raw)
In-Reply-To: <1279725355-23016-1-git-send-email-gdb@mit.edu>

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 <gdb@mit.edu>
---
 contrib/git-shell-commands/README |   23 +++++++++++++++++++++++
 contrib/git-shell-commands/help   |   16 ++++++++++++++++
 contrib/git-shell-commands/list   |   10 ++++++++++
 3 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100644 contrib/git-shell-commands/README
 create mode 100755 contrib/git-shell-commands/help
 create mode 100755 contrib/git-shell-commands/list

diff --git a/contrib/git-shell-commands/README b/contrib/git-shell-commands/README
new file mode 100644
index 0000000..57d7a79
--- /dev/null
+++ b/contrib/git-shell-commands/README
@@ -0,0 +1,23 @@
+Sample programs callable through git-shell.  Place a directory named
+'git-shell-commands' in the home directory of a user whose shell is
+git-shell.  Then anyone logging in as that user will be able to run
+executables in the 'git-shell-commands' directory.
+
+Note that git-shell assumes its CWD is the user's home directory, so
+trying to 'su' to a user whose shell is git-shell would result in
+running commands out of "$(cwd)/git-shell-commands", which may not be
+desired behavior.
+
+Provided commands:
+
+help: Prints out the names of available commands.  When run
+interactively, git-shell will automatically run 'help' on startup,
+provided it exists.
+
+list: Displays any bare repository whose name ends with ".git" under
+user's home directory.  No other git repositories are visible,
+although they might be clonable through git-shell.  'list' is designed
+to minimize the number of calls to git that must be made in finding
+available repositories; if your setup has additional repositories that
+should be user-discoverable, you may wish to modify 'list'
+accordingly.
diff --git a/contrib/git-shell-commands/help b/contrib/git-shell-commands/help
new file mode 100755
index 0000000..a43fcd6
--- /dev/null
+++ b/contrib/git-shell-commands/help
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+if tty -s; then
+    echo "Run 'help' for help, or 'exit' to leave.  Available commands:"
+else
+    echo "Run 'help' for help.  Available commands:"
+fi
+
+cd "$(dirname "$0")"
+
+for cmd in *; do
+    case "$cmd" in
+	help) ;;
+	*) [ -f "$cmd" ] && [ -x "$cmd" ] && echo "$cmd" ;;
+    esac
+done
diff --git a/contrib/git-shell-commands/list b/contrib/git-shell-commands/list
new file mode 100755
index 0000000..4654535
--- /dev/null
+++ b/contrib/git-shell-commands/list
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+print_if_bare_repo='
+       if "$(git --git-dir="$1" rev-parse --is-bare-repository)" = true
+       then
+               printf "%s\n" "${1#./}"
+       fi
+'
+
+find -type d -name "*.git" -exec sh -c "$print_if_bare_repo" -- \{} \; -prune
-- 
1.7.0.4

  parent reply	other threads:[~2010-07-21 15:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-21 15:15 [PATCHv3] Updated patch series for providing mechanism to list available repositories Greg Brockman
2010-07-21 15:15 ` [PATCH 1/3] Allow creation of arbitrary git-shell commands Greg Brockman
2010-07-21 15:15 ` [PATCH 2/3] Add interactive mode to git-shell for user-friendliness Greg Brockman
2010-07-21 15:15 ` Greg Brockman [this message]
2010-07-26 22:32 ` [PATCHv3] Updated patch series for providing mechanism to list available repositories Greg Brockman
2010-07-26 22:54   ` Ævar Arnfjörð Bjarmason
2010-07-26 23:18     ` Greg Brockman
2010-07-27  9:02       ` Jakub Narebski
2010-07-26 23:28     ` Jonathan Nieder
2010-07-27  0:20       ` Greg Brockman
2010-07-27  0:50         ` Jonathan Nieder
2010-07-27  7:16         ` Johannes Sixt
2010-07-27 17:41           ` Jonathan Nieder
2010-07-27 22:43             ` Greg Brockman
2010-07-28  0:33               ` Jonathan Nieder
2010-07-28  6:15                 ` Greg Brockman
2010-07-28  6:42                   ` Jonathan Nieder
2010-07-28  7:06                     ` Greg Brockman
2010-07-28 23:14                     ` Anders Kaseorg
2010-07-28 23:52                       ` Jonathan Nieder
2010-07-29  0:21                         ` Greg Brockman
2010-07-29  0:33                           ` Jonathan Nieder
2010-07-28  1:10               ` Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1279725355-23016-4-git-send-email-gdb@mit.edu \
    --to=gdb@mit.edu \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).