git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] Add sample commands for git-shell

From
Greg Brockman <gdb@mit.edu>
Date
Jul 21, 2010, 15:15 UTC
Message-ID
<1279725355-23016-4-git-send-email-gdb@mit.edu>
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
Previous: Greg BrockmanNext: Greg Brockman
Message 4 of 23 in “[PATCHv3] Updated patch series for providing mechanism to list available repositories”
  1. Greg BrockmanJul 21, 2010
  2. 1/3 Allow creation of arbitrary git-shell commandsGreg Brockman, Jul 21, 2010
  3. 2/3 Add interactive mode to git-shell for user-friendlinessGreg Brockman, Jul 21, 2010
  4. 3/3 Add sample commands for git-shellGreg Brockman, Jul 21, 2010
  5. Greg BrockmanJul 26, 2010
  6. Ævar Arnfjörð BjarmasonJul 26, 2010
  7. Greg BrockmanJul 26, 2010
  8. Jakub NarebskiJul 27, 2010
  9. Jonathan NiederJul 26, 2010
  10. Greg BrockmanJul 27, 2010
  11. Jonathan NiederJul 27, 2010
  12. Johannes SixtJul 27, 2010
  13. Jonathan NiederJul 27, 2010
  14. Greg BrockmanJul 27, 2010
  15. Jonathan NiederJul 28, 2010
  16. Greg BrockmanJul 28, 2010
  17. Jonathan NiederJul 28, 2010
  18. Greg BrockmanJul 28, 2010
  19. Anders KaseorgJul 28, 2010
  20. Jonathan NiederJul 28, 2010
  21. Greg BrockmanJul 29, 2010
  22. Jonathan NiederJul 29, 2010
  23. Jonathan NiederJul 28, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.