refactor!: use Oid instead of String for arguments

This commit is contained in:
Aleksey Kulikov 2021-10-13 15:31:20 +03:00
parent 23787adc3a
commit 1972c6d1ab
39 changed files with 264 additions and 290 deletions

View file

@ -23,22 +23,22 @@ List<Map<String, Pointer>> list(Pointer<git_repository> repo) {
var nextError = 0;
while (nextError >= 0) {
final noteId = calloc<git_oid>();
var annotatedId = calloc<git_oid>();
nextError = libgit2.git_note_next(noteId, annotatedId, iterator.value);
final noteOid = calloc<git_oid>();
var annotatedOid = calloc<git_oid>();
nextError = libgit2.git_note_next(noteOid, annotatedOid, iterator.value);
if (nextError >= 0) {
final out = calloc<Pointer<git_note>>();
final error = libgit2.git_note_read(out, repo, notesRef, annotatedId);
final error = libgit2.git_note_read(out, repo, notesRef, annotatedOid);
calloc.free(noteId);
calloc.free(noteOid);
if (error < 0) {
calloc.free(out);
calloc.free(annotatedId);
calloc.free(annotatedOid);
calloc.free(iterator);
throw LibGit2Error(libgit2.git_error_last());
} else {
result.add({'note': out.value, 'annotatedId': annotatedId});
result.add({'note': out.value, 'annotatedOid': annotatedOid});
}
} else {
break;

View file

@ -19,7 +19,7 @@ Pointer<git_oid> target(Pointer<git_reference> ref) {
final result = libgit2.git_reference_target(ref);
if (result == nullptr) {
throw Exception('OID for reference isn\'t available');
throw Exception('Oid for reference isn\'t available');
} else {
return result;
}

View file

@ -106,30 +106,30 @@ class BlameHunk {
/// version of the file.
int get finalStartLineNumber => _blameHunkPointer.ref.final_start_line_number;
/// Returns the author of [finalCommitId]. If [GitBlameFlag.useMailmap] has been
/// Returns the author of [finalCommitOid]. If [GitBlameFlag.useMailmap] has been
/// specified, it will contain the canonical real name and email address.
Signature get finalCommitter =>
Signature(_blameHunkPointer.ref.final_signature);
/// Returns the [Oid] of the commit where this line was last changed.
Oid get finalCommitId => Oid.fromRaw(_blameHunkPointer.ref.final_commit_id);
Oid get finalCommitOid => Oid.fromRaw(_blameHunkPointer.ref.final_commit_id);
/// Returns the 1-based line number where this hunk begins, in the file
/// named by [originPath] in the commit specified by [originCommitId].
int get originStartLineNumber => _blameHunkPointer.ref.orig_start_line_number;
/// Returns the author of [originCommitId]. If [GitBlameFlag.useMailmap] has been
/// Returns the author of [originCommitOid]. If [GitBlameFlag.useMailmap] has been
/// specified, it will contain the canonical real name and email address.
Signature get originCommitter =>
Signature(_blameHunkPointer.ref.orig_signature);
/// Returns the [Oid] of the commit where this hunk was found. This will usually be
/// the same as [finalCommitId], except when [GitBlameFlag.trackCopiesAnyCommitCopies]
/// the same as [finalCommitOid], except when [GitBlameFlag.trackCopiesAnyCommitCopies]
/// been specified.
Oid get originCommitId => Oid.fromRaw(_blameHunkPointer.ref.orig_commit_id);
Oid get originCommitOid => Oid.fromRaw(_blameHunkPointer.ref.orig_commit_id);
/// Returns the path to the file where this hunk originated, as of the commit
/// specified by [originCommitId].
/// specified by [originCommitOid].
String get originPath =>
_blameHunkPointer.ref.orig_path.cast<Utf8>().toDartString();
}

View file

@ -11,13 +11,13 @@ class Blob {
/// Should be freed to release allocated memory.
Blob(this._blobPointer);
/// Lookups a blob object for provided [id] in a [repo]sitory.
/// Lookups a blob object for provided [oid] in a [repo]sitory.
///
/// Should be freed to release allocated memory.
Blob.lookup({required Repository repo, required Oid id}) {
Blob.lookup({required Repository repo, required Oid oid}) {
_blobPointer = bindings.lookup(
repoPointer: repo.pointer,
oidPointer: id.pointer,
oidPointer: oid.pointer,
);
}
@ -58,8 +58,8 @@ class Blob {
return Oid(bindings.createFromDisk(repoPointer: repo.pointer, path: path));
}
/// Returns the Oid of the blob.
Oid get id => Oid(bindings.id(_blobPointer));
/// Returns the [Oid] of the blob.
Oid get oid => Oid(bindings.id(_blobPointer));
/// Determines if the blob content is most certainly binary or not.
///

View file

@ -119,7 +119,7 @@ class Branch {
branch.free();
}
/// Returns the OID pointed to by a branch.
/// Returns the [Oid] pointed to by a branch.
///
/// Throws an exception if error occured.
Oid get target => Oid(reference_bindings.target(_branchPointer));

View file

@ -11,13 +11,13 @@ class Commit {
/// Should be freed to release allocated memory.
Commit(this._commitPointer);
/// Lookups commit object for provided [id] in a [repo]sitory.
/// Lookups commit object for provided [oid] in a [repo]sitory.
///
/// Should be freed to release allocated memory.
Commit.lookup({required Repository repo, required Oid id}) {
Commit.lookup({required Repository repo, required Oid oid}) {
_commitPointer = bindings.lookup(
repoPointer: repo.pointer,
oidPointer: id.pointer,
oidPointer: oid.pointer,
);
}
@ -67,8 +67,8 @@ class Commit {
/// The returned message will be slightly prettified by removing any potential leading newlines.
String get message => bindings.message(_commitPointer);
/// Returns the id of a commit.
Oid get id => Oid(bindings.id(_commitPointer));
/// Returns the [Oid] of a commit.
Oid get oid => Oid(bindings.id(_commitPointer));
/// Returns the commit time (i.e. committer time) of a commit.
int get time => bindings.time(_commitPointer);
@ -79,7 +79,7 @@ class Commit {
/// Returns the author of a commit.
Signature get author => Signature(bindings.author(_commitPointer));
/// Returns list of parent commits.
/// Returns list of parent commits [Oid]s.
///
/// Throws a [LibGit2Error] if error occured.
List<Oid> get parents {
@ -109,5 +109,5 @@ class Commit {
void free() => bindings.free(_commitPointer);
@override
String toString() => 'Commit{id: $id}';
String toString() => 'Commit{oid: $oid}';
}

View file

@ -107,9 +107,7 @@ class Diff {
);
}
/// Calculate the patch ID for the given patch.
///
/// Calculate a stable patch ID for the given patch by summing the hash of the file diffs,
/// Calculates a stable patch [Oid] for the given patch by summing the hash of the file diffs,
/// ignoring whitespace and line numbers. This can be used to derive whether two diffs are
/// the same with a high probability.
///
@ -181,9 +179,9 @@ class DiffFile {
final git_diff_file _diffFile;
/// Returns oid of the item. If the entry represents an absent side of a diff
/// Returns [Oid] of the item. If the entry represents an absent side of a diff
/// then the oid will be zeroes.
Oid get id => Oid.fromRaw(_diffFile.id);
Oid get oid => Oid.fromRaw(_diffFile.id);
/// Returns path to the entry relative to the working directory of the repository.
String get path => _diffFile.path.cast<Utf8>().toDartString();

View file

@ -153,7 +153,7 @@ class Index with IterableMixin<IndexEntry> {
///
/// This method will scan the index and write a representation of its current state back to disk;
/// it recursively creates tree objects for each of the subtrees stored in the index, but only
/// returns the OID of the root tree. This is the OID that can be used e.g. to create a commit.
/// returns the [Oid] of the root tree. This is the OID that can be used e.g. to create a commit.
///
/// The index must not contain any file in conflict.
///
@ -233,18 +233,20 @@ class IndexEntry {
/// Pointer to memory address for allocated index entry object.
Pointer<git_index_entry> get pointer => _indexEntryPointer;
/// Unique identity of the index entry.
Oid get id => Oid.fromRaw(_indexEntryPointer.ref.id);
/// Returns inique identity of the index entry.
Oid get oid => Oid.fromRaw(_indexEntryPointer.ref.id);
set id(Oid oid) => _indexEntryPointer.ref.id = oid.pointer.ref;
/// Sets inique identity of the index entry.
set oid(Oid oid) => _indexEntryPointer.ref.id = oid.pointer.ref;
/// Path of the index entry.
/// Returns path of the index entry.
String get path => _indexEntryPointer.ref.path.cast<Utf8>().toDartString();
/// Sets path of the index entry.
set path(String path) =>
_indexEntryPointer.ref.path = path.toNativeUtf8().cast<Int8>();
/// Returns id of the index entry as sha-1 hex.
/// Returns id of the index entry as sha hex.
String get sha => _oidToHex(_indexEntryPointer.ref.id);
/// Returns the UNIX file attributes of a index entry.

View file

@ -5,10 +5,10 @@ import 'bindings/note.dart' as bindings;
class Note {
/// Initializes a new instance of the [Note] class from provided
/// pointer to note and annotatedId objects in memory.
Note(this._notePointer, this._annotatedIdPointer);
/// pointer to note and annotatedOid objects in memory.
Note(this._notePointer, this._annotatedOidPointer);
/// Reads the note for an [annotatedId].
/// Reads the note for an [annotatedOid].
///
/// IMPORTANT: Notes must be freed manually when no longer needed to prevent
/// memory leak.
@ -16,31 +16,31 @@ class Note {
/// Throws a [LibGit2Error] if error occured.
Note.lookup({
required Repository repo,
required Oid annotatedId,
required Oid annotatedOid,
String notesRef = 'refs/notes/commits',
}) {
_notePointer = bindings.lookup(
repoPointer: repo.pointer,
oidPointer: annotatedId.pointer,
oidPointer: annotatedOid.pointer,
notesRef: notesRef,
);
_annotatedIdPointer = annotatedId.pointer;
_annotatedOidPointer = annotatedOid.pointer;
}
/// Pointer to memory address for allocated note object.
late final Pointer<git_note> _notePointer;
/// Pointer to memory address for allocated annotetedId object.
late final Pointer<git_oid> _annotatedIdPointer;
/// Pointer to memory address for allocated annotetedOid object.
late final Pointer<git_oid> _annotatedOidPointer;
/// Adds a note for an [annotatedId].
/// Adds a note for an [annotatedOid].
///
/// Throws a [LibGit2Error] if error occured.
static Oid create({
required Repository repo,
required Signature author,
required Signature committer,
required Oid annotatedId,
required Oid annotatedOid,
required String note,
String notesRef = 'refs/notes/commits',
bool force = false,
@ -49,19 +49,19 @@ class Note {
repoPointer: repo.pointer,
authorPointer: author.pointer,
committerPointer: committer.pointer,
oidPointer: annotatedId.pointer,
oidPointer: annotatedOid.pointer,
note: note,
notesRef: notesRef,
force: force,
));
}
/// Deletes the note for an [annotatedId].
/// Deletes the note for an [annotatedOid].
///
/// Throws a [LibGit2Error] if error occured.
static void delete({
required Repository repo,
required Oid annotatedId,
required Oid annotatedOid,
required Signature author,
required Signature committer,
String notesRef = 'refs/notes/commits',
@ -70,7 +70,7 @@ class Note {
repoPointer: repo.pointer,
authorPointer: author.pointer,
committerPointer: committer.pointer,
oidPointer: annotatedId.pointer,
oidPointer: annotatedOid.pointer,
);
}
@ -85,19 +85,19 @@ class Note {
return notesPointers
.map((e) => Note(
e['note'] as Pointer<git_note>,
e['annotatedId'] as Pointer<git_oid>,
e['annotatedOid'] as Pointer<git_oid>,
))
.toList();
}
/// Returns the note object's [Oid].
Oid get id => Oid(bindings.id(_notePointer));
Oid get oid => Oid(bindings.id(_notePointer));
/// Returns the note message.
String get message => bindings.message(_notePointer);
/// Returns the [Oid] of the git object being annotated.
Oid get annotatedId => Oid(_annotatedIdPointer);
Oid get annotatedOid => Oid(_annotatedOidPointer);
/// Releases memory allocated for note object.
void free() => bindings.free(_notePointer);

View file

@ -45,7 +45,7 @@ class Odb {
);
}
/// Returns list of all objects available in the database.
/// Returns list of all objects [Oid]s available in the database.
///
/// Throws a [LibGit2Error] if error occured.
List<Oid> get objects => bindings.objects(_odbPointer);
@ -102,10 +102,10 @@ class OdbObject {
/// Pointer to memory address for allocated odbObject object.
final Pointer<git_odb_object> _odbObjectPointer;
/// Returns the OID of an ODB object.
/// Returns the [Oid] of an ODB object.
///
/// This is the OID from which the object was read from.
Oid get id => Oid(bindings.objectId(_odbObjectPointer));
/// This is the [Oid] from which the object was read from.
Oid get oid => Oid(bindings.objectId(_odbObjectPointer));
/// Returns the type of an ODB object.
GitObject get type {

View file

@ -45,7 +45,7 @@ class Oid {
/// Pointer to memory address for allocated oid object.
Pointer<git_oid> get pointer => _oidPointer;
/// Returns hexadecimal SHA-1 string.
/// Returns hexadecimal SHA string.
String get sha => bindings.toSHA(_oidPointer);
@override

View file

@ -126,9 +126,9 @@ class RebaseOperation {
);
}
/// The commit ID being cherry-picked. This will be populated for
/// Returns the commit [Oid] being cherry-picked. This will be populated for
/// all operations except those of type [GitRebaseOperation.exec].
Oid get id => Oid.fromRaw(_rebaseOperationPointer.ref.id);
Oid get oid => Oid.fromRaw(_rebaseOperationPointer.ref.id);
/// The executable the user has requested be run. This will only
/// be populated for operations of type [GitRebaseOperation.exec].

View file

@ -149,9 +149,9 @@ class Reference {
: ReferenceType.symbolic;
}
/// Returns the OID pointed to by a reference.
/// Returns the [Oid] pointed to by a reference.
///
/// Throws an exception if error occured.
/// Throws an [Exception] if error occured.
Oid get target {
late final Pointer<git_oid> oidPointer;
@ -163,37 +163,33 @@ class Reference {
return Oid(oidPointer);
}
/// Conditionally creates a new reference with the same name as the given reference
/// but a different OID target.
/// Updates the [target] of this reference.
///
/// The new reference will be written to disk, overwriting the given reference.
/// [target] being either Oid for direct reference or String reference name for symbolic
/// reference.
///
/// Throws a [LibGit2Error] if error occured.
void setTarget({required String target, String? logMessage}) {
late final Oid oid;
final owner = bindings.owner(_refPointer);
if (isValidShaHex(target)) {
final repo = Repository(owner);
oid = Oid.fromSHA(repo: repo, sha: target);
} else {
final ref = Reference(bindings.lookup(repoPointer: owner, name: target));
oid = ref.target;
ref.free();
}
if (type == ReferenceType.direct) {
_refPointer = bindings.setTarget(
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if [target] is not
/// [Oid] or String.
void setTarget({required Object target, String? logMessage}) {
if (target is Oid) {
final newPointer = bindings.setTarget(
refPointer: _refPointer,
oidPointer: oid.pointer,
oidPointer: target.pointer,
logMessage: logMessage,
);
} else {
_refPointer = bindings.setTargetSymbolic(
free();
_refPointer = newPointer;
} else if (target is String) {
final newPointer = bindings.setTargetSymbolic(
refPointer: _refPointer,
target: target,
logMessage: logMessage,
);
free();
_refPointer = newPointer;
} else {
throw ArgumentError.value(
'$target must be either Oid or String reference name');
}
}

View file

@ -204,15 +204,19 @@ class Repository {
///
/// Otherwise, the HEAD will be detached and will directly point to the Commit.
///
/// Throws a [LibGit2Error] if error occured.
void setHead(String target) {
if (isValidShaHex(target)) {
/// Throws a [LibGit2Error] if error occured or [ArgumentError] if provided [target]
/// is not Oid or String.
void setHead(Object target) {
if (target is Oid) {
bindings.setHeadDetached(
repoPointer: _repoPointer,
commitishPointer: this[target].pointer,
commitishPointer: target.pointer,
);
} else {
} else if (target is String) {
bindings.setHead(repoPointer: _repoPointer, refname: target);
} else {
throw ArgumentError.value(
'$target must be either Oid or String reference name');
}
}
@ -267,8 +271,9 @@ class Repository {
/// (merge, cherry-pick, etc) is in progress.
GitRepositoryState get state {
final stateInt = bindings.state(_repoPointer);
return GitRepositoryState.values
.singleWhere((state) => stateInt == state.value);
return GitRepositoryState.values.singleWhere(
(state) => stateInt == state.value,
);
}
/// Removes all the metadata associated with an ongoing command like
@ -424,11 +429,11 @@ class Repository {
/// Throws a [LibGit2Error] if error occured.
Odb get odb => Odb(bindings.odb(_repoPointer));
/// Lookups a tree object for provided [id].
/// Lookups a tree object for provided [oid].
///
/// Should be freed to release allocated memory.
Tree lookupTree(Oid id) {
return Tree.lookup(repo: this, id: id);
Tree lookupTree(Oid oid) {
return Tree.lookup(repo: this, oid: oid);
}
/// Creates a new action signature with default user and now timestamp.
@ -439,17 +444,17 @@ class Repository {
/// Throws a [LibGit2Error] if error occured.
Signature get defaultSignature => Signature.defaultSignature(this);
/// Returns the list of commits starting from provided [sha] hex string.
/// Returns the list of commits starting from provided commit [oid].
///
/// If [sorting] isn't provided default will be used (reverse chronological order, like in git).
List<Commit> log({
required String sha,
required Oid oid,
Set<GitSort> sorting = const {GitSort.none},
}) {
final walker = RevWalk(this);
walker.sorting(sorting);
walker.push(this[sha]);
walker.push(oid);
final result = walker.walk();
walker.free();
@ -468,11 +473,11 @@ class Repository {
return RevParse.single(repo: this, spec: spec);
}
/// Lookups commit object for provided [id].
/// Lookups commit object for provided [oid].
///
/// Should be freed to release allocated memory.
Commit lookupCommit(Oid id) {
return Commit.lookup(repo: this, id: id);
Commit lookupCommit(Oid oid) {
return Commit.lookup(repo: this, oid: oid);
}
/// Creates new commit in the repository.
@ -529,11 +534,11 @@ class Repository {
return RevParse.range(repo: this, spec: spec);
}
/// Lookups a blob object for provided [id].
/// Lookups a blob object for provided [oid].
///
/// Should be freed to release allocated memory.
Blob lookupBlob(Oid id) {
return Blob.lookup(repo: this, id: id);
Blob lookupBlob(Oid oid) {
return Blob.lookup(repo: this, oid: oid);
}
/// Creates a new blob from a [content] string and writes it to ODB.
@ -564,10 +569,10 @@ class Repository {
/// Throws a [LibGit2Error] if error occured.
List<String> get tags => Tag.list(this);
/// Lookups tag object for provided [id].
/// Lookups tag object for provided [oid].
///
/// Should be freed to release allocated memory.
Tag lookupTag(Oid id) => Tag.lookup(repo: this, id: id);
Tag lookupTag(Oid oid) => Tag.lookup(repo: this, oid: oid);
/// Creates a new tag in the repository for provided [target] object.
///
@ -753,11 +758,11 @@ class Repository {
/// Finds a merge base between two commits.
///
/// Throws a [LibGit2Error] if error occured.
Oid mergeBase({required String a, required String b}) {
Oid mergeBase({required Oid a, required Oid b}) {
return Oid(merge_bindings.mergeBase(
repoPointer: _repoPointer,
aPointer: this[a].pointer,
bPointer: this[b].pointer,
aPointer: a.pointer,
bPointer: b.pointer,
));
}
@ -797,7 +802,7 @@ class Repository {
return [analysisSet, mergePreference];
}
/// Merges the given commit(s) oid into HEAD, writing the results into the working directory.
/// Merges the given commit [oid] into HEAD, writing the results into the working directory.
/// Any changes are staged for commit and any conflicts are written to the index. Callers
/// should inspect the repository's index after this completes, resolve any conflicts and
/// prepare a commit.
@ -909,7 +914,7 @@ class Repository {
));
}
/// Cherry-picks the provided commit, producing changes in the index and working directory.
/// Cherry-picks the provided [commit], producing changes in the index and working directory.
///
/// Any changes are staged for commit and any conflicts are written to the index. Callers
/// should inspect the repository's index after this completes, resolve any conflicts and
@ -982,14 +987,14 @@ class Repository {
}
}
/// Sets the current head to the specified commit and optionally resets the index
/// Sets the current head to the specified commit [oid] and optionally resets the index
/// and working tree to match.
///
/// Throws a [LibGit2Error] if error occured.
void reset({required String target, required GitReset resetType}) {
void reset({required Oid oid, required GitReset resetType}) {
final object = object_bindings.lookup(
repoPointer: _repoPointer,
oidPointer: this[target].pointer,
oidPointer: oid.pointer,
type: GitObject.any.value,
);
@ -1296,30 +1301,30 @@ class Repository {
/// Throws a [LibGit2Error] if error occured.
List<Note> get notes => Note.list(this);
/// Reads the note for an [annotatedId].
/// Reads the note for an [annotatedOid].
///
/// IMPORTANT: Notes must be freed manually when no longer needed to prevent
/// memory leak.
///
/// Throws a [LibGit2Error] if error occured.
Note lookupNote({
required Oid annotatedId,
required Oid annotatedOid,
String notesRef = 'refs/notes/commits',
}) {
return Note.lookup(
repo: this,
annotatedId: annotatedId,
annotatedOid: annotatedOid,
notesRef: notesRef,
);
}
/// Adds a note for an [annotatedId].
/// Adds a note for an [annotatedOid].
///
/// Throws a [LibGit2Error] if error occured.
Oid createNote({
required Signature author,
required Signature committer,
required Oid annotatedId,
required Oid annotatedOid,
required String note,
String notesRef = 'refs/notes/commits',
bool force = false,
@ -1328,25 +1333,25 @@ class Repository {
repo: this,
author: author,
committer: committer,
annotatedId: annotatedId,
annotatedOid: annotatedOid,
note: note,
notesRef: notesRef,
force: force,
);
}
/// Deletes the note for an [annotatedId].
/// Deletes the note for an [annotatedOid].
///
/// Throws a [LibGit2Error] if error occured.
void deleteNote({
required Oid annotatedId,
required Oid annotatedOid,
required Signature author,
required Signature committer,
String notesRef = 'refs/notes/commits',
}) {
Note.delete(
repo: this,
annotatedId: annotatedId,
annotatedOid: annotatedOid,
author: author,
committer: committer,
notesRef: notesRef,
@ -1359,11 +1364,11 @@ class Repository {
/// `git merge-base --is-ancestor`.
///
/// Throws a [LibGit2Error] if error occured.
bool descendantOf({required String commitSHA, required String ancestorSHA}) {
bool descendantOf({required Oid commit, required Oid ancestor}) {
return graph_bindings.descendantOf(
repoPointer: _repoPointer,
commitPointer: this[commitSHA].pointer,
ancestorPointer: this[ancestorSHA].pointer,
commitPointer: commit.pointer,
ancestorPointer: ancestor.pointer,
);
}
@ -1373,13 +1378,13 @@ class Repository {
/// but it helps to think of one as a branch and the other as its upstream, the ahead and
/// behind values will be what git would report for the branches.
List<int> aheadBehind({
required String localSHA,
required String upstreamSHA,
required Oid local,
required Oid upstream,
}) {
return graph_bindings.aheadBehind(
repoPointer: _repoPointer,
localPointer: this[localSHA].pointer,
upstreamPointer: this[upstreamSHA].pointer,
localPointer: local.pointer,
upstreamPointer: upstream.pointer,
);
}

View file

@ -37,14 +37,14 @@ class RevWalk {
);
}
/// Adds a new root for the traversal.
/// Adds a new root commit [oid] for the traversal.
///
/// The pushed commit will be marked as one of the roots from which to start the walk.
/// This commit may not be walked if it or a child is hidden.
///
/// At least one commit must be pushed onto the walker before a walk can be started.
///
/// The given id must belong to a committish on the walked repository.
/// The given [oid] must belong to a committish on the walked repository.
///
/// Throws a [LibGit2Error] if error occured.
void push(Oid oid) {
@ -54,7 +54,7 @@ class RevWalk {
);
}
/// Marks a commit (and its ancestors) uninteresting for the output.
/// Marks a commit [oid] (and its ancestors) uninteresting for the output.
///
/// The given id must belong to a committish on the walked repository.
///

View file

@ -216,26 +216,26 @@ class Submodule {
/// Returns the [Oid] for the submodule in the current HEAD tree or
/// null if submodule is not in the HEAD.
Oid? get headId {
Oid? get headOid {
final result = bindings.headId(_submodulePointer);
return result == null ? null : Oid(result);
}
/// Returns the [Oid] for the submodule in the index or null if submodule
/// is not in the index.
Oid? get indexId {
Oid? get indexOid {
final result = bindings.indexId(_submodulePointer);
return result == null ? null : Oid(result);
}
/// Returns the OID for the submodule in the current working directory or null if
/// Returns the [Oid] for the submodule in the current working directory or null if
/// submodule is not checked out.
///
/// This returns the OID that corresponds to looking up `HEAD` in the checked out
/// This returns the [Oid] that corresponds to looking up `HEAD` in the checked out
/// submodule. If there are pending changes in the index or anything else, this
/// won't notice that. You should call [status] for a more complete picture about
/// the state of the working directory.
Oid? get workdirId {
Oid? get workdirOid {
final result = bindings.workdirId(_submodulePointer);
return result == null ? null : Oid(result);
}

View file

@ -11,13 +11,13 @@ class Tag {
/// Should be freed to release allocated memory.
Tag(this._tagPointer);
/// Lookups tag object for provided [id] in a [repo]sitory.
/// Lookups tag object for provided [oid] in a [repo]sitory.
///
/// Should be freed to release allocated memory.
Tag.lookup({required Repository repo, required Oid id}) {
Tag.lookup({required Repository repo, required Oid oid}) {
_tagPointer = bindings.lookup(
repoPointer: repo.pointer,
oidPointer: id.pointer,
oidPointer: oid.pointer,
);
}
@ -112,8 +112,8 @@ class Tag {
}
}
/// Get the id of a tag.
Oid get id => Oid(bindings.id(_tagPointer));
/// Returns the [Oid] of a tag.
Oid get oid => Oid(bindings.id(_tagPointer));
/// Returns the name of a tag.
String get name => bindings.name(_tagPointer);

View file

@ -11,13 +11,13 @@ class Tree {
/// Should be freed to release allocated memory.
Tree(this._treePointer);
/// Lookups a tree object for provided [id] in a [repo]sitory.
/// Lookups a tree object for provided [oid] in a [repo]sitory.
///
/// Should be freed to release allocated memory.
Tree.lookup({required Repository repo, required Oid id}) {
Tree.lookup({required Repository repo, required Oid oid}) {
_treePointer = bindings.lookup(
repoPointer: repo.pointer,
oidPointer: id.pointer,
oidPointer: oid.pointer,
);
}
@ -69,8 +69,8 @@ class Tree {
}
}
/// Returns the Oid of a tree.
Oid get id => Oid(bindings.id(_treePointer));
/// Returns the [Oid] of a tree.
Oid get oid => Oid(bindings.id(_treePointer));
/// Get the number of entries listed in a tree.
int get length => bindings.entryCount(_treePointer);
@ -141,8 +141,8 @@ class TreeEntry {
/// Pointer to memory address for allocated tree entry object.
final Pointer<git_tree_entry> _treeEntryPointer;
/// Returns the Oid of the object pointed by the entry.
Oid get id => Oid(bindings.entryId(_treeEntryPointer));
/// Returns the [Oid] of the object pointed by the entry.
Oid get oid => Oid(bindings.entryId(_treeEntryPointer));
/// Returns the filename of a tree entry.
String get name => bindings.entryName(_treeEntryPointer);
@ -201,5 +201,5 @@ class TreeEntry {
void free() => bindings.entryFree(_treeEntryPointer);
@override
String toString() => 'TreeEntry{id: $id, name: $name}';
String toString() => 'TreeEntry{oid: $oid, name: $name}';
}