* test_pause giving '__git_ps1: not found' warning @ 2023-01-14 14:54 Philip Oakley 2023-01-14 17:49 ` Philip Oakley 0 siblings, 1 reply; 4+ messages in thread From: Philip Oakley @ 2023-01-14 14:54 UTC (permalink / raw) To: Git List, Philippe Blain, Elijah Newren; +Cc: Philip Oakley I was trying to refine a test_expect_failure test [1] and tried inserting a `test_pause &&` test line [2]. I then found, when it paused, I was repeatedly given the warning line /bin/sh: 1: __git_ps1: not found in the terminal until I expected the test shell. my PS1 is working normally in the terminal, but not here. Is this expected, or do I need to set up anything else? Normally I'm on Git for Windows, but this was on my old laptop (Acer 7741 i5 4GB ram..) converted to Ubuntu 20.04, which I use when away. The basic sequence was ~$ cd repos/git ~/repos/git (doctrunc *)$ cd t ~/repos/git/t (doctrunc *)$ ./t4205-log-pretty-formats.sh -i -x -v Initialized empty Git repository in /home/philip/repos/git/t/trash directory.t4205-log-pretty-formats/.git/ [... ...] + git log --format=%<(5,mtrunc)%s -4 + test_pause + PAUSE_TERM=dumb + PAUSE_SHELL=/bin/sh + PAUSE_HOME=/home/philip/repos/git/t/trash directory.t4205-log-pretty-formats + test 0 != 0 + TERM=dumb HOME=/home/philip/repos/git/t/trash directory.t4205-log-pretty-formats /bin/sh /bin/sh: 1: __git_ps1: not found \w$ git status On branch source-b [...] nothing added to commit but untracked files present (use "git add" to track) /bin/sh: 1: __git_ps1: not found I added the gits status to see when/where the warning was emitted. [1] https://github.com/PhilipOakley/git/blob/doctrunc/t/t4205-log-pretty-formats.sh#L1021-L1046 [2] https://github.com/git/git/blob/master/t/test-lib-functions.sh#L137-L188 Any suggestions as to how to set this up correctly to avoid the warning? -- Philip ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: test_pause giving '__git_ps1: not found' warning 2023-01-14 14:54 test_pause giving '__git_ps1: not found' warning Philip Oakley @ 2023-01-14 17:49 ` Philip Oakley 2023-01-16 17:38 ` Jeff King 0 siblings, 1 reply; 4+ messages in thread From: Philip Oakley @ 2023-01-14 17:49 UTC (permalink / raw) To: Git List, Philippe Blain, Elijah Newren On 14/01/2023 14:54, Philip Oakley wrote: > I was trying to refine a test_expect_failure test [1] and tried > inserting a `test_pause &&` test line [2]. > > I then found, when it paused, I was repeatedly given the warning line > /bin/sh: 1: __git_ps1: not found > in the terminal until I expected the test shell. > > my PS1 is working normally in the terminal, but not here. Is this > expected, or do I need to set up anything else? > > Normally I'm on Git for Windows, but this was on my old laptop (Acer > 7741 i5 4GB ram..) converted to Ubuntu 20.04, which I use when away. > > The basic sequence was > > ~$ cd repos/git > ~/repos/git (doctrunc *)$ cd t > ~/repos/git/t (doctrunc *)$ ./t4205-log-pretty-formats.sh -i -x -v > Initialized empty Git repository in /home/philip/repos/git/t/trash > directory.t4205-log-pretty-formats/.git/ > > [... ...] > > + git log --format=%<(5,mtrunc)%s -4 > + test_pause > + PAUSE_TERM=dumb > + PAUSE_SHELL=/bin/sh > + PAUSE_HOME=/home/philip/repos/git/t/trash > directory.t4205-log-pretty-formats > + test 0 != 0 > + TERM=dumb HOME=/home/philip/repos/git/t/trash > directory.t4205-log-pretty-formats /bin/sh I think the 'gotcha' is here in the setting of HOME within the test_pause which in some ways conflicts with the setting of the __git_ps1 instructions [3]. My local .bashrc has . /home/philip/git-completion.bash . ~/git-prompt.sh export GIT_PS1_SHOWDIRTYSTATE=1 export PS1='\w$(__git_ps1 " (%s)")\$ ' Not sure why I have a relative and an absolute path but... , so I'll try updating the git-prompt.sh to an absolute path, and if that works, maybe think about adding an extra comment to the `test-lib-functions.sh` to note the change of HOME and potential '__git_ps1' problem [3] https://git-scm.com/book/uz/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bash > /bin/sh: 1: __git_ps1: not found > \w$ git status > On branch source-b > [...] > nothing added to commit but untracked files present (use "git add" to > track) > /bin/sh: 1: __git_ps1: not found > > I added the gits status to see when/where the warning was emitted. > > [1] > https://github.com/PhilipOakley/git/blob/doctrunc/t/t4205-log-pretty-formats.sh#L1021-L1046 > [2] > https://github.com/git/git/blob/master/t/test-lib-functions.sh#L137-L188 > > > Any suggestions as to how to set this up correctly to avoid the warning? > -- > Philip ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: test_pause giving '__git_ps1: not found' warning 2023-01-14 17:49 ` Philip Oakley @ 2023-01-16 17:38 ` Jeff King 2023-01-18 13:50 ` Philip Oakley 0 siblings, 1 reply; 4+ messages in thread From: Jeff King @ 2023-01-16 17:38 UTC (permalink / raw) To: Philip Oakley; +Cc: Git List, Philippe Blain, Elijah Newren On Sat, Jan 14, 2023 at 05:49:15PM +0000, Philip Oakley wrote: > On 14/01/2023 14:54, Philip Oakley wrote: > > I was trying to refine a test_expect_failure test [1] and tried > > inserting a `test_pause &&` test line [2]. > > > > I then found, when it paused, I was repeatedly given the warning line > > /bin/sh: 1: __git_ps1: not found > > in the terminal until I expected the test shell. > > > > my PS1 is working normally in the terminal, but not here. Is this > > expected, or do I need to set up anything else? > > > > Normally I'm on Git for Windows, but this was on my old laptop (Acer > > 7741 i5 4GB ram..) converted to Ubuntu 20.04, which I use when away. On Ubuntu, your /bin/sh is likely to be dash. And unless you've set TEST_SHELL_PATH, that's what test_pause will use. > My local .bashrc has > > . /home/philip/git-completion.bash > . ~/git-prompt.sh > export GIT_PS1_SHOWDIRTYSTATE=1 > export PS1='\w$(__git_ps1 " (%s)")\$ ' It's unusual to export PS1. Only the shell needs it. But by exporting it, the child "dash" will see it, but of course doesn't have the __git_ps1() function defined. And thus the complaint. If you stop exporting it, then you'd see dash's regular prompt. Which fixes the "whoops, __git_ps1() is not defined" problem, but probably is not quite what you want, if you really wanted a nice prompt. > Not sure why I have a relative and an absolute path but... , so I'll try > updating the git-prompt.sh to an absolute path, and if that works, maybe > think about adding an extra comment to the `test-lib-functions.sh` to note > the change of HOME and potential '__git_ps1' problem It looks like test_pause() has various options for retaining shell, term, home, etc, and includes documentation. I haven't played with them myself, though. Usually I just use "-i" to stop the test, and then investigate the result in one of my regular shells (and in the rare case of "oops, it succeeds when I expect it to fail, I insert "false &&" as appropriate). -Peff ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: test_pause giving '__git_ps1: not found' warning 2023-01-16 17:38 ` Jeff King @ 2023-01-18 13:50 ` Philip Oakley 0 siblings, 0 replies; 4+ messages in thread From: Philip Oakley @ 2023-01-18 13:50 UTC (permalink / raw) To: Jeff King; +Cc: Git List, Philippe Blain, Elijah Newren On 16/01/2023 17:38, Jeff King wrote: > On Sat, Jan 14, 2023 at 05:49:15PM +0000, Philip Oakley wrote: > >> On 14/01/2023 14:54, Philip Oakley wrote: >>> I was trying to refine a test_expect_failure test [1] and tried >>> inserting a `test_pause &&` test line [2]. >>> >>> I then found, when it paused, I was repeatedly given the warning line >>> /bin/sh: 1: __git_ps1: not found >>> in the terminal until I expected the test shell. >>> >>> my PS1 is working normally in the terminal, but not here. Is this >>> expected, or do I need to set up anything else? >>> >>> Normally I'm on Git for Windows, but this was on my old laptop (Acer >>> 7741 i5 4GB ram..) converted to Ubuntu 20.04, which I use when away. > On Ubuntu, your /bin/sh is likely to be dash. And unless you've set > TEST_SHELL_PATH, that's what test_pause will use. Thanks. Some of these little tidbits passed me by. I wasactually trying to understand why $(printf "\145\314\201") wasn't working as expected (or the hex equivalent) depending on which machine (Ubuntu / Windows) I was on (when running in a test as part of t/t4205-log-pretty-formats.sh). I.e. sometimes the results looked like the unicode was being recognised, and others as if part were just ascii characters, ignoring the octal/hex escaping) > >> My local .bashrc has >> >> . /home/philip/git-completion.bash >> . ~/git-prompt.sh >> export GIT_PS1_SHOWDIRTYSTATE=1 >> export PS1='\w$(__git_ps1 " (%s)")\$ ' > It's unusual to export PS1. Only the shell needs it. It's the default setting described in the git-scm book's Appendix A "Git in Bash" [1]. Not sure if extra clarification is needed, or where that advice originated from. It (export'ing) is not currently part of contrib's git-prompt.sh comments [2]. > But by exporting > it, the child "dash" will see it, but of course doesn't have the > __git_ps1() function defined. And thus the complaint. > > If you stop exporting it, then you'd see dash's regular prompt. Which > fixes the "whoops, __git_ps1() is not defined" problem, but probably is > not quite what you want, if you really wanted a nice prompt. > >> Not sure why I have a relative and an absolute path but... , so I'll try >> updating the git-prompt.sh to an absolute path, and if that works, maybe >> think about adding an extra comment to the `test-lib-functions.sh` to note >> the change of HOME and potential '__git_ps1' problem > It looks like test_pause() has various options for retaining shell, > term, home, etc, and includes documentation. I haven't played with them > myself, though. > Usually I just use "-i" to stop the test, and then > investigate the result in one of my regular shells (and in the rare case > of "oops, it succeeds when I expect it to fail, > I insert "false &&" as > appropriate). That's a neat alternative. > > -Peff -- Philip [1] https://git-scm.com/book/uz/v2/Appendix-A%3A-Git-in-Other-Environments-Git-in-Bash [2] https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-18 14:10 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-01-14 14:54 test_pause giving '__git_ps1: not found' warning Philip Oakley 2023-01-14 17:49 ` Philip Oakley 2023-01-16 17:38 ` Jeff King 2023-01-18 13:50 ` Philip Oakley
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).