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

Re: [PATCH] git-p4: Fix empty submit template when editor fires up

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 10, 2010, 11:11 UTC
Message-ID
<20100110111153.GA19612@progeny.tock>
In-Reply-To
<1262235876-1239-1-git-send-email-kevinlsk@gmail.com>
Kevin Leung wrote:
> read_pipe() returns "\n". We need to remove it before passing it
> to system().
> 
> Signed-off-by: Kevin Leung <kevinlsk@gmail.com>

If I understand correctly, this is a cosmetic change: os.system() calls system(3), which uses 'sh -c', which has no problem coping with an extra newline at the end. So 'need' seems too strong a word. Still, the change sounds sensible.

Show 20 quoted lines
> ---
>  contrib/fast-import/git-p4 |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 0cef242..04bf4f4 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -732,8 +732,8 @@ class P4Submit(Command):
>              if os.environ.has_key("P4EDITOR"):
>                  editor = os.environ.get("P4EDITOR")
>              else:
> -                editor = read_pipe("git var GIT_EDITOR")
> -            system(editor + " " + fileName)
> +                editor = read_pipe("git var GIT_EDITOR").strip()
> +            system("%s %s" % (editor, fileName))
>  
>              response = "y"
>              if os.stat(fileName).st_mtime <= mtime:
> -- 

What is the rationale for the rewritten system() line? I would have understood a change to

	os.spawnlp("sh", "-c", editor + " \"$@\"", fileName)

for better behavior when TMPDIR contains shell metacharacters, but even this has nothing to do with read_pipe() returning a trailing newline.

Just my two cents, Jonathan

Next: Jonathan Nieder
Message 1 of 3 in “Re: [PATCH] git-p4: Fix empty submit template when editor fires up”
  1. Jonathan NiederJan 10, 2010
  2. Jonathan NiederJan 10, 2010
  3. Kevin LeungJan 10, 2010

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.