threads / discuss / 57149

Git internal command line parser

Subject: Git internal command line parser

## tl;dr

11 messages between Dec 24, 2021 and Dec 29, 2021.

replies: 10people: 3as markdown or json

Lemuria· Dec 24, 2021, 14:38 UTC · lore
#=< TLDR: Where's the code for git's internal command line parser? >===#

I'm interested in the internals of git, more specifically it's command line parser.

Does Git use a library like getopt for it's command line handling, or does it use a custom parser?

If possible, I would appreciate being redirected to the source code files that handle this.

Sincerely, Lemuria

Philip Oakley· Dec 24, 2021, 18:13 UTC · re: Lemuria · lore

Re: Git internal command line parser

On 24/12/2021 14:38, Lemuria wrote:
> #=< TLDR: Where's the code for git's internal command line parser? >===#
>
> I'm interested in the internals of git, more specifically it's command
> line parser.
One place to start is https://github.com/git/git/blob/master/git.c
Show 9 quoted lines
>
> Does Git use a library like getopt for it's command line handling, or
> does it use a custom parser?
>
> If possible, I would appreciate being redirected to the source code
> files that handle this.
>
> Sincerely,
> Lemuria
Philip
Lemuria· Dec 24, 2021, 18:30 UTC · re: Philip Oakley · lore

Re: Git internal command line parser

On 25/12/2021 2:13 am, Philip Oakley wrote:
Show 8 quoted lines
> On 24/12/2021 14:38, Lemuria wrote:
>> #=< TLDR: Where's the code for git's internal command line parser? >===#
>>
>> I'm interested in the internals of git, more specifically it's command
>> line parser.
> 
> One place to start is https://github.com/git/git/blob/master/git.c
>

Wait, is all of Git just one big executable or are there many executables and `git` is just the front-end for accessing the separate git executables, such as say, the one for processing commits?

Show 12 quoted lines
>>
>> Does Git use a library like getopt for it's command line handling, or
>> does it use a custom parser?
>>
>> If possible, I would appreciate being redirected to the source code
>> files that handle this.
>>
>> Sincerely,
>> Lemuria
> 
> Philip
> 
Philip Oakley· Dec 24, 2021, 18:36 UTC · re: Lemuria · lore

Re: Git internal command line parser

On 24/12/2021 18:30, Lemuria wrote:
Show 18 quoted lines
>
>
> On 25/12/2021 2:13 am, Philip Oakley wrote:
>> On 24/12/2021 14:38, Lemuria wrote:
>>> #=< TLDR: Where's the code for git's internal command line parser?
>>> >===#
>>>
>>> I'm interested in the internals of git, more specifically it's command
>>> line parser.
>>
>> One place to start is https://github.com/git/git/blob/master/git.c
>>
>
> Wait, is all of Git just one big executable or are there many
> executables and `git` is just the front-end for accessing the
> separate git executables, such as say, the one for processing
> commits?
>
Yes, `git` is a front end.

If you are on Windows, it gets even more interesting because all the individual sub-commands are just hard links back to the single git.exe that then links to those sub-command's code.

Show 12 quoted lines
>>>
>>> Does Git use a library like getopt for it's command line handling, or
>>> does it use a custom parser?
>>>
>>> If possible, I would appreciate being redirected to the source code
>>> files that handle this.
>>>
>>> Sincerely,
>>> Lemuria
>>
>> Philip
>>
Lemuria· Dec 24, 2021, 19:05 UTC · re: Philip Oakley · lore

Re: Git internal command line parser

On 25/12/2021 2:36 am, Philip Oakley wrote:
Show 26 quoted lines
> On 24/12/2021 18:30, Lemuria wrote:
>>
>>
>> On 25/12/2021 2:13 am, Philip Oakley wrote:
>>> On 24/12/2021 14:38, Lemuria wrote:
>>>> #=< TLDR: Where's the code for git's internal command line parser?
>>>>> ===#
>>>>
>>>> I'm interested in the internals of git, more specifically it's command
>>>> line parser.
>>>
>>> One place to start is https://github.com/git/git/blob/master/git.c
>>>
>>
>> Wait, is all of Git just one big executable or are there many
>> executables and `git` is just the front-end for accessing the
>> separate git executables, such as say, the one for processing
>> commits?
>>
> 
> Yes, `git` is a front end.
> 
> If you are on Windows, it gets even more interesting because all the
> individual sub-commands are just hard links back to the single git.exe
> that then links to those sub-command's code.
>
I'm on Ubuntu 20.04, just in case you ever want to know.

