# [PATCH 09/19] Adding a "list" command

1 messages from 2013-03-09 to 2013-03-09. Participants: Paul Campbell.
Thread: https://gitlist.dev/t/33128

## Paul Campbell, 2013-03-09 19:26

Subject: [PATCH 09/19] Adding a "list" command
Message-ID: <CALeLG_nWWbQnmMcKoqtpdLa+7VaxMgjmAr4Y7pPZ98SNO+_05g@mail.gmail.com>
URL: https://gitlist.dev/e/CALeLG_nWWbQnmMcKoqtpdLa%2B7VaxMgjmAr4Y7pPZ98SNO%2B_05g%40mail.gmail.com

```
>From ca1c855c032d88159ed878f68ef2e18640bbd49c Mon Sep 17 00:00:00 2001
From: Paul Campbell <pcampbell@kemitix.net>
Date: Sat, 9 Mar 2013 18:33:12 +0000
Subject: [PATCH 09/19] Adding a "list" command

Conflicts:
	git-subtree.sh

Original-Author: mhoffman <matt.hoffman@quantumretail.com>
Conflicts-resolved-by: Paul Campbell <pcampbell@kemitix.net>
---
 contrib/subtree/git-subtree.sh | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 4c3f3c0..7d08064 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -107,10 +107,10 @@ shift
 case "$command" in
 	add|merge|pull|from-submodule|pull-all|push-all) default= ;;
 	*) die "Unknown command '$command'" ;;
-    split|push|diff) default="--default HEAD" ;;
+    split|push|diff|list) default="--default HEAD" ;;
 esac

-if [ -z "$prefix" -a "$command" != "pull-all" -a "$command" !=
"push-all" ]; then
+if [ -z "$prefix" -a "$command" != "pull-all" -a "$command" !=
"push-all" -a "$command" != "list" ]; then
 	die "You must provide the --prefix option."
 fi

@@ -824,6 +824,21 @@ cmd_from-submodule()
 	rm -rf $tmp_repo
 }

+subtree_list()
+{
+    git config -f .gittrees -l | grep subtree | grep path | grep -o
'=.*' | grep -o '[^=].*' |
+    while read path; do
+        repository=$(git config -f .gittrees subtree.$path.url)
+        refspec=$(git config -f .gittrees subtree.$path.branch)
+        echo "    $path        (merged from $repository branch $refspec) "
+    done
+}
+
+cmd_list()
+{
+  subtree_list
+}
+
 cmd_pull-all()
 {
     git config -f .gittrees -l | grep subtree | grep path | grep -o
'=.*' | grep -o '[^=].*' |
-- 
1.8.2.rc1


-- 
Paul [W] Campbell

```
