{"thread":{"id":"3889","subject":"[BUG] comments in grafts file broken in current master","startedAt":"2006-04-16T12:35:35Z","lastAt":"2006-04-16T21:26:30Z","messageCount":2,"participants":["Yann Dirson","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"18738","messageId":"20060416123535.GT12638@nowhere.earth","threadId":"3889","inReplyTo":null,"subject":"[BUG] comments in grafts file broken in current master","fromName":"Yann Dirson","fromEmail":"ydirson@altern.org","sentAt":"2006-04-16T12:35:35Z","receivedAt":"2006-04-16T12:35:35Z","isPatch":false,"sender":{"key":"ydirson@altern.org","avatar":"https://avatars.githubusercontent.com/u/1190950?v=4"},"body":"While looking at allowing empty lines in grafts files, I discovered\nthat comments had already been implemented.  However, current\ngit-read-tree segfaults when there is a comment line in info/grafts:\n\ndwitch@gandelf:/export/work/yann/git/git$ cat .git/info/grafts \nc118c026e44f02c3dbad00d924285eef2340f700\n# foo\ndwitch@gandelf:/export/work/yann/git/git$ git-read-tree master\nSegmentation fault\n\n\nThe commit introducing the problem is\n5040f17eba15504bad66b14a645bddd9b015ebb7 (blame -S <ancestry-file>),\nwhich changes quite some things in the grafts area.\n    \n\nBTW, after segfaulting, .git/index.lock is still there, and the\n\"unable to create new cachefile\" is not so helpful - I had to strace\nto see what was happenning.\n\nHope this helps,\n-- \nYann Dirson    <ydirson@altern.org> |\nDebian-related: <dirson@debian.org> |   Support Debian GNU/Linux:\n                                    |  Freedom, Power, Stability, Gratis\n     http://ydirson.free.fr/        | Check <http://www.debian.org/>\n"},{"id":"18755","messageId":"7v64l9qkjd.fsf@assigned-by-dhcp.cox.net","threadId":"3889","inReplyTo":"20060416123535.GT12638@nowhere.earth","subject":"[PATCH] reading $GIT_DIR/info/graft - skip comments correctly.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-04-16T21:26:30Z","receivedAt":"2006-04-16T21:26:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Noticed by Yann Dirson.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n\n---\n\n  Yann Dirson <ydirson@altern.org> writes:\n\n  > While looking at allowing empty lines in grafts files, I discovered\n  > that comments had already been implemented.  However, current\n  > git-read-tree segfaults when there is a comment line in info/grafts:\n  >\n  > dwitch@gandelf:/export/work/yann/git/git$ cat .git/info/grafts \n  > c118c026e44f02c3dbad00d924285eef2340f700\n  > # foo\n  > dwitch@gandelf:/export/work/yann/git/git$ git-read-tree master\n  > Segmentation fault\n\n  Thanks for noticing.\n\n commit.c |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\n5bc4ce589646faf72c7a77a5d32d9496ccc8d456\ndiff --git a/commit.c b/commit.c\nindex ca25574..05c4c92 100644\n--- a/commit.c\n+++ b/commit.c\n@@ -161,7 +161,7 @@ struct commit_graft *read_graft_line(cha\n \tif (buf[len-1] == '\\n')\n \t\tbuf[--len] = 0;\n \tif (buf[0] == '#')\n-\t\treturn 0;\n+\t\treturn NULL;\n \tif ((len + 1) % 41) {\n \tbad_graft_data:\n \t\terror(\"bad graft data: %s\", buf);\n@@ -192,6 +192,8 @@ int read_graft_file(const char *graft_fi\n \t\t/* The format is just \"Commit Parent1 Parent2 ...\\n\" */\n \t\tint len = strlen(buf);\n \t\tstruct commit_graft *graft = read_graft_line(buf, len);\n+\t\tif (!graft)\n+\t\t\tcontinue;\n \t\tif (register_commit_graft(graft, 1))\n \t\t\terror(\"duplicate graft data: %s\", buf);\n \t}\n-- \n1.3.0.rc4.g4024\n"}]}