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

Re: [RFC/PATCH] extend meaning of "--root" option to index comparisons

From
Jeff King <peff@peff.net>
Date
Sep 19, 2008, 17:39 UTC
Message-ID
<20080919173947.GA24541@sigill.intra.peff.net>
In-Reply-To
<3665a1a00809190954q2473e164u5d80d3653d238a27@mail.gmail.com>
On Fri, Sep 19, 2008 at 09:54:15AM -0700, Anatol Pomozov wrote:
> I dont see how does log.showroot or core.showroot affect 'git log'.
> man git-log says nothing, git-config only mentions that initial commit
> is "a big creation event".
Try this:
  mkdir repo && cd repo && git init
  echo content >file && git add file && git commit -m initial
  git show ;# you see initial as creation event
  git config log.showroot false
  git show ;# you see commit log, but no diff
  git show --root ;# same as log.showroot=true

where of course the same holds for log, as show uses the same display logic.

> But for me as for person that still actively works with Subversion it
> was quite surprising that I have error messages right after I created
> a fresh empty repo. I always thought that "Empty repo" -> "No history"
> -> "No log output"

I agree it is a bit nicer not to get an error in that situation. It is really a result of the way git thinks of history. It is not "no history" but rather "some history may or may not exist, but you have no valid pointer to any history".

However, I wonder if it might be possible to special-case the "branch yet to be born" case. That is, if HEAD points to a ref which does not exist, can we treat that specially. I suspect it may turn out to be a lot of work tracking down all of the spots in the code that would need to be special-cased, which may make it not worthwhile.

Show 6 quoted lines
> > Maybe it really is better to just force the caller to check the initial
> > commit condition. It's more work for them, but the semantics are simple
> > and unambiguous.
> 
> What is the best way to check that repo has valid HEAD? Check that
> file .git/HEAD exists?

No, HEAD will exist even in a just-created repo. But you can check whether HEAD points to a valid commit:

  git rev-parse --verify HEAD
-Peff
Previous: Anatol PomozovNext: Junio C Hamano
Message 15 of 22 in “Diff-tree does not work for initial commit”
  1. Anatol PomozovSep 15, 2008
  2. Michael J GruberSep 15, 2008
  3. Junio C HamanoSep 15, 2008
  4. Anatol PomozovSep 15, 2008
  5. Michael J GruberSep 15, 2008
  6. Sverre RabbelierSep 15, 2008
  7. Jeff KingSep 15, 2008
  8. Sverre RabbelierSep 16, 2008
  9. Jeff KingSep 16, 2008
  10. extend meaning of "--root" option to index comparisonsJeff King, Sep 18, 2008
  11. Anatol PomozovSep 18, 2008
  12. Sverre RabbelierSep 18, 2008
  13. Jeff KingSep 19, 2008
  14. Anatol PomozovSep 19, 2008
  15. Jeff KingSep 19, 2008
  16. Re* [RFC/PATCH] extend meaning of "--root" option to index comparisonsJunio C Hamano, Sep 19, 2008
  17. Jeff KingSep 21, 2008
  18. Anatol PomozovSep 21, 2008
  19. Jakub NarebskiSep 21, 2008
  20. Jeff KingSep 22, 2008
  21. Re* [RFC/PATCH] extend meaning of "--root" option to index comparisonsJunio C Hamano, Sep 21, 2008
  22. Jeff KingSep 22, 2008

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.