Skip to content

Commit 2847cae

Browse files
artagnongitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 45acb75 commit 2847cae

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

contrib/completion/git-prompt.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,20 +347,20 @@ __git_ps1 ()
347347
local step=""
348348
local total=""
349349
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)
353353
if [ -f "$g/rebase-merge/interactive" ]; then
354354
r="|REBASE-i"
355355
else
356356
r="|REBASE-m"
357357
fi
358358
else
359359
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)
362362
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)"
364364
r="|REBASE"
365365
elif [ -f "$g/rebase-apply/applying" ]; then
366366
r="|AM"

0 commit comments

Comments
 (0)