* [PATCH] cg-status: handle subdirs when listing heads
@ 2005-12-11 19:03 Jonas Fonseca
2005-12-11 19:49 ` Jonas Fonseca
0 siblings, 1 reply; 2+ messages in thread
From: Jonas Fonseca @ 2005-12-11 19:03 UTC (permalink / raw)
To: Petr Baudis, git
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
fonseca@antimatter:~/src/cogito/cogito > cg switch -r master tmp/work
Creating new branch tmp/work: 218ee732bee381746890bf5ffb9bfc4672795954
Switching to branch tmp/work...
fonseca@antimatter:~/src/cogito/cogito > cg status
Heads:
cg-object-id c10cc1d2a99b01ed3bf45d5f2ad6157940a22365
cg-Xedit 41447107236a7d23daa6ab0f40a0829935485bc8
master 218ee732bee381746890bf5ffb9bfc4672795954
R origin 218ee732bee381746890bf5ffb9bfc4672795954
cat: .git/refs/heads/tmp: Is a directory
tmp
commit 2e7be765ca86117dc7af8aa0cd0f090269fee428
tree 0154d7f35e6ae7c357ff18e7b1f46e2ee4d25309
parent 218ee732bee381746890bf5ffb9bfc4672795954
author Jonas Fonseca <fonseca@diku.dk> Sun, 11 Dec 2005 19:57:31 +0100
committer Jonas Fonseca <fonseca@antimatter.localdomain> Sun, 11 Dec 2005 19:57:31 +0100
cg-status | 28 +++++++++++++++++++---------
1 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/cg-status b/cg-status
index a4c5e7a..629c796 100755
--- a/cg-status
+++ b/cg-status
@@ -106,6 +106,24 @@ if [ ! "$gitstatus" ] && [ ! "$workstatu
fi
+list_heads()
+{
+ local path="$1"
+
+ if [ -d "$path" ]; then
+ for head in "$path"/*; do
+ list_heads "$head"
+ done
+ else
+ headsha1=$(cat "$path")
+ headname=${path#$_git/refs/heads/}
+ [ "$headname" = "cg-seek-point" ] && continue
+ cf=" "; rf=" "
+ [ "$headname" = "$_git_head" ] && cf=">"
+ [ -s "$_git/branches/$headname" ] && rf="R"
+ echo -e " $rf$cf$headname\t$headsha1"
+ fi
+}
if [ "$gitstatus" ]; then
mkdir -p $_git/refs/heads
@@ -123,15 +141,7 @@ if [ "$gitstatus" ]; then
fi
echo "Heads:"
- for head in $_git/refs/heads/*; do
- headsha1=$(cat "$head")
- headname=$(basename "$head")
- [ "$headname" = "cg-seek-point" ] && continue
- cf=" "; rf=" "
- [ "$headname" = "$_git_head" ] && cf=">"
- [ -s "$_git/branches/$headname" ] && rf="R"
- echo -e " $rf$cf$headname\t$headsha1"
- done
+ list_heads "$_git/refs/heads"
if [ -s "$_git/merging" ]; then
tmp=$(cat "$_git/merging")
\f
!-------------------------------------------------------------flip-
--
Jonas Fonseca
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH] cg-status: handle subdirs when listing heads
2005-12-11 19:03 [PATCH] cg-status: handle subdirs when listing heads Jonas Fonseca
@ 2005-12-11 19:49 ` Jonas Fonseca
0 siblings, 0 replies; 2+ messages in thread
From: Jonas Fonseca @ 2005-12-11 19:49 UTC (permalink / raw)
To: Petr Baudis, git
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
---
And here's one which handles empty directories and is cleaner.
diff --git a/cg-status b/cg-status
index a4c5e7a..bd4d0ce 100755
--- a/cg-status
+++ b/cg-status
@@ -123,9 +123,9 @@ if [ "$gitstatus" ]; then
fi
echo "Heads:"
- for head in $_git/refs/heads/*; do
+ find "$_git/refs/heads" ! -type d | sort | while read head; do
headsha1=$(cat "$head")
- headname=$(basename "$head")
+ headname=${head#$_git/refs/heads/}
[ "$headname" = "cg-seek-point" ] && continue
cf=" "; rf=" "
[ "$headname" = "$_git_head" ] && cf=">"
--
Jonas Fonseca
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-12-11 19:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-11 19:03 [PATCH] cg-status: handle subdirs when listing heads Jonas Fonseca
2005-12-11 19:49 ` Jonas Fonseca
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).