hs-git
hs-git copied to clipboard
Parser Issue (improper backtracking?)
It looks like maybeParseChunks
/eitherParseChunks
yield different results depending on where the input bytestring's chunk boundaries fall. This will, somewhat unfortunately, surface as RefNotFound
errors when trying to read an object using getObject_
.
To demonstrate:
:{
let
chunks =
[ "tree ad9dbc8a57cb0b085beda0b1787"
, "2e5c0969fc0f1\nparent 49423fd19151f8652d0ee707640bb4168a1ec5ca\nau"
, "thor Kim Altintop <[email protected]> 1544626597 +0100\ncommitter Kim Altintop <[email protected]> 1544626597 +0100\ngpg"
, "sig -----BEGIN PGP SIGNATURE-----\n \n iQIzBAABCAAdFiEE9fvRg86P9g49DnZNjtD9FaxE0PMFAlwRIjIACgkQjtD9FaxE\n 0POCUxAAl6miZr0P1nmajk0lms5cXnAMOpE9WNJOgASfa7J6Bz4kH0Ll+udpU/+B\n 7LIaXQg1ZzwyxSiLR777/VN/V5nCvBvXdv0tX6A6WEnX6IZwd46KVu/mukGNVSqU\n lH8LJCNikE/PC8i9Dw/Zj","Jnn63YunNOscxtU/2TQ/9mvIrqNB8tWBgazEQj1GEUN\n 3OzHyLBFcW84GEjy6/6WB56rRbj9k1ODQ+dWm2IUGR0+EFCsDmkiOFBpv/etGTzO\n Hs0MGX/KygjUPsyXqUQiCEQfwOlP+9aTr3uFnstRvnKrWF9b1vY/amNURdFf+S6E\n suURHGfSa8YWgUkG46n5k9xazMY5kks+31I2AZFD+iwJlZ9GfgnDrZ9tcBERjIPX\n 54O0Y4QTQAMhJCBqPqJeesVN84fprI53aHe4zBs11CO+9dXa8NBMqLFpe7XFvqeh\n apynUNPvgK17P7LNVEAndnAeFOH7JWkS5wtY+UQU6U9kcYmF0QeOXdtQDeeKYSz2\n htPDbZLiuMif5roUUxNLckXqu3wy4JcMhlyx+uTePo1TBqAJ0I6hCKWWVa6bUFOY\n VxtGq0S16jyScDlIhdYUIJRqKjnsUhKFnhehYPZQIfRMRQWY4UAXZZZXjBf6T8cH\n VH6/V"
, "yjXeqFdiUItxmfYKex1x1SUDKBYa4eMrA8k1rgdh7CdZy4=\n =wM1X\n -----END PGP SIGNATURE-----\n"
, "\nFix listRefs\n\nWould loop indefinitely when passed a 'LocalPath' containing forward slashes.\n"
]
in
eitherParseChunks commitParse chunks :: Either String (Commit SHA1)
:}
Left "EOL: need more data"
If we move the boundary of the last chunk a little, such that the previous parser yields some leftover unparsed input, parsing succeeds:
:{
let
chunks =
[ "tree ad9dbc8a57cb0b085beda0b1787"
, "2e5c0969fc0f1\nparent 49423fd19151f8652d0ee707640bb4168a1ec5ca\nau"
, "thor Kim Altintop <[email protected]> 1544626597 +0100\ncommitter Kim Altintop <[email protected]> 1544626597 +0100\ngpg"
, "sig -----BEGIN PGP SIGNATURE-----\n \n iQIzBAABCAAdFiEE9fvRg86P9g49DnZNjtD9FaxE0PMFAlwRIjIACgkQjtD9FaxE\n 0POCUxAAl6miZr0P1nmajk0lms5cXnAMOpE9WNJOgASfa7J6Bz4kH0Ll+udpU/+B\n 7LIaXQg1ZzwyxSiLR777/VN/V5nCvBvXdv0tX6A6WEnX6IZwd46KVu/mukGNVSqU\n lH8LJCNikE/PC8i9Dw/Zj","Jnn63YunNOscxtU/2TQ/9mvIrqNB8tWBgazEQj1GEUN\n 3OzHyLBFcW84GEjy6/6WB56rRbj9k1ODQ+dWm2IUGR0+EFCsDmkiOFBpv/etGTzO\n Hs0MGX/KygjUPsyXqUQiCEQfwOlP+9aTr3uFnstRvnKrWF9b1vY/amNURdFf+S6E\n suURHGfSa8YWgUkG46n5k9xazMY5kks+31I2AZFD+iwJlZ9GfgnDrZ9tcBERjIPX\n 54O0Y4QTQAMhJCBqPqJeesVN84fprI53aHe4zBs11CO+9dXa8NBMqLFpe7XFvqeh\n apynUNPvgK17P7LNVEAndnAeFOH7JWkS5wtY+UQU6U9kcYmF0QeOXdtQDeeKYSz2\n htPDbZLiuMif5roUUxNLckXqu3wy4JcMhlyx+uTePo1TBqAJ0I6hCKWWVa6bUFOY\n VxtGq0S16jyScDlIhdYUIJRqKjnsUhKFnhehYPZQIfRMRQWY4UAXZZZXjBf6T8cH\n VH6/V"
, "yjXeqFdiUItxmfYKex1x1SUDKBYa4eMrA8k1rgdh7CdZy4=\n =wM1X\n -----END PGP SIGNATURE-----\n\n"
, "Fix listRefs\n\nWould loop indefinitely when passed a 'LocalPath' containing forward slashes.\n"
]
in
eitherParseChunks commitParse chunks :: Either String (Commit SHA1)
:}
Right (Commit {commitTreeish = ad9dbc8a57cb0b085beda0b17872e5c0969fc0f1, commitParents = [49423fd19151f8652d0ee707640bb4168a1ec5ca], commitAuthor = Person {personName = "Kim Altintop", personEmail = "[email protected]", personTime = 1544626597 +0100}, commitCommitter = Person {personName = "Kim Altintop", personEmail = "[email protected]", personTime = 1544626597 +0100}, commitEncoding = Nothing, commitExtras = [CommitExtra {commitExtraKey = "gpgsig -----BEGIN PGP SIGNATURE-----", commitExtraValue = "\niQIzBAABCAAdFiEE9fvRg86P9g49DnZNjtD9FaxE0PMFAlwRIjIACgkQjtD9FaxE\n0POCUxAAl6miZr0P1nmajk0lms5cXnAMOpE9WNJOgASfa7J6Bz4kH0Ll+udpU/+B\n7LIaXQg1ZzwyxSiLR777/VN/V5nCvBvXdv0tX6A6WEnX6IZwd46KVu/mukGNVSqU\nlH8LJCNikE/PC8i9Dw/ZjJnn63YunNOscxtU/2TQ/9mvIrqNB8tWBgazEQj1GEUN\n3OzHyLBFcW84GEjy6/6WB56rRbj9k1ODQ+dWm2IUGR0+EFCsDmkiOFBpv/etGTzO\nHs0MGX/KygjUPsyXqUQiCEQfwOlP+9aTr3uFnstRvnKrWF9b1vY/amNURdFf+S6E\nsuURHGfSa8YWgUkG46n5k9xazMY5kks+31I2AZFD+iwJlZ9GfgnDrZ9tcBERjIPX\n54O0Y4QTQAMhJCBqPqJeesVN84fprI53aHe4zBs11CO+9dXa8NBMqLFpe7XFvqeh\napynUNPvgK17P7LNVEAndnAeFOH7JWkS5wtY+UQU6U9kcYmF0QeOXdtQDeeKYSz2\nhtPDbZLiuMif5roUUxNLckXqu3wy4JcMhlyx+uTePo1TBqAJ0I6hCKWWVa6bUFOY\nVxtGq0S16jyScDlIhdYUIJRqKjnsUhKFnhehYPZQIfRMRQWY4UAXZZZXjBf6T8cH\nVH6/VyjXeqFdiUItxmfYKex1x1SUDKBYa4eMrA8k1rgdh7CdZy4=\n=wM1X\n-----END PGP SIGNATURE-----"}], commitMessage = "Fix listRefs\n\nWould loop indefinitely when passed a 'LocalPath' containing forward slashes.\n"})