And I likely will consider this "front-end to many separate executable apps" approach for my future large projects.

Thanks for your help! I've also cloned the git repository of git, and I'll take a look through the source code.

I'm also a beginner to C, not quite an expert at it.
Show 13 quoted lines
>>>>
>>>> Does Git use a library like getopt for it's command line handling, or
>>>> does it use a custom parser?
>>>>
>>>> If possible, I would appreciate being redirected to the source code
>>>> files that handle this.
>>>>
>>>> Sincerely,
>>>> Lemuria
>>>
>>> Philip
>>>
> 
João Victor Bonfim· Dec 25, 2021, 02:55 UTC · re: Philip Oakley · lore

Re: Git internal command line parser

> If you are on Windows, it gets even more interesting because all the
> individual sub-commands are just hard links back to the single git.exe
> that then links to those sub-command's code.

That seems undesirable... I know operating otherwise would be even more complicated and might create undue complexity or diminish performance, but I guess that, if it works, don't mess with it.

> And I likely will consider this "front-end to many separate
executable apps" approach for my future large projects.
Lemuria, please consider those points as, sometimes, what is great at performance might not help with scalability and other matters, therefore, as the designer/engineer of a software system, a choice must be made and an evaluation of the properties of each possibility is a necessity.
Do with that what you will.
> I'm also a beginner to C, not quite an expert at it.
Practice programming a lot and never forget two things: [1] you are working with a man made machine, therefore its limitations and capabilities are by design, so you must consider them every step of the way when developing (like how computers send information, how computers process informations, how machine behaviour can be altered, abused or exploited through alteration of the environment or mechanism and through the use of sleight of hand). [2] Your code always has real life consequences and it is your moral responsibility to consider them and make sure that prejudice isn't codified into them.
Those are my two tid bits about being a responsible and effective programmer.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
Em sexta-feira, 24 de dezembro de 2021 às 15:36, Philip Oakley <philipoakley@iee.email> escreveu:
Show 45 quoted lines
> On 24/12/2021 18:30, Lemuria wrote:
>
> > On 25/12/2021 2:13 am, Philip Oakley wrote:
> >
> > > On 24/12/2021 14:38, Lemuria wrote:
> > >
> > > > #=< TLDR: Where's the code for git's internal command line parser?
> > > >
> > > > > ===#
> > > >
> > > > I'm interested in the internals of git, more specifically it's command
> > > >
> > > > line parser.
> > >
> > > One place to start is https://github.com/git/git/blob/master/git.c
> >
> > Wait, is all of Git just one big executable or are there many
> >
> > executables and `git` is just the front-end for accessing the
> >
> > separate git executables, such as say, the one for processing
> >
> > commits?
>
> Yes, `git` is a front end.
>
> If you are on Windows, it gets even more interesting because all the
>
> individual sub-commands are just hard links back to the single git.exe
>
> that then links to those sub-command's code.
>
> > > > Does Git use a library like getopt for it's command line handling, or
> > > >
> > > > does it use a custom parser?
> > > >
> > > > If possible, I would appreciate being redirected to the source code
> > > >
> > > > files that handle this.
> > > >
> > > > Sincerely,
> > > >
> > > > Lemuria
> > >
> > > Philip
Lemuria· Dec 25, 2021, 08:32 UTC · re: João Victor Bonfim · lore

Re: Git internal command line parser

On 25/12/2021 10:55 am, João Victor Bonfim wrote:
Show 7 quoted lines
>> If you are on Windows, it gets even more interesting because all the
>> individual sub-commands are just hard links back to the single git.exe
>> that then links to those sub-command's code.
> 
> That seems undesirable...
> I know operating otherwise would be even more complicated and might create undue complexity or diminish performance, but I guess that, if it works, don't mess with it.
> 
Was this directed towards Lemuria (me)?
Show 10 quoted lines
>> And I likely will consider this "front-end to many separate
> executable apps" approach for my future large projects.
> 
> Lemuria, please consider those points as, sometimes, what is great at performance might not help with scalability and other matters, therefore, as the designer/engineer of a software system, a choice must be made and an evaluation of the properties of each possibility is a necessity.
> 
> Do with that what you will.
> 
>> I'm also a beginner to C, not quite an expert at it.
> 
> Practice programming a lot and never forget two things: [1] you are working with a man made machine, therefore its limitations and capabilities are by design, so you must consider them every step of the way when developing (like how computers send information, how computers process informations, how machine behaviour can be altered, abused or exploited through alteration of the environment or mechanism and through the use of sleight of hand). [2] Your code always has real life consequences and it is your moral responsibility to consider them and make sure that prejudice isn't codified into them.

