bit_fast_import

git fast-import stream parser

git
fast-import
moon add mizchi/bit_fast_import@0.46.4
Download zip
Author
Version
0.46.4
License
Apache-2.0
Last updated
4 days ago
Downloads
52
README

#
FastImportDataResult

pub(all) struct FastImportDataResult {
content : Bytes
next_line : Int
}

#
FastImportFileOp

pub(all) enum FastImportFileOp {
Modify(mode~ : String, dataref~ : String, path~ : String)
Delete(path~ : String)
DeleteAll
Rename(old_path~ : String, new_path~ : String)
Copy(old_path~ : String, new_path~ : String)
} derive(Eq,
Debug
)

File operation types parsed from fast-import M/D/deleteall/R/C lines.

#
FastImportIdent

pub(all) struct FastImportIdent {
ident : String
timestamp : Int64
tz : String
}

Parsed identity from an author/committer/tagger line.

#
fast_import_parse_data

fn fast_import_parse_data(lines : Array[String], start : Int) -> FastImportDataResult

Parse a "data" command from pre-split lines starting at start. Supports both byte-count mode ("data ") and delimited mode ("data <<DELIM"). Returns the parsed content bytes and the index of the next line to process.

#
fast_import_parse_dataref

fn fast_import_parse_dataref(ref_str : String) -> (Int, String)

Resolve a dataref string: ":N" returns the mark number, hex returns hex. Returns (mark_number, hex_string) — one will be meaningful depending on format.

#
fast_import_parse_file_op

fn fast_import_parse_file_op(line : String) -> FastImportFileOp?

Parse a single file operation line from a fast-import stream. Returns None if the line is not a recognized file operation.

#
fast_import_parse_ident

fn fast_import_parse_ident(line : String) -> FastImportIdent?

Parse an author/committer line value (after stripping the "author "/"committer " prefix). Input: "Name timestamp tz" Returns None if the line cannot be parsed.

#
fast_import_parse_marks

fn fast_import_parse_marks(content : String) -> Array[(Int, String)]

Parse a marks file content into an array of (mark_number, hex_oid) pairs.

#
fast_import_parse_split_two_paths

fn fast_import_parse_split_two_paths(s : String) -> (String, String)?

Split two space-separated paths, handling quoted paths.

#
fast_import_parse_string_byte_count

fn fast_import_parse_string_byte_count(s : String) -> Int

Count UTF-8 encoded byte length of a string.

#
fast_import_parse_trim

fn fast_import_parse_trim(s : String) -> String

Trim whitespace from a string.

#
fast_import_parse_unquote_path

fn fast_import_parse_unquote_path(path : String) -> String

Unquote a C-style quoted path (e.g., ""foo/bar"" -> "foo/bar").