Re: [GSOC/RFC] GSoC Proposal Draft | Git Beginner
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Mar 21, 2016, 08:29 UTC
- Message-ID
- <vpqd1qo5j5e.fsf@anie.imag.fr>
- In-Reply-To
- <56EFA558.5020301@gmail.com>
Sidhant Sharma <tigerkid001@gmail.com> writes:
Show 14 quoted lines
> 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/