All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alexandr Miloslavskiy via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>,
	Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
Subject: [PATCH] prepare_shell_cmd: add code comment
Date: Fri, 06 Mar 2020 12:41:48 +0000	[thread overview]
Message-ID: <pull.574.git.1583498508362.gitgitgadget@gmail.com> (raw)

From: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>

While debugging something else, I was quite puzzled to see that
`prepare_shell_cmd()` duplicates the command before sending to sh, like:
    sh -c "git-upload-pack '../testrepo/.git'" "git-upload-pack '../testrepo/.git'"

A Windows programmer myself, initially I thought that it's a bug.

Add a clarifying comment.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
---
    prepare_shell_cmd: add code comment
    
    While debugging something else, I was quite puzzled to see that
    prepare_shell_cmd() duplicates the command before sending to sh, like:
    sh -c "git-upload-pack '../testrepo/.git'" "git-upload-pack
    '../testrepo/.git'"
    
    A Windows programmer myself, initially I thought that it's a bug.
    
    Add a clarifying comment.
    
    Signed-off-by: Alexandr Miloslavskiy alexandr.miloslavskiy@syntevo.com
    [alexandr.miloslavskiy@syntevo.com]

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-574%2FSyntevoAlex%2F%230259(git)_doubled_prepare_shell_cmd-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-574/SyntevoAlex/#0259(git)_doubled_prepare_shell_cmd-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/574

 run-command.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/run-command.c b/run-command.c
index f5e1149f9b3..95ab3c168bc 100644
--- a/run-command.c
+++ b/run-command.c
@@ -284,6 +284,12 @@ static const char **prepare_shell_cmd(struct argv_array *out, const char **argv)
 			argv_array_push(out, argv[0]);
 		else
 			argv_array_pushf(out, "%s \"$@\"", argv[0]);
+
+		/*
+		 * -c expects shell_name after command_string.
+		 * Pushing entire original argv below will pass argv[0]
+		 * as shell name.
+		 */
 	}
 
 	argv_array_pushv(out, argv);

base-commit: 076cbdcd739aeb33c1be87b73aebae5e43d7bcc5
-- 
gitgitgadget

             reply	other threads:[~2020-03-06 12:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-06 12:41 Alexandr Miloslavskiy via GitGitGadget [this message]
2020-03-26 14:38 ` [PATCH] prepare_shell_cmd: add code comment Alexandr Miloslavskiy

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=pull.574.git.1583498508362.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=alexandr.miloslavskiy@syntevo.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.