update-ref: add support for 'symref-create' command
Add 'symref-create' command to the '--stdin' mode 'git-update-ref' to allow creation of symbolic refs in a transaction. The 'symref-create' command takes in a <new-target>, which the created <ref> will point to. Also, support the 'core.prefersymlinkrefs' config, wherein if the config is set and the filesystem supports symlinks, we create the symbolic ref as a symlink. We fallback to creating a regular symref if creating the symlink is unsuccessful. Helped-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
2343720967
commit
ed3272720e
9
refs.c
9
refs.c
@ -1302,15 +1302,18 @@ int ref_transaction_update(struct ref_transaction *transaction,
|
||||
int ref_transaction_create(struct ref_transaction *transaction,
|
||||
const char *refname,
|
||||
const struct object_id *new_oid,
|
||||
const char *new_target,
|
||||
unsigned int flags, const char *msg,
|
||||
struct strbuf *err)
|
||||
{
|
||||
if (!new_oid || is_null_oid(new_oid)) {
|
||||
strbuf_addf(err, "'%s' has a null OID", refname);
|
||||
if (new_oid && new_target)
|
||||
BUG("create called with both new_oid and new_target set");
|
||||
if ((!new_oid || is_null_oid(new_oid)) && !new_target) {
|
||||
strbuf_addf(err, "'%s' has neither a valid OID nor a target", refname);
|
||||
return 1;
|
||||
}
|
||||
return ref_transaction_update(transaction, refname, new_oid,
|
||||
null_oid(), NULL, NULL, flags,
|
||||
null_oid(), new_target, NULL, flags,
|
||||
msg, err);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user