git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Definition of "the Git repository"

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 28, 2021, 05:21 UTC
Message-ID
<60d95c6024f3d_aaf7e208a4@natae.notmuch>
In-Reply-To
<ec31434f-0c99-ffb7-6eb0-6ecb1f6e761c@pawsey.org.au>
Kevin Buckley wrote:
Show 39 quoted lines
> 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.

Show 5 quoted lines
> 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
Previous: Kevin BuckleyNext: Kevin Buckley
Message 10 of 15 in “Definition of "the Git repository"”
  1. Kevin BuckleyJun 25, 2021
  2. Ævar Arnfjörð BjarmasonJun 25, 2021
  3. Igor DjordjevicJun 25, 2021
  4. Igor DjordjevicJun 25, 2021
  5. Felipe ContrerasJun 25, 2021
  6. Philip OakleyJun 25, 2021
  7. Kevin BuckleyJun 28, 2021
  8. Felipe ContrerasJun 28, 2021
  9. Kevin BuckleyJun 28, 2021
  10. Felipe ContrerasJun 28, 2021
  11. Kevin BuckleyJun 29, 2021
  12. Felipe ContrerasJun 29, 2021
  13. Philip OakleyJun 28, 2021
  14. Chris TorekJun 28, 2021
  15. Junio C HamanoJun 29, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.