Thread (51 messages) flat view 51 messages, 5 authors, 2016-06-15
STALE3706d

[PATCH 1/2] Update the bash prompt from 'applied' instead of the obsolete 'current'

From: Robin Rosenberg <hidden>
Date: 2016-06-15 22:43:11
Subsystem: the rest · Maintainer: Linus Torvalds

Signed-off-by: Robin Rosenberg <redacted>

s�ndag 20 maj 2007 skrev Yann Dirson:
Note that "tail -1" gives a warning with newer versions, "tail -n 1"
should be the proper call.
My man page doesn't mention -N being deprecated, but ok since -n 1 seems
to work here too.
 
Also I'm not sure it is a good way to look at "applied" file, since
Karl IIRC has plans to change this.  Better call "stg top" and not
touch that again :)
Calling stg is too slow to be be used here. I that command in my first draft
for this function and people complained (see the thread named "Bash snippet
to show branch and patch in bash prompt"). It takes ~ 0.15s on here which is
very noticable, barely below my pain threshold. 

We'll update the prompt when and if Karl breaks this.

It'd probably drain my battery too :/

-- robin

 contrib/stgbashprompt.sh |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/stgbashprompt.sh b/contrib/stgbashprompt.sh
index 16bb39b..f4817a1 100755
--- a/contrib/stgbashprompt.sh
+++ b/contrib/stgbashprompt.sh
@@ -8,8 +8,8 @@ if [ "$PS1" ]; then
 		git_dir=$(git-rev-parse --git-dir 2> /dev/null) || return
 		ref=$(git-symbolic-ref HEAD 2> /dev/null) || return
 		br=${ref#refs/heads/}
-		top=$(cat $git_dir/patches/$br/current 2>/dev/null) \
-			&& top="/$top"
+		top=$(tail -n 1 $git_dir/patches/$br/applied 2>/dev/null) \
+			&& top="/$top";
 		echo "[$br$top]"
 	}
 	PS1='\u@\h:$(__prompt_git)\W\$ '
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help