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
Junio C Hamano <gitster@pobox.com>
Date
Sep 19, 2008, 20:27 UTC
Message-ID
<7vskrvswxp.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080919142537.GA1287@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 13 quoted lines
> On Thu, Sep 18, 2008 at 09:31:24AM -0700, Anatol Pomozov wrote:
>
>> > Can you think of any other cases?
>> 
>> git log??
>> 
>> git log --root for empty repo should not print anything (instead of
>> error message that we have now).
>
> I'm not sure that's the same as "--root", though. In existing --root
> cases, we are saying "pretend that beyond the initial commit, there is a
> commit that contains the empty tree". The logical extension of git-log
> here would be to print out that commit.
I would say:
 (1) A user getting an error message from "git init && git log" may be
     annoyed, but he very well knows there is no history yet _anyway_.
     This initial annoyance will pass immediately after creating any
     commit, so I do not think it is a big issue.
     "bad default revision 'HEAD'" is a cryptic way to give that indicaion
     that can be improved but that is a separate issue.  Rewording it so
     that it explains the situation better in user's terms would be a
     worthy improvement.
 (2) "--root" is about "do we show a creation event as a huge diff from
     emptyness?".  Yes, we turn it on for "git log" but it does not have
     anything to do with the issue of yet to be born branch, where there
     isn't even a big creation event yet.

I am reluctant to agree with the opinion that "git log" should be _silent_ in a world without any history.

Perhaps something like this would be a good compromise?  I dunno.
 builtin-log.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git c/builtin-log.c w/builtin-log.c
index 081e660..881324c 100644
--- c/builtin-log.c
+++ w/builtin-log.c
@@ -42,7 +42,14 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
 	if (default_date_mode)
 		rev->date_mode = parse_date_format(default_date_mode);
 
-	argc = setup_revisions(argc, argv, rev, "HEAD");
+	argc = setup_revisions(argc, argv, rev, NULL);
+	if (!rev->pending.nr) {
+		add_head_to_pending(rev);
+		if (!rev->pending.nr) {
+			printf("No commits (yet).\n");
+			exit(0);
+		}
+	}
 
 	if (rev->diffopt.pickaxe || rev->diffopt.filter)
 		rev->always_show_header = 0;
Previous: Jeff KingNext: Jeff King
Message 16 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.