Xgit v0.8.0 Xgit.Object View Source
Describes a single object stored (or about to be stored) in a git repository.
This struct is constructed, modified, and shared as a working description of how to find and describe an object before it gets written to a repository.
Link to this section Summary
Types
Error codes which can be returned by check/2
.
This struct describes a single object stored or about to be stored in a git repository.
Functions
Verify that a proposed object is valid.
Return true
if the struct describes a valid object.
Link to this section Types
check_reason()
View Sourcecheck_reason() :: :invalid_type | :no_tree_header | :invalid_tree | :invalid_parent | :no_author | :no_committer | :no_object_header | :invalid_object | :no_type_header | :invalid_tagger | :bad_date | :bad_email | :missing_email | :missing_space_before_date | :bad_time_zone | :invalid_file_mode | :truncated_in_name | :duplicate_entry_names | :incorrectly_sorted | :truncated_in_object_id | :null_sha1 | :invalid_mode
Error codes which can be returned by check/2
.
t()
View Sourcet() :: %Xgit.Object{ content: Xgit.ContentSource.t(), id: Xgit.ObjectId.t() | :unknown, size: non_neg_integer() | :unknown, type: Xgit.ObjectType.t() }
This struct describes a single object stored or about to be stored in a git repository.
Struct Members
:type
: the object's type (:blob
,:tree
,:commit
, or:tag
):content
: how to obtain the content (seeXgit.ContentSource
):size
: size (in bytes) of the object or:unknown
:id
: object ID (40 chars hex) of the object or:unknown
Link to this section Functions
check(object, opts \\ [])
View Sourcecheck(object :: t(), windows?: boolean(), macosx?: boolean()) :: :ok | {:error, reason :: check_reason()} | {:error, reason :: Xgit.FilePath.check_path_reason()} | {:error, reason :: Xgit.FilePath.check_path_segment_reason()}
Verify that a proposed object is valid.
This function performs a detailed check on the content of the object.
For a simpler verification that the Object
struct is itself
valid, see valid?/1
.
Verifications made by this function only check that the fields of an object are formatted correctly. The object ID checksum of the object is not verified, and connectivity links between objects are also not verified. It's assumed that the caller can provide both of these validations on its own.
Options
By default, this function will only enforce Posix file name restrictions.
:macosx?
:true
to also enforce Mac OS X path name restrictions:windows?
:true
to also enforce Windows path name restrictions
Return Value
:ok
if the object is successfully validated.
{:error, :invalid_type}
if the object's type is unknown.
{:error, :no_tree_header}
if the object is a commit but does not contain
a valid tree header.
{:error, :invalid_tree}
if the object is a commit but the tree object ID
is invalid.
{:error, :invalid_parent}
if the object is a commit but one of the parent
headers is invalid.
{:error, :no_author}
if the object is a commit but there is no author
header.
{:error, :no_committer}
if the object is a commit but there is no committer
header.
{:error, :no_object_header}
if the object is a tag but there is no object
header.
{:error, :invalid_object}
if the object is a tag but the object ID is invalid.
{:error, :no_type_header}
if the object is a tag but there is no type
header.
{:error, :invalid_tagger}
if the object is a tag but one of the tagger
headers
is invalid.
{:error, :bad_date}
if the object is a tag or a commit but has a malformed date entry.
{:error, :bad_email}
if the object is a tag or a commit but has a malformed e-mail address.
{:error, :missing_email}
if the object is a tag or a commit but has a missing e-mail address
where one is expected.
{:error, :missing_space_before_date}
if the object is a tag or a commit but
has no space preceding the place where a date is expected.
{:error, :bad_time_zone}
if the object is a tag or a commit but has a malformed
time zone entry.
{:error, :invalid_file_mode}
if the object is a tree but one of the file modes is invalid.
{:error, :truncated_in_name}
if the object is a tree but one of the file names is incomplete.
{:error, :duplicate_entry_names}
if the object is a tree and contains duplicate
entry names.
{:error, :incorrectly_sorted}
if the object is a tree and the entries are not
in alphabetical order.
{:error, :truncated_in_object_id}
if the object is a tree and one of the object IDs
is invalid.
{:error, :null_sha1}
if the object is a tree and one of the object IDs is all zeros.
{:error, :invalid_mode}
if the object is a tree and one of the file modes is incomplete.
See also error responses from Xgit.FilePath.check_path/2
and
Xgit.FilePath.check_path_segment/2
.
Return true
if the struct describes a valid object.
IMPORTANT: This validation only verifies that the struct itself is valid.
It does not inspect the content of the object. That check can be performed by
check/2
.