| License | BSD-style |
|---|---|
| Maintainer | Nicolas DI PRIMA <nicolas@di-prima.fr> |
| Stability | experimental |
| Portability | unix |
| Safe Haskell | None |
| Language | Haskell98 |
Data.Git.Diff
Contents
Description
Basic Git diff methods.
Synopsis
- data BlobContent
- data BlobState hash = BlobState {
- bsFilename :: EntPath
- bsMode :: ModePerm
- bsRef :: Ref hash
- bsContent :: BlobContent
- data BlobStateDiff hash
- getDiffWith :: (Typeable hash, HashAlgorithm hash) => (BlobStateDiff hash -> a -> a) -> a -> Ref hash -> Ref hash -> Git hash -> IO a
- data GitDiff hash = GitDiff {
- hFileName :: EntPath
- hFileContent :: GitFileContent
- hFileMode :: GitFileMode
- hFileRef :: GitFileRef hash
- data GitFileContent
- data FilteredDiff
- = NormalLine (Item TextLine)
- | Separator
- data GitFileRef hash
- = NewRef (Ref hash)
- | OldRef (Ref hash)
- | ModifiedRef (Ref hash) (Ref hash)
- | UnModifiedRef (Ref hash)
- data GitFileMode
- data TextLine = TextLine {}
- defaultDiff :: Int -> BlobStateDiff hash -> [GitDiff hash] -> [GitDiff hash]
- getDiff :: (Typeable hash, HashAlgorithm hash) => Ref hash -> Ref hash -> Git hash -> IO [GitDiff hash]
Basic features
data BlobContent Source #
represents a blob's content (i.e., the content of a file at a given reference).
Constructors
| FileContent [ByteString] | Text file's lines |
| BinaryContent ByteString | Binary content |
Instances
| Show BlobContent Source # | |
Defined in Data.Git.Diff Methods showsPrec :: Int -> BlobContent -> ShowS # show :: BlobContent -> String # showList :: [BlobContent] -> ShowS # | |
This is a blob description at a given state (revision)
Constructors
| BlobState | |
Fields
| |
data BlobStateDiff hash Source #
Represents a file state between two revisions A file (a blob) can be present in the first Tree's revision but not in the second one, then it has been deleted. If only in the second Tree's revision, then it has been created. If it is in the both, maybe it has been changed.
Arguments
| :: (Typeable hash, HashAlgorithm hash) | |
| => (BlobStateDiff hash -> a -> a) | diff helper (State -> accumulator -> accumulator) |
| -> a | accumulator |
| -> Ref hash | commit reference (the original state) |
| -> Ref hash | commit reference (the new state) |
| -> Git hash | repository |
| -> IO a |
generate a diff list between two revisions with a given diff helper.
Useful to extract any kind of information from two different revisions. For example you can get the number of deleted files:
getdiffwith f 0 head^ head git
where f (OnlyOld _) acc = acc+1
f _ acc = accOr save the list of new files:
getdiffwith f [] head^ head git
where f (OnlyNew bs) acc = (bsFilename bs):acc
f _ acc = accDefault helpers
This is a proposed diff records for a given file. It contains useful information: * the filename (with its path in the root project) * a file diff (with the Data.Algorithm.Patience method) * the file's mode (i.e. the file priviledge) * the file's ref
Constructors
| GitDiff | |
Fields
| |
data GitFileContent Source #
data FilteredDiff Source #
Constructors
| NormalLine (Item TextLine) | |
| Separator |
data GitFileRef hash Source #
Constructors
| NewRef (Ref hash) | |
| OldRef (Ref hash) | |
| ModifiedRef (Ref hash) (Ref hash) | |
| UnModifiedRef (Ref hash) |
data GitFileMode Source #
Constructors
| NewMode ModePerm | |
| OldMode ModePerm | |
| ModifiedMode ModePerm ModePerm | |
| UnModifiedMode ModePerm |
Constructors
| TextLine | |
Fields | |
Arguments
| :: Int | Number of line for context |
| -> BlobStateDiff hash | |
| -> [GitDiff hash] | Accumulator |
| -> [GitDiff hash] | Accumulator with a new content |
A default diff helper. It is an example about how you can write your own diff helper or you can use it if you want to get all of differences.