{"thread":{"id":"13731","subject":"[PATCH] builtin-fast-export: Remove double spaces in author line","startedAt":"2008-05-30T10:31:15Z","lastAt":"2008-05-30T20:27:37Z","messageCount":2,"participants":["Pieter de Bie","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"78129","messageId":"1212143475-48255-1-git-send-email-pdebie@ai.rug.nl","threadId":"13731","inReplyTo":null,"subject":"[PATCH] builtin-fast-export: Remove double spaces in author line","fromName":"Pieter de Bie","fromEmail":"pdebie@ai.rug.nl","sentAt":"2008-05-30T10:31:15Z","receivedAt":"2008-05-30T10:31:15Z","isPatch":true,"sender":{"key":"pdebie@ai.rug.nl","avatar":null},"body":"At least the Samba repository has an extra space after the author's email\nfor some commits. This breaks builtin-fast-export as that format is required\nto have only a single space.\n\nThis removes double spaces in committer and author lines.\n---\n\nThis is an ugly hack and obviously not meant for application (which is why\nI didn't sign it off). \n\nThe Samba thing can be seen by running:\n\n  git cat-file commit 65968b294351d2612d1bf94236d1fcbf853c494e\n\nIt produces \n\n\t\"author Samba Release Account <samba-bugs@samba.org>  831196245 +0000\"\n\nThe git-fast-import syntax says there can only be a single space after the >\nsign. This Samba commit breaks bzr-fast-import, for example.\n\nI'm not sure how to properly fix the problem, as I'm not very deep into Git's\ncode. I included this patch in case anyone else has the same problem and wants\na quick fix. I'm also not sure if it's a fast-export problem, or if the Samba\nrepository is just invalid :)\n\n- Pieter\n\ndiff --git a/builtin-fast-export.c b/builtin-fast-export.c\nindex 1dfc01e..8218199 100755\n--- a/builtin-fast-export.c\n+++ b/builtin-fast-export.c\n@@ -144,6 +144,24 @@ static const char *find_encoding(const char *begin, const char *end)\n \treturn bol;\n }\n \n+static void parse_line(char **begin, char **end)\n+{\n+\tchar *b = *begin;\n+\tchar *e = *end;\n+\n+\tchar *line = xmalloc((e - b) * sizeof(char));\n+\t*begin = line;\n+\tchar prev = 0;\n+\n+\tfor (; b < e; b++) {\n+\t\tif (!(prev == ' ' && *b == ' '))\n+\t\t\t*line++ = *b;\n+\t\tprev = *b;\n+\t}\n+\n+\t*end = line;\n+}\n+\n static void handle_commit(struct commit *commit, struct rev_info *rev)\n {\n \tint saved_output_format = rev->diffopt.output_format;\n@@ -163,11 +181,14 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)\n \tauthor++;\n \tauthor_end = strchrnul(author, '\\n');\n \tcommitter = strstr(author_end, \"\\ncommitter \");\n+\tparse_line(&author, &author_end);\n+\n \tif (!committer)\n \t\tdie (\"Could not find committer in commit %s\",\n \t\t     sha1_to_hex(commit->object.sha1));\n \tcommitter++;\n \tcommitter_end = strchrnul(committer, '\\n');\n+\tparse_line(&committer, &committer_end);\n \tmessage = strstr(committer_end, \"\\n\\n\");\n \tencoding = find_encoding(committer_end, message);\n \tif (message)\n@@ -214,6 +235,8 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)\n \n \tprintf(\"\\n\");\n \n+\tfree(committer);\n+\tfree(author);\n \tshow_progress();\n }\n \n-- \n1.5.6.rc0.163.g26db5e.dirty\n"},{"id":"78166","messageId":"7vtzgfk05i.fsf@gitster.siamese.dyndns.org","threadId":"13731","inReplyTo":"1212143475-48255-1-git-send-email-pdebie@ai.rug.nl","subject":"Re: [PATCH] builtin-fast-export: Remove double spaces in author line","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-30T20:27:37Z","receivedAt":"2008-05-30T20:27:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pieter de Bie <pdebie@ai.rug.nl> writes:\n\n> It produces \n>\n> \t\"author Samba Release Account <samba-bugs@samba.org>  831196245 +0000\"\n>\n> The git-fast-import syntax says there can only be a single space after the >\n> sign. This Samba commit breaks bzr-fast-import, for example.\n>\n> I'm not sure how to properly fix the problem, as I'm not very deep into Git's\n> code. I included this patch in case anyone else has the same problem and wants\n> a quick fix. I'm also not sure if it's a fast-export problem, or if the Samba\n> repository is just invalid :)\n\nYou can call that repository broken if you want, but we can try to be\nliberal when receiving and be strict when generating.  IOW, fast-import\ncould accept such a minor deviation and generate a commit after fixing it.\nThe same thing can be said about fast-export --- read, fix and generate.\n\nBy the way, your quick hack would however squash multiple SPs anywhere on\nthe line, wouldn't it, not just the one between '>' and the timestamp?\n"}]}