public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@grenoble-inp•fr>
To: Sidhant Sharma <tigerkid001@gmail•com>
Cc: Lars Schneider <larsxschneider@gmail•com>,
	Git Mailing List <git@vger•kernel.org>,
	Junio C Hamano <gitster@pobox•com>,
	philipoakley@iee•org, Kevin Daudt <me@ikke•info>,
	Jacob Keller <jacob.keller@gmail•com>,
	Elijah Newren <newren@gmail•com>
Subject: Re: [GSOC/RFC] GSoC Proposal Draft | Git Beginner
Date: Mon, 21 Mar 2016 09:29:01 +0100	[thread overview]
Message-ID: <vpqd1qo5j5e.fsf@anie.imag.fr> (raw)
In-Reply-To: <56EFA558.5020301@gmail.com> (Sidhant Sharma's message of "Mon, 21 Mar 2016 13:10:08 +0530")

Sidhant Sharma <tigerkid001@gmail•com> writes:

> On Monday 21 March 2016 12:22 AM, Matthieu Moy wrote:
>
>> Note that it implies writting an almost full-blown option parser to
>> recognize commands like
>>
>> ggit --work-tree git --namespace reset --git-dir --hard git log
>>
>> (just looking for "git", "reset" and "--hard" in the command-line would
>> not work here).
>
> Could you please elaborate on the above command, I'm unable to
> understand its syntax. I thought all git commands follow the
> `git command <arguments>` syntax, so using simple string
> manipulations and regexes would work. Am I missing something?

The full syntax is

git [global options] <command> [options and arguments for a command]

For example:

git -p log => -p is the option for "git" itself, which means "paginate"
git log -p => -p is the option for "git log", which means "patch"

Options can have stuck or non-stuck form, for example

git --work-tree=foo <=> git --work-tree foo

git --work-tree git --namespace reset --git-dir --hard git log
<=>
git --work-tree=git --namespace=reset --git-dir=--hard git log

(This is probably a stupid command to type, but it's legal)

The later is source of issues for a parser since you can't just iterate
through argv[] and search for problematic commands/options, since you
have to distinguish options themselves (--work-tree above) and option
arguments (foo above).

In my example above, I played with global options (before "git" in the
command-line), but I could also have done that with per-command options
taking arguments, like

git push --repo --force

Here, --force is the name of the repo (again, probably a stupid name,
but why not), not the --force option.

> I wasn't sure if we are allowed to code before the actual coding period begins
> so I kept it that way. I'll update it now.

You're not "forced" to, but you can write code whenever you like. We've
already seen code written before the application!

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

  reply	other threads:[~2016-03-21  8:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-20 16:34 [GSOC/RFC] GSoC Proposal Draft | Git Beginner Sidhant Sharma
2016-03-20 18:52 ` Matthieu Moy
2016-03-21  7:40   ` Sidhant Sharma
2016-03-21  8:29     ` Matthieu Moy [this message]
2016-03-21 10:10       ` Sidhant Sharma
2016-03-21 10:19   ` Sidhant Sharma
2016-03-22  8:38     ` Lars Schneider
2016-03-22  9:05       ` Sidhant Sharma
2016-03-22  9:43       ` Sidhant Sharma

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=vpqd1qo5j5e.fsf@anie.imag.fr \
    --to=matthieu.moy@grenoble-inp$(echo .)fr \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=jacob.keller@gmail$(echo .)com \
    --cc=larsxschneider@gmail$(echo .)com \
    --cc=me@ikke$(echo .)info \
    --cc=newren@gmail$(echo .)com \
    --cc=philipoakley@iee$(echo .)org \
    --cc=tigerkid001@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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