fix git ls-tree parser
File mode is octal not decimal. This broke in the conversion to attoparsec. (I've submitted the content of Utility.Attoparsec to the attoparsec developers.) Test suite passes 100% now.
This commit is contained in:
parent
4aaef14c61
commit
f39f018ee0
5 changed files with 59 additions and 3 deletions
35
COPYRIGHT
35
COPYRIGHT
|
@ -29,6 +29,11 @@ Copyright: 2018 Joey Hess <id@joeyh.name>
|
|||
2013 Michael Snoyman
|
||||
License: Expat
|
||||
|
||||
Files: Utility/Attoparsec.hs
|
||||
Copyright: 2019 Joey Hess <id@joeyh.name>
|
||||
2007-2015 Bryan O'Sullivan
|
||||
License: BSD-3-clause
|
||||
|
||||
Files: Utility/GitLFS.hs
|
||||
Copyright: © 2019 Joey Hess <id@joeyh.name>
|
||||
License: AGPL-3+
|
||||
|
@ -112,7 +117,35 @@ License: BSD-2-clause
|
|||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
|
||||
License: BSD-3-clause
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
.
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
.
|
||||
3. Neither the name of the author nor the names of his contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
.
|
||||
THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
License: Expat
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
|
|
@ -24,6 +24,7 @@ import Git.Command
|
|||
import Git.Sha
|
||||
import Git.FilePath
|
||||
import qualified Git.Filename
|
||||
import Utility.Attoparsec
|
||||
|
||||
import Numeric
|
||||
import Data.Either
|
||||
|
@ -90,7 +91,7 @@ parseLsTree b = case A.parse parserLsTree b of
|
|||
parserLsTree :: A.Parser TreeItem
|
||||
parserLsTree = TreeItem
|
||||
-- mode
|
||||
<$> A8.decimal
|
||||
<$> octal
|
||||
<* A8.char ' '
|
||||
-- type
|
||||
<*> A.takeTill (== 32)
|
||||
|
|
|
@ -112,7 +112,7 @@ fmtObjectType TreeObject = "tree"
|
|||
|
||||
{- Types of items in a tree. -}
|
||||
data TreeItemType = TreeFile | TreeExecutable | TreeSymlink | TreeSubmodule
|
||||
deriving (Eq)
|
||||
deriving (Eq, Show)
|
||||
|
||||
{- Git uses magic numbers to denote the type of a tree item. -}
|
||||
readTreeItemType :: S.ByteString -> Maybe TreeItemType
|
||||
|
|
21
Utility/Attoparsec.hs
Normal file
21
Utility/Attoparsec.hs
Normal file
|
@ -0,0 +1,21 @@
|
|||
{- attoparsec utility functions
|
||||
-
|
||||
- Copyright 2019 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2007-2015 Bryan O'Sullivan
|
||||
-
|
||||
- License: BSD-3-clause
|
||||
-}
|
||||
|
||||
module Utility.Attoparsec where
|
||||
|
||||
import qualified Data.Attoparsec.ByteString as A
|
||||
import qualified Data.ByteString as B
|
||||
|
||||
-- | Parse and decode an unsigned octal number.
|
||||
--
|
||||
-- This parser does not accept a leading @\"0o\"@ string.
|
||||
octal :: Integral a => A.Parser a
|
||||
octal = B.foldl' step 0 `fmap` A.takeWhile1 isOctDigit
|
||||
where
|
||||
isOctDigit w = w >= 48 && w <= 55
|
||||
step a w = a * 8 + fromIntegral (w - 48)
|
|
@ -1020,6 +1020,7 @@ Executable git-annex
|
|||
Utility.Aeson
|
||||
Utility.Android
|
||||
Utility.Applicative
|
||||
Utility.Attoparsec
|
||||
Utility.AuthToken
|
||||
Utility.Base64
|
||||
Utility.Batch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue