git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Philip Oakley <philipoakley@iee.email>
To: Git List <git@vger.kernel.org>,
	Philippe Blain <levraiphilippeblain@gmail.com>,
	Elijah Newren <newren@gmail.com>
Subject: Re: test_pause giving '__git_ps1: not found' warning
Date: Sat, 14 Jan 2023 17:49:15 +0000	[thread overview]
Message-ID: <8355f48b-dbf9-7cfe-c85c-0d6ca5926c8c@iee.email> (raw)
In-Reply-To: <bce6ac3a-17a6-beed-43ef-5a1e0dd92a5d@iee.email>

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


  reply	other threads:[~2023-01-14 17:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-14 14:54 test_pause giving '__git_ps1: not found' warning Philip Oakley
2023-01-14 17:49 ` Philip Oakley [this message]
2023-01-16 17:38   ` Jeff King
2023-01-18 13:50     ` Philip Oakley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8355f48b-dbf9-7cfe-c85c-0d6ca5926c8c@iee.email \
    --to=philipoakley@iee.email \
    --cc=git@vger.kernel.org \
    --cc=levraiphilippeblain@gmail.com \
    --cc=newren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).