Re: Definition of "the Git repository"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kevin Buckley wrote:
> On 2021/06/28 11:24, Felipe Contreras wrote:
> > Kevin Buckley wrote:
> > 
> >> Everything within the .git directory "belongs", in my way of thinking,
> >> to the "repository", that is, the directory that gets created when git
> >> is (init)ialised.
> >> 
> >> For me, the 'objects", the 'ref/heads', the "staging area' and the like,
> >> also lie within the repository.
> > 
> > Does it?
> > 
> > Suppose you have three directories, each with exactly the same contents
> > in their corresponding .git directory, the only difference is the
> > .git/index file:
> > 
> >   a) No .git/index file at all
> >   b) The .git/index file doesn't have anything staged
> >   c) The .git/index file contains some staged changes
> > 
> > Do you really consider them three different repositories?
> > 
> > In my mind the staging area is where you put stuff in preparation for
> > the commit. The commit is part of the repository, the staging area
> > isn't.
> > 
> 
> I think I do consider them as different, yes, but in the sense that,
> because the contents of any working directory can change in isolation
> to the others, they have become different instances (perhaps clones?)
> of the same repository.
> 
> Let's say I make two commits, that resulted in the same state of the
> files in the working directory, but I make them in different order
> in two of the working directories.
> 
> Clearly I need to sync the two different repositories in order to gain
> a consistency across them, and that suggets, to me, that they should
> be thought of as different.

Yes, but this has nothing to do with .git/index. You are talking about
branches and commits. Clearly these are parts of a repository, and
nobody objects to that.

> As to the staging area,
> 
> again, for me, Git has an understanding of a "staging area" based on its
> inspection of the state of the working directory and a comparison of that
> state with what it knows has been committed.

Wouldn't it be much easier to say that git is comparing the working
directory with HEAD?

Clearly HEAD is part of the repository, and so is the commit that it's
pointing to (indirectly or directly).

But that doesn't say anything about the staging area, which is between
the two (in my mind): the working directory and the repository.


To try to make it more orthogonal, let's suppose the index file was
outside the .git directory. Would you consider then the staging area
separate from the repository?

In fact, we don't have to suppose:

  GIT_INDEX_FILE=/tmp/index git checkout @~ -- .

Does that command change the repository in any way?

-- 
Felipe Contreras



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux