Skip to content

Latest commit

 

History

History
1081 lines (811 loc) · 29 KB

File metadata and controls

1081 lines (811 loc) · 29 KB
layout default
menu_item api
title Repository
description Version 0.4.0
return_to
API Documentation Index
/api/
sections
init initExt open openBare openExt wrapOdb #checkoutBranch #config #configSnapshot #continueRebase #createBlobFromBuffer #createBranch #createCommit #createCommitOnHead #createLightweightTag #createRevWalk #createTag #defaultSignature #deleteTagByName #detachHead #fetch #fetchAll #fetchheadForeach #free #getBlob #getBranch #getBranchCommit #getCommit #getCurrentBranch #getHeadCommit #getMasterCommit #getNamespace #getReference #getReferenceCommit #getReferenceNames #getReferences #getRemote #getRemotes #getStatus #getStatusExt #getTag #getTagByName #getTree #head #headDetached #headUnborn #index #isBare #isEmpty #isShallow #mergeBranches #messageRemove #odb #path #rebaseBranches #refdb #setHead #setHeadDetached #setNamespace #setWorkdir #state #stateCleanup #treeBuilder #workdir INIT_FLAG INIT_MODE OPEN_FLAG STATE
#init
#initExt
#open
#openBare
#openExt
#wrapOdb
#checkoutBranch
#config
#configSnapshot
#continueRebase
#createBlobFromBuffer
#createBranch
#createCommit
#createCommitOnHead
#createLightweightTag
#createRevWalk
#createTag
#defaultSignature
#deleteTagByName
#detachHead
#fetch
#fetchAll
#fetchheadForeach
#free
#getBlob
#getBranch
#getBranchCommit
#getCommit
#getCurrentBranch
#getHeadCommit
#getMasterCommit
#getNamespace
#getReference
#getReferenceCommit
#getReferenceNames
#getReferences
#getRemote
#getRemotes
#getStatus
#getStatusExt
#getTag
#getTagByName
#getTree
#head
#headDetached
#headUnborn
#index
#isBare
#isEmpty
#isShallow
#mergeBranches
#messageRemove
#odb
#path
#rebaseBranches
#refdb
#setHead
#setHeadDetached
#setNamespace
#setWorkdir
#state
#stateCleanup
#treeBuilder
#workdir
#INIT_FLAG
#INIT_MODE
#OPEN_FLAG
#STATE

Repository.init Async

Repository.init(path, is_bare).then(function(repository) {
  // Use repository
});
Parameters Type
path String the path to the repository
is_bare Number if true, a Git repository without a working directory is created at the pointed path. If false, provided path will be considered as the working directory into which the .git directory will be created.
Returns
Repository

Repository.initExt Async

Repository.initExt(repo_path, opts).then(function(repository) {
  // Use repository
});
Parameters Type
repo_path String The path to the repository.
opts RepositoryInitOptions Pointer to git_repository_init_options struct.
Returns
Repository

Repository.open Async

Repository.open(path).then(function(repository) {
  // Use repository
});
Parameters Type
path String the path to the repository
Returns
Repository

Repository.openBare Async

Repository.openBare(bare_path).then(function(repository) {
  // Use repository
});
Parameters Type
bare_path String Direct path to the bare repository
Returns
Repository

Repository.openExt Async

Repository.openExt(path, flags, ceiling_dirs).then(function(repository) {
  // Use repository
});
Parameters Type
path String Path to open as git repository. If the flags permit "searching", then this can be a path to a subdirectory inside the working directory of the repository.
flags Number A combination of the GIT_REPOSITORY_OPEN flags above.
ceiling_dirs String A GIT_PATH_LIST_SEPARATOR delimited list of path prefixes at which the search for a containing repository should terminate.
Returns
Repository

Repository.wrapOdb Async

Repository.wrapOdb(odb).then(function(repository) {
  // Use repository
});
Parameters Type
odb Odb the object database to wrap
Returns
Repository

Repository#checkoutBranch Sync

repository.checkoutBranch(branch, opts);

This will set the HEAD to point to the local branch and then attempt to update the index and working tree to match the content of the latest commit on that branch

| Parameters | Type | | --- | --- | --- | | branch | String, Reference | the branch to checkout | | opts | Object, CheckoutOptions | the options to use for the checkout |

Repository#config Async

repository.config().then(function(config) {
  // Use config
});
Returns
Config

Repository#configSnapshot Async

repository.configSnapshot().then(function(config) {
  // Use config
});
Returns
Config

Repository#continueRebase Sync

var oid = repository.continueRebase(signature);

Continues an existing rebase

| Parameters | Type | | --- | --- | --- | | signature | Signature | Identity of the one performing the rebase |

Returns
Oid A commit id for a succesful merge or an index for a rebase with conflicts

Repository#createBlobFromBuffer Sync

var blob = repository.createBlobFromBuffer(buffer);

Create a blob from a buffer

| Parameters | Type | | --- | --- | --- | | buffer | Buffer | |

Returns
Blob

Repository#createBranch Async

repository.createBranch(name, commit, force, signature, logMessage).then(function(ref) {
  // Use ref
});

Creates a branch with the passed in name pointing to the commit

| Parameters | Type | | --- | --- | --- | | name | String | Branch name, e.g. "master" | | commit | Commit, String, Oid | The commit the branch will point to | | force | bool | Overwrite branch if it exists | | signature | Signature | Identity to use to populate reflog | | logMessage | String | One line message to be appended to the reflog |

Returns
Ref

Repository#createCommit Async

repository.createCommit(updateRef, author, committer, message, Tree, parents).then(function(oid) {
  // Use oid
});

Create a commit

| Parameters | Type | | --- | --- | --- | | updateRef | String | | | author | Signature | | | committer | Signature | | | message | String | | | Tree | Tree, Oid, String | | | parents | Array | |

Returns
Oid The oid of the commit

Repository#createCommitOnHead Async

repository.createCommitOnHead(filesToAdd, author, committer, message).then(function(oid) {
  // Use oid
});

Creates a new commit on HEAD from the list of passed in files

| Parameters | Type | | --- | --- | --- | | filesToAdd | Array | | | author | Signature | | | committer | Signature | | | message | String | |

Returns
Oid The oid of the new commit

Repository#createLightweightTag Async

repository.createLightweightTag(String, name).then(function(reference) {
  // Use reference
});

Creates a new lightweight tag

| Parameters | Type | | --- | --- | --- | | String | String, Oid | sha or Oid | | name | String | the name of the tag |

Returns
Reference

Repository#createRevWalk Sync

var revWalk = repository.createRevWalk(String);

Instantiate a new revision walker for browsing the Repository"s history. See also Commit.prototype.history()

| Parameters | Type | | --- | --- | --- | | String | String, Oid | sha or Oid |

Returns
RevWalk

Repository#createTag Async

repository.createTag(String, name, message).then(function(tag) {
  // Use tag
});

Creates a new annotated tag

| Parameters | Type | | --- | --- | --- | | String | String, Oid | sha or Oid | | name | String | the name of the tag | | message | String | the description that will be attached to the annotated tag |

Returns
Tag

Repository#defaultSignature Sync

var signature = repository.defaultSignature();

Gets the default signature for the default user and now timestamp

Returns
Signature

Repository#deleteTagByName Async

