prompt: squelch error output from cat
The files $g/rebase-{merge,apply}/{head-name,msgnum,end} are not guaranteed to exist. When attempting to cat them, squelch the error output. In addition to guarding against stray directories, this patch addresses a real problem: # on terminal 1 $ git rebase -i master # ignore editor, and switch to terminal 2 cat: .git/rebase-merge/msgnum: No such file or directory cat: .git/rebase-merge/end: No such file or directory $ Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ramkumar Ramachandra committed
Jun 14, 2013 at 13:58 UTC
2847cae835fa70f00e6e2286fbfa5595cb2247d0
1 file changed
+6
-6
contrib/completion/git-prompt.sh
+6
-6
@@ -347,9 +347,9 @@ __git_ps1 ()
347
local step=""
348
local total=""
349
if [ -d "$g/rebase-merge" ]; then
350
- b="$(cat "$g/rebase-merge/head-name")"
351
- step=$(cat "$g/rebase-merge/msgnum")
352
- total=$(cat "$g/rebase-merge/end")
350
+ b="$(cat "$g/rebase-merge/head-name" 2>/dev/null)"
351
+ step=$(cat "$g/rebase-merge/msgnum" 2>/dev/null)
352
+ total=$(cat "$g/rebase-merge/end" 2>/dev/null)
353
if [ -f "$g/rebase-merge/interactive" ]; then
354
r="|REBASE-i"
355
else
@@ -357,10 +357,10 @@ __git_ps1 ()
357
fi
358
else
359
if [ -d "$g/rebase-apply" ]; then
360
- step=$(cat "$g/rebase-apply/next")
361
- total=$(cat "$g/rebase-apply/last")
360
+ step=$(cat "$g/rebase-apply/next" 2>/dev/null)
361
+ total=$(cat "$g/rebase-apply/last" 2>/dev/null)
362
if [ -f "$g/rebase-apply/rebasing" ]; then
363
- b="$(cat "$g/rebase-apply/head-name")"
363
+ b="$(cat "$g/rebase-apply/head-name" 2>/dev/null)"
364
r="|REBASE"
365
elif [ -f "$g/rebase-apply/applying" ]; then
366
r="|AM"