git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCHv2 1/2] git p4: Fixing script editor checks

From
Luke Diamand <luke@diamand.org>
Date
Apr 11, 2012, 19:24 UTC
Message-ID
<CAE5ih7-49ynPFrHDn_a0fiskSjfovS4qX2eHh9W3G08HaHHRkw@mail.gmail.com>
In-Reply-To
<7vpqbejdf4.fsf@alter.siamese.dyndns.org>
On Wed, Apr 11, 2012 at 9:06 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 39 quoted lines
> Luke Diamand <luke@diamand.org> writes:
>
>> On Wed, Apr 11, 2012 at 7:14 PM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Luke Diamand <luke@diamand.org> writes:
>>>
>>>> If P4EDITOR is defined, the tests will fail when "git p4" starts an
>>>> editor.
>>>
>>> Is that a problem specific to tests, or should "git p4" itself unset that
>>> environment? If it is a problem specific to tests, would it be a better
>>> fix to add "P4EDITOR=:" like we do for EDITOR in t/test-lib.sh?
>>
>> Yes and no - git-p4.py will run $P4EDITOR if it is set, even if it's
>> just empty. So it would need a small fix to check for an empty string.
>> I can submit a suitable patch.
>
> How does real "p4" run $P4EDITOR?  For example, if you have:
>
>        P4EDITOR='vi -e'
>
> does it start "vi" in its "ex" mode, implying that it behaves as if the
> invocation were like this in a hypothetical implementation of "p4" as a
> shell script:
>
>        #!/bin/sh
>        ... do some stuff p4 does ...
>        $P4EDITOR file-to-be-edited
>
> Whatever it does needs to be emulated by the code in git-p4.py that runs
> it, as that is the way the end users expect, and if it turns out to be
> like the above, setting P4EDITOR to ':' just like we do to EDITOR in
> t/test-lib.sh should be the right thing to do.  The always-true command
> colon will leave the file-to-be-edited unmodified and report success.
>
> Similarly, what happens with "p4" when $P4EDITOR is set to an empty
> string?  If it ignores and falls back to the other usual way to find your
> preferred editor, you should emulate that as well in git-p4.py.
>
> Thanks.

"vi -e" => vi in ex mode ":" => always-true-command "" => falls back to $EDITOR, and then to vi(UNIX or Win32 if $SHELL is set) or notepad(Win32).

Previous: Junio C HamanoNext: Luke Diamand
Message 6 of 9 in “[PATCHv2 0/2] git p4 - import/export of git/p4 tags and labels”
  1. Luke DiamandApr 11, 2012
  2. 1/2 git p4: Fixing script editor checksLuke Diamand, Apr 11, 2012
  3. Junio C HamanoApr 11, 2012
  4. Luke DiamandApr 11, 2012
  5. Junio C HamanoApr 11, 2012
  6. Luke DiamandApr 11, 2012
  7. 2/2 git p4: import/export of labels to/from p4Luke Diamand, Apr 11, 2012
  8. Pete WyckoffApr 18, 2012
  9. Luke DiamandApr 21, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.