libgit2

git_reference_symbolic_create

Version:

Create a new symbolic reference.

A symbolic reference is a reference name that refers to another reference name. If the other name moves, the symbolic name will move, too. As a simple example, the "HEAD" reference might refer to "refs/heads/master" while on the "master" branch of a repository.

The symbolic reference will be created in the repository and written to the disk. The generated reference object must be freed by the user.

Valid reference names must follow one of two patterns:

  1. Top-level names must contain only capital letters and underscores, and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
  2. Names prefixed with "refs/" can be almost anything. You must avoid the characters '~', '^', ':', '
    ', '?', '[', and '*', and the sequences ".." and "@{" which have special meaning to revparse.

This function will return an error if a reference already exists with the given name unless force is true, in which case it will be overwritten.

The signature and message for the reflog will be ignored if the reference does not belong in the standard set (HEAD, branches and remote-tracking branches) and it does not have a reflog.

Signature

int git_reference_symbolic_create(git_reference **out, git_repository *repo, const char *name, const char *target, int force, const git_signature *signature, const char *log_message);

Parameters

In
out

Pointer to the newly created reference

In
repo

Repository where that reference will live

const char *
In
name

The name of the reference

const char *
In
target

The target of the reference

int
In
force

Overwrite existing references

In
signature

The identity that will used to populate the reflog entry

const char *
In
log_message

The one line long message to be appended to the reflog

Returns

int

0 on success, GIT_EEXISTS, GIT_EINVALIDSPEC or an error code

Versions