Okay, I understand. I'll do everything to keep my code bias-free. I'm working on a project in C and if it's okay, I'll link you to the GitHub repository.

I'm sure the git mailing list isn't the right place for me to get criticism on that project however.

Show 51 quoted lines
> Those are my two tid bits about being a responsible and effective programmer.
> 
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> 
> Em sexta-feira, 24 de dezembro de 2021 às 15:36, Philip Oakley <philipoakley@iee.email> escreveu:
> 
>> On 24/12/2021 18:30, Lemuria wrote:
>>
>>> On 25/12/2021 2:13 am, Philip Oakley wrote:
>>>
>>>> On 24/12/2021 14:38, Lemuria wrote:
>>>>
>>>>> #=< TLDR: Where's the code for git's internal command line parser?
>>>>>
>>>>>> ===#
>>>>>
>>>>> I'm interested in the internals of git, more specifically it's command
>>>>>
>>>>> line parser.
>>>>
>>>> One place to start is https://github.com/git/git/blob/master/git.c
>>>
>>> Wait, is all of Git just one big executable or are there many
>>>
>>> executables and `git` is just the front-end for accessing the
>>>
>>> separate git executables, such as say, the one for processing
>>>
>>> commits?
>>
>> Yes, `git` is a front end.
>>
>> If you are on Windows, it gets even more interesting because all the
>>
>> individual sub-commands are just hard links back to the single git.exe
>>
>> that then links to those sub-command's code.
>>
>>>>> Does Git use a library like getopt for it's command line handling, or
>>>>>
>>>>> does it use a custom parser?
>>>>>
>>>>> If possible, I would appreciate being redirected to the source code
>>>>>
>>>>> files that handle this.
>>>>>
>>>>> Sincerely,
>>>>>
>>>>> Lemuria
>>>>
>>>> Philip
João Victor Bonfim· Dec 26, 2021, 02:38 UTC · re: Lemuria · lore

Re: Git internal command line parser

Saturday, 25, December, 2021, at 05:32, Lemuria <nekadek457@gmail.com> wrote:
> Was this directed towards Lemuria (me)?
 Oh god no, those were more general comments about the way things are done on Git, rather than directed towards you. See it as me reacting to the information received and trying to pull a conversation about it with Philip.
Show 6 quoted lines
> Okay, I understand. I'll do everything to keep my code bias-free.
> I'm working on a project in C and if it's okay, I'll link you to
> the GitHub repository.
>
> I'm sure the git mailing list isn't the right place for me to get
> criticism on that project however.
 I will do my best to help you out. If you want to contact me, send an e-mail to my address (JoaoVictorBonfim@protonmail.com) and we can talk it out. From experience I learned that, when talking about prejudice, it is better to shut up, pay attention to the conversations in the room and see who is being denied their humanity, who has the power in the situation and who is trying to prop up an emotional response from others. Most of the time, those who are being denied their humanity, those who are restrained in their response, those who have no power or say in the conversation and those who are more emotional than trying to prop emotions are the marginalized in the conversation.
Now, out of curiosity, are you named Lemuria because of Lemurs? You know, the little primates from the Madagascar island?
Lemuria· Dec 26, 2021, 03:40 UTC · re: João Victor Bonfim · lore

Re: Git internal command line parser

On 26/12/2021 10:38 am, João Victor Bonfim wrote:
> Saturday, 25, December, 2021, at 05:32, Lemuria <nekadek457@gmail.com> wrote:
>> Was this directed towards Lemuria (me)?
> 
>   Oh god no, those were more general comments about the way things are done on Git, rather than directed towards you. See it as me reacting to the information received and trying to pull a conversation about it with Philip.
Alrighty then.
Show 9 quoted lines
> 
>> Okay, I understand. I'll do everything to keep my code bias-free.
>> I'm working on a project in C and if it's okay, I'll link you to
>> the GitHub repository.
>>
>> I'm sure the git mailing list isn't the right place for me to get
>> criticism on that project however.
> 
>   I will do my best to help you out. If you want to contact me, send an e-mail to my address (JoaoVictorBonfim@protonmail.com) and we can talk it out.

I think I can deal with it on my own. But if you're curious, it's right here:

