aboutsummaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2016-06-23 14:44:19 +0300
committerDiana Picus <diana.picus@linaro.org>2016-06-29 12:55:41 +0300
commitdb95ab279074944729dc4a45621706db0ac09918 (patch)
treedaf06a1943013a0a8e3df6823f37c5d5fbf1ab04 /helpers
parent600c05a4cfcc83ba0ade98ced85c46fea0b49fc8 (diff)
[llvm-env] List current worktree directories
When running llvm-env without any arguments, it now dumps the current worktrees, as well as the branch that is currently checked out in them (only for llvm, to make it easy to spot places where this is different from the environment name). This is a very hacky implementation, because newer versions of git will come with git worktree list, which does exactly what we want. We can nuke this when we're all ready to move to newer gits. Change-Id: I787594ce1ecea0de68ceb0e518194b783da408b3
Diffstat (limited to 'helpers')
-rwxr-xr-xhelpers/llvm-env38
1 files changed, 36 insertions, 2 deletions
diff --git a/helpers/llvm-env b/helpers/llvm-env
index d90c767..c45fb2e 100755
--- a/helpers/llvm-env
+++ b/helpers/llvm-env
@@ -20,14 +20,48 @@ if [ -z "$PS1" ]; then
exit 1
fi
+list_worktrees() {
+ current_worktree=$1
+
+ # FIXME:
+ # Ideally we would just use git for this (I think git 2.7-ish should suffice),
+ # but I'm currently stuck with git 2.5 on my Ubuntu and it seems to me the
+ # rest of the team is on older gits too. Until we all move to a smarter git,
+ # we're going to use the simplest possible implementation that can give us
+ # what we want (the proper way to do this ofc would be to inspect
+ # $GITDIR/worktrees/). This implementation has the disadvantage that it may
+ # give false positives or false negatives if you do naughty things with your
+ # $LLVM_ROOT.
+ pushdq $LLVM_ROOT
+
+ for dir in *; do
+ if [ -d "$dir" -a "$dir" != "repos" -a -d "$dir/llvm" ]; then
+ pushdq $dir/llvm
+ branch=`get_branch`
+ popdq
+
+ if [ "$current_worktree" = $LLVM_ROOT/$dir/llvm ]; then
+ echo "[ Worktree: $dir ($branch) ]"
+ else
+ echo "Wortkree: $dir ($branch)"
+ fi
+ fi
+ done
+
+ popdq
+}
+
if [ "$1" = "" ]; then
if [ -z "$LLVM_SRC" ]; then
- echo "You haven't set up a worktree"
+ list_worktrees
+ echo "You haven't set up an env (LLVM_SRC is empty)"
eval $clean_exit
fi
worktree=`basename $(readlink -m $LLVM_SRC/../)`
- echo $worktree
+
+ list_worktrees $LLVM_SRC
+
eval $clean_exit
elif [ "$1" = "-h" ]; then
echo "Usage: $0 <branch> [-cleanup] [-d]"