|author||Diana Picus <firstname.lastname@example.org>||2016-06-23 14:44:19 +0300|
|committer||Diana Picus <email@example.com>||2016-06-29 12:55:41 +0300|
[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
1 files changed, 36 insertions, 2 deletions
diff --git a/helpers/llvm-env b/helpers/llvm-env
index d90c767..c45fb2e 100755
@@ -20,14 +20,48 @@ if [ -z "$PS1" ]; then
+ # 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
+ if [ "$current_worktree" = $LLVM_ROOT/$dir/llvm ]; then
+ echo "[ Worktree: $dir ($branch) ]"
+ echo "Wortkree: $dir ($branch)"
if [ "$1" = "" ]; then
if [ -z "$LLVM_SRC" ]; then
- echo "You haven't set up a worktree"
+ echo "You haven't set up an env (LLVM_SRC is empty)"
worktree=`basename $(readlink -m $LLVM_SRC/../)`
- echo $worktree
+ list_worktrees $LLVM_SRC
elif [ "$1" = "-h" ]; then
echo "Usage: $0 <branch> [-cleanup] [-d]"