repository.deleteTagByName(Short).then(function() {
  // method complete});

Deletes a tag from a repository by the tag name.

| Parameters | Type | | --- | --- | --- | | Short | String | or full tag name |

Repository#detachHead Sync

var result = repository.detachHead(signature, reflog_message);

| Parameters | Type | | --- | --- | --- | | signature | Signature | The identity that will used to populate the reflog entry | | reflog_message | String | The one line long message to be appended to the reflog |

Returns
Number 0 on success, GIT_EUNBORNBRANCH when HEAD points to a non existing
branch or an error code

Repository#fetch Sync

repository.fetch(remote, remoteCallbacks, set, pruneAfter);

Fetches from a remote

| Parameters | Type | | --- | --- | --- | | remote | String, Remote | | | remoteCallbacks | Object, RemoteCallback | Any custom callbacks needed | | set | Bool, autoTag | the AUTO_TAG option for remote | | pruneAfter | Bool | will perform a prune after the fetch if true |

Repository#fetchAll Sync

repository.fetchAll(remoteCallbacks, set, pruneAfter);

Fetches from all remotes

| Parameters | Type | | --- | --- | --- | | remoteCallbacks | Object, RemoteCallback | Any custom callbacks needed | | set | Bool, autoTag | the AUTO_TAG option for remotes | | pruneAfter | Bool | will perform a prune after the fetch if true |

Repository#fetchheadForeach Async

repository.fetchheadForeach(callback).then(function() {
  // method complete});

| Parameters | Type | | --- | --- | --- | | callback | FetchheadForeachCb | The callback function to be called on each entry |

Repository#free Sync

repository.free();

Repository#getBlob Async

repository.getBlob(String).then(function(blob) {
  // Use blob
});

Retrieve the blob represented by the oid.

| Parameters | Type | | --- | --- | --- | | String | String, Oid | sha or Oid |

Returns
Blob

Repository#getBranch Async

repository.getBranch(name).then(function(ref) {
  // Use ref
});

Look up a branch. Alias for getReference

| Parameters | Type | | --- | --- | --- | | name | String, Ref | Ref name, e.g. "master", "refs/heads/master" or Branch Ref |

Returns
Ref

Repository#getBranchCommit Async

repository.getBranchCommit(name).then(function(commit) {
  // Use commit
});

Look up a branch's most recent commit. Alias to getReferenceCommit

| Parameters | Type | | --- | --- | --- | | name | String, Ref | Ref name, e.g. "master", "refs/heads/master" or Branch Ref |

Returns
Commit

Repository#getCommit Async

repository.getCommit(String).then(function(commit) {
  // Use commit
});

Retrieve the commit identified by oid.

| Parameters | Type | | --- | --- | --- | | String | String, Oid | sha or Oid |

Returns
Commit

Repository#getCurrentBranch Async

repository.getCurrentBranch().then(function(reference) {
  // Use reference
});

Gets the branch that HEAD currently points to Is an alias to head()

Returns
Reference

Repository#getHeadCommit Async

repository.getHeadCommit().then(function(commit) {
  // Use commit
});

Retrieve the commit that HEAD is currently pointing to

Returns
Commit

Repository#getMasterCommit Async

repository.getMasterCommit().then(function(commit) {
  // Use commit
});

Retrieve the master branch commit.

Returns
Commit

Repository#getNamespace Sync

var string = repository.getNamespace();
Returns
String the active namespace, or NULL if there isn't one

Repository#getReference Async

repository.getReference(name).then(function(reference) {
  // Use reference
});

Lookup the reference with the given name.

| Parameters | Type | | --- | --- | --- | | name | String, Ref | Ref name, e.g. "master", "refs/heads/master" or Branch Ref |

Returns
Reference

Repository#getReferenceCommit Async

repository.getReferenceCommit(name).then(function(commit) {
  // Use commit
});

Look up a refs's commit.

| Parameters | Type | | --- | --- | --- | | name | String, Ref | Ref name, e.g. "master", "refs/heads/master" or Branch Ref |

Returns
Commit

Repository#getReferenceNames Async

repository.getReferenceNames(type).then(function(arrayString) {
  // Use arrayString
});

Lookup reference names for a repository.

| Parameters | Type | | --- | --- | --- | | type | Reference.TYPE | Type of reference to look up |

Returns
Array<String>

Repository#getReferences Async

repository.getReferences(type).then(function(arrayReference) {
  // Use arrayReference
});

Lookup references for a repository.

| Parameters | Type | | --- | --- | --- | | type | Reference.TYPE | Type of reference to look up |

Returns
Array<Reference>

Repository#getRemote Sync

var remote = repository.getRemote(remote, callback);

Gets a remote from the repo

| Parameters | Type | | --- | --- | --- | | remote | String, Remote | | | callback | Function | |

Returns
Remote The remote object

Repository#getRemotes Sync

var object = repository.getRemotes(Optional);

Lists out the remotes in the given repository.

| Parameters | Type | | --- | --- | --- | | Optional | Function | callback |

Returns
Object Promise object.

Repository#getStatus Sync

var arrayStatusFile = repository.getStatus(opts);

Get the status of a repo to it's working directory

| Parameters | Type | | --- | --- | --- | | opts | obj | |

Returns
Array<StatusFile>

Repository#getStatusExt Sync

var arrayStatusEntry = repository.getStatusExt(opts);

Get extended statuses of a repo to it's working directory. Status entries have status, headToIndex delta, and indexToWorkdir deltas

| Parameters | Type | | --- | --- | --- | | opts | obj | |

Returns
Array<StatusEntry>

Repository#getTag Async

repository.getTag(String).then(function(tag) {
  // Use tag
});

Retrieve the tag represented by the oid.

| Parameters | Type | | --- | --- | --- | | String | String, Oid | sha or Oid |

Returns
Tag

Repository#getTagByName Async

repository.getTagByName(Short).then(function(tag) {
  // Use tag
});

Retrieve the tag represented by the tag name.

| Parameters | Type | | --- | --- | --- | | Short | String | or full tag name |

Returns
Tag

Repository#getTree Async

repository.getTree(String).then(function(tree) {
  // Use tree
});

Retrieve the tree represented by the oid.

| Parameters | Type | | --- | --- | --- | | String | String, Oid | sha or Oid |

Returns
Tree

Repository#head Async

repository.head().then(function(reference) {
  // Use reference
});
Returns
Reference

Repository#headDetached Sync

var result = repository.headDetached();
Returns
Number 1 if HEAD is detached, 0 if it's not; error code if there
was an error.

Repository#headUnborn Sync

var result = repository.headUnborn();
Returns
Number 1 if the current branch is unborn, 0 if it's not; error
code if there was an error

Repository#index Async

repository.index().then(function(index) {
  // Use index
});
Returns
Index

Repository#isBare Sync

var result = repository.isBare();
Returns
Number 1 if the repository is bare, 0 otherwise.

Repository#isEmpty Sync

var result = repository.isEmpty();
Returns
Number 1 if the repository is empty, 0 if it isn't, error code
if the repository is corrupted

Repository#isShallow Sync

var result = repository.isShallow();
Returns
Number 1 if shallow, zero if not

Repository#mergeBranches Sync

var oid = repository.mergeBranches(to, from);

Merge a branch onto another branch

| Parameters | Type | | --- | --- | --- | | to | String, Ref | | | from | String, Ref | |

Returns
Oid A commit id for a succesful merge or an index for a merge with conflicts

Repository#messageRemove Sync

var result = repository.messageRemove();
Returns
Number

Repository#odb Async

repository.odb().then(function(odb) {
  // Use odb
});
Returns
Odb

Repository#path Sync

var string = repository.path();
Returns
String the path to the repository

Repository#rebaseBranches Sync

var oid = repository.rebaseBranches(branch, upstream, onto, signature);

Rebases a branch onto another branch

| Parameters | Type | | --- | --- | --- | | branch | String | | | upstream | String | | | onto | String | | | signature | Signature | Identity of the one performing the rebase |

Returns
Oid A commit id for a succesful merge or an index for a rebase with conflicts

Repository#refdb Async

repository.refdb().then(function(refdb) {
  // Use refdb
});
Returns
Refdb

Repository#setHead Async

repository.setHead(refname, signature, log_message).then(function(result) {
  // Use result
});

| Parameters | Type | | --- | --- | --- | | refname | String | Canonical name of the reference the HEAD should point at | | signature | Signature | The identity that will used to populate the reflog entry | | log_message | String | The one line long message to be appended to the reflog |

Returns
Number 0 on success, or an error code

Repository#setHeadDetached Sync

var result = repository.setHeadDetached(commitish, signature, log_message);

| Parameters | Type | | --- | --- | --- | | commitish | Oid | Object id of the Commit the HEAD should point to | | signature | Signature | The identity that will used to populate the reflog entry | | log_message | String | The one line long message to be appended to the reflog |

Returns
Number 0 on success, or an error code

Repository#setNamespace Sync

var result = repository.setNamespace(nmspace);

| Parameters | Type | | --- | --- | --- | | nmspace | String | The namespace. This should not include the refs folder, e.g. to namespace all references under refs/namespaces/foo/, use foo as the namespace. |

Returns
Number 0 on success, -1 on error

Repository#setWorkdir Sync

var result = repository.setWorkdir(workdir, update_gitlink);

| Parameters | Type | | --- | --- | --- | | workdir | String | The path to a working directory | | update_gitlink | Number | Create/update gitlink in workdir and set config "core.worktree" (if workdir is not the parent of the .git directory) |

Returns
Number 0, or an error code

Repository#state Sync

var result = repository.state();
Returns
Number The state of the repository

Repository#stateCleanup Sync

var result = repository.stateCleanup();
Returns
Number 0 on success, or error

Repository#treeBuilder Sync

repository.treeBuilder(tree);

Create a new tree builder.

| Parameters | Type | | --- | --- | --- | | tree | Tree | |

Repository#workdir Sync

var string = repository.workdir();
Returns
String the path to the working dir, if it exists

Repository.INIT_FLAG ENUM

| Flag | Value | | --- | --- | --- | | Repository.INIT_FLAG.BARE | 1 | | Repository.INIT_FLAG.NO_REINIT | 2 | | Repository.INIT_FLAG.NO_DOTGIT_DIR | 4 | | Repository.INIT_FLAG.MKDIR | 8 | | Repository.INIT_FLAG.MKPATH | 16 | | Repository.INIT_FLAG.EXTERNAL_TEMPLATE | 32 | | Repository.INIT_FLAG.RELATIVE_GITLINK | 64 |

Repository.INIT_MODE ENUM

| Flag | Value | | --- | --- | --- | | Repository.INIT_MODE.INIT_SHARED_UMASK | 0 | | Repository.INIT_MODE.INIT_SHARED_GROUP | 1533 | | Repository.INIT_MODE.INIT_SHARED_ALL | 1535 |

Repository.OPEN_FLAG ENUM

| Flag | Value | | --- | --- | --- | | Repository.OPEN_FLAG.OPEN_NO_SEARCH | 1 | | Repository.OPEN_FLAG.OPEN_CROSS_FS | 2 | | Repository.OPEN_FLAG.OPEN_BARE | 4 |

Repository.STATE ENUM

| Flag | Value | | --- | --- | --- | | Repository.STATE.NONE | 0 | | Repository.STATE.MERGE | 1 | | Repository.STATE.REVERT | 2 | | Repository.STATE.CHERRYPICK | 3 | | Repository.STATE.BISECT | 4 | | Repository.STATE.REBASE | 5 | | Repository.STATE.REBASE_INTERACTIVE | 6 | | Repository.STATE.REBASE_MERGE | 7 | | Repository.STATE.APPLY_MAILBOX | 8 | | Repository.STATE.APPLY_MAILBOX_OR_REBASE | 9 |