{"thread":{"id":"8483","subject":"git-log fatal error in empty repo","startedAt":"2007-06-07T13:34:20Z","lastAt":"2007-06-09T02:31:21Z","messageCount":3,"participants":["Steve Hoelzer","Junio C Hamano","Geert Bosch"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"44242","messageId":"588192970706070634s4c25ae45g68be32c06a30d043@mail.gmail.com","threadId":"8483","inReplyTo":null,"subject":"git-log fatal error in empty repo","fromName":"Steve Hoelzer","fromEmail":"shoelzer@gmail.com","sentAt":"2007-06-07T13:34:20Z","receivedAt":"2007-06-07T13:34:20Z","isPatch":false,"sender":{"key":"shoelzer@gmail.com","avatar":"https://avatars.githubusercontent.com/u/4623209?v=4"},"body":"git-log will return a fatal error for an empty repo, like so:\n\n$ git --version\ngit version 1.5.2.73.g18bece\n$ mkdir mytest\n$ cd mytest\n$ git-init\nInitialized empty Git repository in .git/\n$ git-log\nfatal: bad default revision 'HEAD'\n\nIt would be nice if git-log was quiet or returned a \"no log\" message\ninstead of the fatal error.\n\nSteve\n"},{"id":"44258","messageId":"7vps47o6eh.fsf@assigned-by-dhcp.cox.net","threadId":"8483","inReplyTo":"588192970706070634s4c25ae45g68be32c06a30d043@mail.gmail.com","subject":"Re: git-log fatal error in empty repo","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-07T20:29:10Z","receivedAt":"2007-06-07T20:29:10Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Steve Hoelzer\" <shoelzer@gmail.com> writes:\n\n> git-log will return a fatal error for an empty repo, like so:\n>\n> $ git --version\n> git version 1.5.2.73.g18bece\n> $ mkdir mytest\n> $ cd mytest\n> $ git-init\n> Initialized empty Git repository in .git/\n> $ git-log\n> fatal: bad default revision 'HEAD'\n>\n> It would be nice if git-log was quiet or returned a \"no log\" message\n> instead of the fatal error.\n\nMaybe, but I highly doubt if it is worth to bother about it.\n\n revision.c |    5 ++++-\n 1 files changed, 4 insertions(+), 1 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 0a29b53..0573b86 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1218,8 +1218,11 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch\n \t\tunsigned char sha1[20];\n \t\tstruct object *object;\n \t\tunsigned mode;\n-\t\tif (get_sha1_with_mode(def, sha1, &mode))\n+\t\tif (get_sha1_with_mode(def, sha1, &mode)) {\n+\t\t\tif (!strcmp(\"HEAD\", def))\n+\t\t\t\tdie(\"You have no history yet on your HEAD\");\n \t\t\tdie(\"bad default revision '%s'\", def);\n+\t\t}\n \t\tobject = get_reference(revs, def, sha1, 0);\n \t\tadd_pending_object_with_mode(revs, object, def, mode);\n \t}\n"},{"id":"44426","messageId":"9EDDBC9D-EE20-4158-AF77-E46B1DD0BC74@adacore.com","threadId":"8483","inReplyTo":"7vps47o6eh.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-log fatal error in empty repo","fromName":"Geert Bosch","fromEmail":"bosch@adacore.com","sentAt":"2007-06-09T02:31:21Z","receivedAt":"2007-06-09T02:31:21Z","isPatch":false,"sender":{"key":"bosch@adacore.com","avatar":null},"body":"\nOn Jun 7, 2007, at 16:29, Junio C Hamano wrote:\n> Maybe, but I highly doubt if it is worth to bother about it.\n\nMy first confusion with git was exactly this issue.\nIt's very normal for a new user to do a git init\nand than try to verify that the current state is a sane\nempty repository.\n\nSo, git log, git status and git fsck should all properly\nhandle this situation and give reasonable output in this case.\n\n   -Geert\n"}]}