git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: kusmabite@gmail.com
Cc: Dave Bradley <dbradley2@bell.net>,
	GIT Mailing-list <git@vger.kernel.org>
Subject: Re: #178 parsing of pretty=format:"%an %ad" causes fatal: bad revision '%ad'
Date: Fri, 02 May 2014 10:18:26 -0700	[thread overview]
Message-ID: <xmqqsiosayl9.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CABPQNSa6PaTZ3coX2eU-r7BFH3JR2V6XHv4HbXxsYyxv0qA71Q@mail.gmail.com> (Erik Faye-Lund's message of "Fri, 2 May 2014 14:12:59 +0200")

Erik Faye-Lund <kusmabite@gmail.com> writes:

> On Fri, May 2, 2014 at 1:50 PM, Dave Bradley <dbradley2@bell.net> wrote:
>> Hi,
>>
>> I’m very new to ‘git’ github. I reported the #178 issue in github and the
>> issue has been closed, I believe this means no further discussion.
>
> When you say "the #178 issue in github", you really mean "issue #178
> for Git for Windows on GitHub", available at
> https://github.com/msysgit/git/issues/178 for those interested.
>
> That issue tracker is for the Windows port of Git for Windows. It's
> intended to track breakages in Git for Windows compared to Git on, say
> Linux. It's not a general issue tracker for problems with Git. Still,
> it seems a lot of people think "I downloaded Git for Windows, and
> here's something that didn't work the way I expected it to, I'll file
> a bug". Those kinds of bug-reports usually gets closed quickly, as
> it's outside the scope of Git for Windows to decide how Git should
> behave - we try to make it behave consistently between Windows and
> Unixy-platforms.
>
> This is indeed the right forum to address your issue. So thank you for
> moving the discussion here.

Hmmmmmm, everything you said in the earlier paragraphs is correct,
but I am having a feeling that this is either an issue specific to
the Windows port, or more likely a user error, depending on who is
giving the extra dq quoting.  From the command line:

    $ git show --pretty='format:"%an %ad"'
    "Junio C Hamano Wed Apr 30 11:01:42 2014 -0700"

Because the 'format:' specifier requests to put dq around these two,
we respond by putting dq around these two, just as we were asked to
do.  The way to ask %an followed by SP followed by %ad and nothing
else is

    $ git show --pretty='format:%an %ad'
    Junio C Hamano Wed Apr 30 11:01:42 2014 -0700

Especially this part from the original tells me that this is a user
error and there is nothing wrong in either the generic Git or in the
Windows port.

    G:\w....x>git log --all "--pretty=format:"%an %ad"" -- pom.xml
    fatal: bad revision '%ad'

Separating the tokens on that command line, we would get:

    git
    log
    --all
    --pretty=format:%an
    %ad
    --
    pom.xml

So it told git to run the log subcommand with arguments that tells
it to "include all tips of refs to the starting set", "show them
using a custom format %an", "include %ad to the starting set",
"everything that follows are not revs but pathspecs", and then
finally "pom.xml is the pathspec to limit to paths the user is
interested in".  "%ad is not a rev" is perfectly valid.


You cannot take --pretty=format:"%ad %an" that you see in tutorials
and random web pages too literally.  The double quotes you see in
that example is our way to tell that "--pretty=format:%ad %an" (what
is inside these dq) is expected to be fed to Git as a single
argument.

The examples you see typically follow the convention to show what
you _would_ give to shell to achieve that, and shell's command line
parser needs these dq to make sure that the SP between %an and %ad
is not taken as an argument separator.

Your custom front-end may take a different approach to let you
specify what individual arguments are on your command line, and you
would have to follow its convention.  The user needs to be careful
about how shell quoting works on his/her command line, and that is
all, I would think.

Visiting an earlier part of the original issue report:

    Getting a fatal failure when using the following
    --pretty=format:"%an %ad" via a programmed execution from within
    a programming language. (Java using the execution capabilities
    puts the ' --pretty=format:"%an %ad" ' as an argument).

I take that "Java using ..." to mean that the user wants to see his
machinery eventually do an equivalent to:

	execl('git', 'git', 'log', '--pretty=format:%an %ad', ...);

but it somehow is getting

	execl('git', 'git', 'log', '--pretty=format:%an', '%ad', ...);

due to reason unknown to us that is not in the report.

Without knowing what the end-user input to the front-end that calls
into that "Java" machinery is and what the argument separating
convention that is employed by the front-end is, I cannot tell where
the single argument is split into two.  The problem may either be in
that front-end program and not in the end-user input.  Or the
problem may be in Windows port letting the Windows library split
command line at a funny point.  In any case, it does not sound like
it is a problem in Git.  If the command fed to the equivalent to
execl() above were not 'git' but any program, it will suffer from
the same issue.

  reply	other threads:[~2014-05-02 17:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-02 11:50 #178 parsing of pretty=format:"%an %ad" causes fatal: bad revision '%ad' Dave Bradley
2014-05-02 12:12 ` Erik Faye-Lund
2014-05-02 17:18   ` Junio C Hamano [this message]
2014-05-02 17:22 ` Jonathan Nieder
2014-05-02 17:23 ` Jonathan Nieder
2014-05-02 18:23   ` Erik Faye-Lund
2014-05-04 10:14     ` [msysGit] " Dave Bradley
2014-05-05 23:02       ` Junio C Hamano

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=xmqqsiosayl9.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=dbradley2@bell.net \
    --cc=git@vger.kernel.org \
    --cc=kusmabite@gmail.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.
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 NNTP newsgroup(s).