git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Mike Mueller via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Mike Mueller <mike.mueller@moodys.com>
Subject: Re: [PATCH 1/1] p4 unshelve: fix "Not a valid object name HEAD0"
Date: Wed, 15 May 2019 14:25:00 +0900	[thread overview]
Message-ID: <xmqqd0kk70ib.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <fc580e902bedb92b5caea8047c1ddd1c9fc822f6.1557502383.git.gitgitgadget@gmail.com> (Mike Mueller via GitGitGadget's message of "Fri, 10 May 2019 08:33:05 -0700 (PDT)")

"Mike Mueller via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Mike Mueller <mike.mueller@moodys.com>
>
> git p4 unshelve was failing with these errors on Windows:
>
> fatal: Not a valid object name HEAD0
> Command failed: git cat-file commit HEAD^0
>
> (git version 2.21.0.windows.1, python 2.7.16)
>
> The pOpen call used by git-p4 to invoke the git command can take either a
> string or an array as a first argument.  The array form is preferred
> however the extractLogMessageFromGitCommit method was using the string
> form, which makes the caller responsible for escaping the command text
> appropriately (see https://docs.python.org/2/library/subprocess.html)

Rewrite the sentence that begin with "The array form is
preferred...", as it is somewhat unreadable.  "X is preferred
because Y; however Z was using the other one" would be
understandable.

> Somewhat ironically, the carat character is the escape character in

s/carat/caret/ everywhere.

> Windows and so should be escaped (HEAD^^0).  Without the extra carat, the
> OS was passing an escaped 0 to the git command instead, and the git
> command was rejecting the invalid object name "HEAD0"
>
> The behaviour can be confirmed by typing ECHO HEAD^0 at the command-
> prompt, which emits HEAD0.
>
> The solution is simply to use the array format of passing the command to
> fOpen, which is preferred and used in other parts of this code anyway.
>
> Signed-off-by: Mike Mueller <mike.mueller@moodys.com>
> ---
>  git-p4.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-p4.py b/git-p4.py
> index 5b79920f46..0b5bfcbc5e 100755
> --- a/git-p4.py
> +++ b/git-p4.py
> @@ -737,7 +737,7 @@ def extractLogMessageFromGitCommit(commit):
>  
>      ## fixme: title is first line of commit, not 1st paragraph.
>      foundTitle = False
> -    for log in read_pipe_lines("git cat-file commit %s" % commit):
> +    for log in read_pipe_lines(["git", "cat-file", "commit", commit]):
>         if not foundTitle:
>             if len(log) == 1:
>                 foundTitle = True

  reply	other threads:[~2019-05-15  5:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-10 15:33 [PATCH 0/1] p4: fix "Not a valid object name HEAD0" when unshelving Mike Mueller via GitGitGadget
2019-05-10 15:33 ` [PATCH 1/1] p4 unshelve: fix "Not a valid object name HEAD0" Mike Mueller via GitGitGadget
2019-05-15  5:25   ` Junio C Hamano [this message]
2019-05-28 18:15 ` [PATCH v2 0/1] p4: fix "Not a valid object name HEAD0" when unshelving Mike Mueller via GitGitGadget
2019-05-28 18:15   ` [PATCH v2 1/1] p4 unshelve: fix "Not a valid object name HEAD0" on Windows Mike Mueller via GitGitGadget
2019-05-28 20:37     ` Junio C Hamano
2019-05-29 11:41       ` Johannes Schindelin

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqd0kk70ib.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=mike.mueller@moodys.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).