https://github.com/a-random-lemurian/randstuff
Mostly random generators, like random ascii and hex.
> From experience I learned that, when talking about prejudice, it is better to shut up, pay attention to the conversations in the room and see who is being denied their humanity, who has the power in the situation and who is trying to prop up an emotional response from others. Most of the time, those who are being denied their humanity, those who are restrained in their response, those who have no power or say in the conversation and those who are more emotional than trying to prop emotions are the marginalized in the conversation.

Alrighty then. I'm also worried about prejudice in say, machine learning. We humans are biased, so who's to say the AI training data isn't biased?

In fact, I might be biased right now and I probably would not realized it.

> Now, out of curiosity, are you named Lemuria because of Lemurs? You know, the little primates from the Madagascar island?

Indirectly. I named myself after the lost continent. It was a decent name, which is why I use it as my psuedonym on most of the internet.

And the lost continent in turn was named after... lemurs.
Philip Oakley· Dec 27, 2021, 16:43 UTC · re: João Victor Bonfim · lore

Re: Git internal command line parser

Hi João  & Lemuria,
On 25/12/2021 02:55, João Victor Bonfim wrote:
Show 5 quoted lines
>> If you are on Windows, it gets even more interesting because all the
>> individual sub-commands are just hard links back to the single git.exe
>> that then links to those sub-command's code.
> That seems undesirable...
> I know operating otherwise would be even more complicated and might create undue complexity or diminish performance, but I guess that, if it works, don't mess with it.

The original question didn't say which OS was in use, and had hints that roughly matched a common Windows user misunderstanding about how the Git executables coped with the change of OS [1].

My description was a hint, rather than a detailed exposition about what was happening there. As you note, performance is important.

Show 43 quoted lines
>> And I likely will consider this "front-end to many separate
> executable apps" approach for my future large projects.
>
> Lemuria, please consider those points as, sometimes, what is great at performance might not help with scalability and other matters, therefore, as the designer/engineer of a software system, a choice must be made and an evaluation of the properties of each possibility is a necessity.
>
> Do with that what you will.
>
>> I'm also a beginner to C, not quite an expert at it.
> Practice programming a lot and never forget two things: [1] you are working with a man made machine, therefore its limitations and capabilities are by design, so you must consider them every step of the way when developing (like how computers send information, how computers process informations, how machine behaviour can be altered, abused or exploited through alteration of the environment or mechanism and through the use of sleight of hand). [2] Your code always has real life consequences and it is your moral responsibility to consider them and make sure that prejudice isn't codified into them.
>
> Those are my two tid bits about being a responsible and effective programmer.
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
>
> Em sexta-feira, 24 de dezembro de 2021 às 15:36, Philip Oakley <philipoakley@iee.email> escreveu:
>
>> On 24/12/2021 18:30, Lemuria wrote:
>>
>>> On 25/12/2021 2:13 am, Philip Oakley wrote:
>>>
>>>> On 24/12/2021 14:38, Lemuria wrote:
>>>>
>>>>> #=< TLDR: Where's the code for git's internal command line parser?
>>>>>
>>>>>> ===#
>>>>> I'm interested in the internals of git, more specifically it's command
>>>>>
>>>>> line parser.
>>>> One place to start is https://github.com/git/git/blob/master/git.c
>>> Wait, is all of Git just one big executable or are there many
>>>
>>> executables and `git` is just the front-end for accessing the
>>>
>>> separate git executables, such as say, the one for processing
>>>
>>> commits?
>> Yes, `git` is a front end.
>>
>> If you are on Windows, it gets even more interesting because all the
>>
>> individual sub-commands are just hard links back to the single git.exe
>>
>> that then links to those sub-command's code.

This (over simplified) explanation relates to the differences between the OS approaches to the performance issues when creating new processes and the like on Windows. Each OS has strengths and weaknesses.

Show 13 quoted lines
>>
>>>>> Does Git use a library like getopt for it's command line handling, or
>>>>>
>>>>> does it use a custom parser?
>>>>>
>>>>> If possible, I would appreciate being redirected to the source code
>>>>>
>>>>> files that handle this.
>>>>>
>>>>> Sincerely,
>>>>>
>>>>> Lemuria
>>>> Philip

[1] https://github.com/git-for-windows/build-extra/blob/main/ReleaseNotes.md?plain=1#L25

João Victor Bonfim· Dec 29, 2021, 23:16 UTC · re: Philip Oakley · lore

Re: Git internal command line parser

> This (over simplified) explanation relates to the differences between
> the OS approaches to the performance issues when creating new processes
> and the like on Windows. Each OS has strengths and weaknesses.

Oakley, to whom did you want to address this and what did you want to say? I don't get what you meant.

← back to recent threads