{"thread":{"id":"2243","subject":"[TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid","startedAt":"2005-10-27T17:40:12Z","lastAt":"2006-02-28T21:16:01Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"10710","messageId":"Pine.LNX.4.63.0510271936520.7518@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2243","inReplyTo":null,"subject":"[TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-27T17:40:12Z","receivedAt":"2005-10-27T17:40:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"for_each_ref() used to ignore refs which point nowhere. Making git-fsck-objects\nbe happy about them.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n\tOf course, it may be by design. But then, it does not feel \n\tright to me. If this is intended behaviour, please don't let me \n\tdie dumb.\n\n refs.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\napplies-to: d29f6558d14b1da55642659c9874d4f52dac18bf\n047627834b0ecb7ec0e0a98066b4b28688c374bc\ndiff --git a/refs.c b/refs.c\nindex a52b038..d74ede9 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -194,9 +194,9 @@ static int do_for_each_ref(const char *b\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (read_ref(git_path(\"%s\", path), sha1) < 0)\n-\t\t\t\tcontinue;\n+\t\t\t\tdie(\"%s points nowhere!\", path);\n \t\t\tif (!has_sha1_file(sha1))\n-\t\t\t\tcontinue;\n+\t\t\t\tdie(\"%s does not point to a valid commit object!\", path);\n \t\t\tretval = fn(path, sha1);\n \t\t\tif (retval)\n \t\t\t\tbreak;\n---\n0.99.8.GIT\n"},{"id":"10715","messageId":"7vacgu3hta.fsf@assigned-by-dhcp.cox.net","threadId":"2243","inReplyTo":"Pine.LNX.4.63.0510271936520.7518@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-27T19:01:37Z","receivedAt":"2005-10-27T19:01:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The only case that I can think of that this patch may make a\ndifference in behaviour in a valid repository is the HEAD\npointer that points at nowhere (i.e. refs/heads/master)\nimmediately after git-init-db, so in that sense this change may\nbe safe for most purposes.\n\nHowever, we might want to write a tool to iterate over what we\nhave under .git/refs/ and warn about them to help the user fix\nbroken branches/tags, and do_for_each_ref() dying like this\nwould not help that usage.\n\nNot that the current loop is any better for that purpose.  We\nsilently ignore not just dangling ref and ref not storing\n40-byte hex, but files starting with a period '.',  names longer\nthan 255 bytes, and unreadable ones, all of which we would\nprobably want to warn about in such a tool.\n\n-jc\n"},{"id":"10717","messageId":"Pine.LNX.4.63.0510272125580.28705@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2243","inReplyTo":"7vacgu3hta.fsf@assigned-by-dhcp.cox.net","subject":"Re: [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-27T19:28:03Z","receivedAt":"2005-10-27T19:28:03Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 27 Oct 2005, Junio C Hamano wrote:\n\n> Not that the current loop is any better for that purpose.  We\n> silently ignore not just dangling ref and ref not storing\n> 40-byte hex, but files starting with a period '.',  names longer\n> than 255 bytes, and unreadable ones, all of which we would\n> probably want to warn about in such a tool.\n\nOkay, how about 'fprintf(stderr, \"Warning: ...\\n\"); continue;' instead of \n'die(\"...\");' then?\n\nCiao,\nDscho\n"},{"id":"10719","messageId":"7voe5a1yft.fsf@assigned-by-dhcp.cox.net","threadId":"2243","inReplyTo":"Pine.LNX.4.63.0510272125580.28705@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [TENTATIVE PATCH] Complain loudly, dying, when a ref is invalid","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-27T20:45:26Z","receivedAt":"2005-10-27T20:45:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi,\n>\n> On Thu, 27 Oct 2005, Junio C Hamano wrote:\n>\n>> Not that the current loop is any better for that purpose.  We\n>> silently ignore not just dangling ref and ref not storing\n>> 40-byte hex, but files starting with a period '.',  names longer\n>> than 255 bytes, and unreadable ones, all of which we would\n>> probably want to warn about in such a tool.\n>\n> Okay, how about 'fprintf(stderr, \"Warning: ...\\n\"); continue;' instead of \n> 'die(\"...\");' then?\n\nYup.  That sounds sensible.\n"},{"id":"16923","messageId":"Pine.LNX.4.63.0602282213180.27405@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2243","inReplyTo":"7voe5a1yft.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH] Warn about invalid refs","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-02-28T21:16:01Z","receivedAt":"2006-02-28T21:16:01Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\nOn Thu, 27 Oct 2005, Junio C Hamano wrote:\n\n\t> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\t> \n\t> > On Thu, 27 Oct 2005, Junio C Hamano wrote:\n\t> >\n\t> >> Not that the current loop is any better for that purpose.  \n\t> >> We silently ignore not just dangling ref and ref not storing\n\t> >> 40-byte hex, but files starting with a period '.', names \n\t> >> longer than 255 bytes, and unreadable ones, all of which we \n\t> >> would probably want to warn about in such a tool.\n\t> >\n\t> > Okay, how about 'fprintf(stderr, \"Warning: ...\\n\"); continue;' \n\t> > instead of 'die(\"...\");' then?\n\t> \n\t> Yup.  That sounds sensible.\n\n\tSorry for taking so long...\n\n refs.c |    9 +++++++--\n 1 files changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 826ae7a..982ebf8 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -151,10 +151,15 @@ static int do_for_each_ref(const char *b\n \t\t\t\t\tbreak;\n \t\t\t\tcontinue;\n \t\t\t}\n-\t\t\tif (read_ref(git_path(\"%s\", path), sha1) < 0)\n+\t\t\tif (read_ref(git_path(\"%s\", path), sha1) < 0) {\n+\t\t\t\tfprintf(stderr, \"%s points nowhere!\", path);\n \t\t\t\tcontinue;\n-\t\t\tif (!has_sha1_file(sha1))\n+\t\t\t}\n+\t\t\tif (!has_sha1_file(sha1)) {\n+\t\t\t\tfprintf(stderr, \"%s does not point to a valid \"\n+\t\t\t\t\t\t\"commit object!\", path);\n \t\t\t\tcontinue;\n+\t\t\t}\n \t\t\tretval = fn(path, sha1);\n \t\t\tif (retval)\n \t\t\t\tbreak;\n"}]}