Skip to contentSkip to conversation

git-p4: Fix empty submit template when editor fires up

PATCH Jonathan Nieder 2 participants 3 messages Jun 15, 2016 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 4 lines · Kevin Leung

read_pipe() returns "\n". We need to remove it before passing it to system().

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.

Quoted 10 lines
---
 contrib/fast-import/git-p4 |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
contrib/fast-import/git-p4 +0 -0
index 0cef242..04bf4f4 100755

contrib/fast-import/git-p4 class P4Submit(Command): · line 739

Quoted 10 lines
contrib/fast-import/git-p4 +2 -2
@@ -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

author Acked-by
#2 lore raw
Quoted 7 lines · Jonathan Nieder
Quoted 4 lines · Kevin Leung

read_pipe() returns "\n". We need to remove it before passing it to system().

If I understand correctly, this is a cosmetic change:

... and of course I didn't the subject. Sorry about that. Thanks for cleaning up my mess.

Quoted 4 lines

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

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

I am still curious about this, though it is not so important.

Jonathan

#3 lore raw
Quoted 12 lines · Jonathan Nieder
Quoted 7 lines · Jonathan Nieder
Quoted 4 lines · Kevin Leung

read_pipe() returns "\n". We need to remove it before passing it to system().

If I understand correctly, this is a cosmetic change:

... and of course I didn't the subject.  Sorry about that.  Thanks for cleaning up my mess.

Quoted 8 lines
Quoted 4 lines

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

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

I am still curious about this, though it is not so important.

You are right, the system() line is not so important. I can revert that line of change.

Kevin