mirror of
https://github.com/git/git
synced 2024-08-27 11:39:22 +00:00
Merge branch 'ab/no-errno-from-resolve-ref-unsafe'
Remaining code-clean-up. * ab/no-errno-from-resolve-ref-unsafe: refs API: remove "failure_errno" from refs_resolve_ref_unsafe() sequencer: don't use die_errno() on refs_resolve_ref_unsafe() failure
This commit is contained in:
commit
03bdcfcc78
51
refs.c
51
refs.c
|
@ -269,10 +269,9 @@ char *refs_resolve_refdup(struct ref_store *refs,
|
||||||
struct object_id *oid, int *flags)
|
struct object_id *oid, int *flags)
|
||||||
{
|
{
|
||||||
const char *result;
|
const char *result;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
result = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
|
result = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
|
||||||
oid, flags, &ignore_errno);
|
oid, flags);
|
||||||
return xstrdup_or_null(result);
|
return xstrdup_or_null(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,11 +293,10 @@ struct ref_filter {
|
||||||
|
|
||||||
int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags)
|
int read_ref_full(const char *refname, int resolve_flags, struct object_id *oid, int *flags)
|
||||||
{
|
{
|
||||||
int ignore_errno;
|
|
||||||
struct ref_store *refs = get_main_ref_store(the_repository);
|
struct ref_store *refs = get_main_ref_store(the_repository);
|
||||||
|
|
||||||
if (refs_resolve_ref_unsafe(refs, refname, resolve_flags,
|
if (refs_resolve_ref_unsafe(refs, refname, resolve_flags,
|
||||||
oid, flags, &ignore_errno))
|
oid, flags))
|
||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -310,9 +308,8 @@ int read_ref(const char *refname, struct object_id *oid)
|
||||||
|
|
||||||
int refs_ref_exists(struct ref_store *refs, const char *refname)
|
int refs_ref_exists(struct ref_store *refs, const char *refname)
|
||||||
{
|
{
|
||||||
int ignore_errno;
|
|
||||||
return !!refs_resolve_ref_unsafe(refs, refname, RESOLVE_REF_READING,
|
return !!refs_resolve_ref_unsafe(refs, refname, RESOLVE_REF_READING,
|
||||||
NULL, NULL, &ignore_errno);
|
NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ref_exists(const char *refname)
|
int ref_exists(const char *refname)
|
||||||
|
@ -656,15 +653,13 @@ int expand_ref(struct repository *repo, const char *str, int len,
|
||||||
struct object_id *this_result;
|
struct object_id *this_result;
|
||||||
int flag;
|
int flag;
|
||||||
struct ref_store *refs = get_main_ref_store(repo);
|
struct ref_store *refs = get_main_ref_store(repo);
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
this_result = refs_found ? &oid_from_ref : oid;
|
this_result = refs_found ? &oid_from_ref : oid;
|
||||||
strbuf_reset(&fullref);
|
strbuf_reset(&fullref);
|
||||||
strbuf_addf(&fullref, *p, len, str);
|
strbuf_addf(&fullref, *p, len, str);
|
||||||
r = refs_resolve_ref_unsafe(refs, fullref.buf,
|
r = refs_resolve_ref_unsafe(refs, fullref.buf,
|
||||||
RESOLVE_REF_READING,
|
RESOLVE_REF_READING,
|
||||||
this_result, &flag,
|
this_result, &flag);
|
||||||
&ignore_errno);
|
|
||||||
if (r) {
|
if (r) {
|
||||||
if (!refs_found++)
|
if (!refs_found++)
|
||||||
*ref = xstrdup(r);
|
*ref = xstrdup(r);
|
||||||
|
@ -693,14 +688,12 @@ int repo_dwim_log(struct repository *r, const char *str, int len,
|
||||||
for (p = ref_rev_parse_rules; *p; p++) {
|
for (p = ref_rev_parse_rules; *p; p++) {
|
||||||
struct object_id hash;
|
struct object_id hash;
|
||||||
const char *ref, *it;
|
const char *ref, *it;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
strbuf_reset(&path);
|
strbuf_reset(&path);
|
||||||
strbuf_addf(&path, *p, len, str);
|
strbuf_addf(&path, *p, len, str);
|
||||||
ref = refs_resolve_ref_unsafe(refs, path.buf,
|
ref = refs_resolve_ref_unsafe(refs, path.buf,
|
||||||
RESOLVE_REF_READING,
|
RESOLVE_REF_READING,
|
||||||
oid ? &hash : NULL, NULL,
|
oid ? &hash : NULL, NULL);
|
||||||
&ignore_errno);
|
|
||||||
if (!ref)
|
if (!ref)
|
||||||
continue;
|
continue;
|
||||||
if (refs_reflog_exists(refs, path.buf))
|
if (refs_reflog_exists(refs, path.buf))
|
||||||
|
@ -1390,10 +1383,9 @@ int refs_head_ref(struct ref_store *refs, each_ref_fn fn, void *cb_data)
|
||||||
{
|
{
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
int flag;
|
int flag;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
|
if (refs_resolve_ref_unsafe(refs, "HEAD", RESOLVE_REF_READING,
|
||||||
&oid, &flag, &ignore_errno))
|
&oid, &flag))
|
||||||
return fn("HEAD", &oid, flag, cb_data);
|
return fn("HEAD", &oid, flag, cb_data);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1682,15 +1674,13 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
|
||||||
const char *refname,
|
const char *refname,
|
||||||
int resolve_flags,
|
int resolve_flags,
|
||||||
struct object_id *oid,
|
struct object_id *oid,
|
||||||
int *flags, int *failure_errno)
|
int *flags)
|
||||||
{
|
{
|
||||||
static struct strbuf sb_refname = STRBUF_INIT;
|
static struct strbuf sb_refname = STRBUF_INIT;
|
||||||
struct object_id unused_oid;
|
struct object_id unused_oid;
|
||||||
int unused_flags;
|
int unused_flags;
|
||||||
int symref_count;
|
int symref_count;
|
||||||
|
|
||||||
assert(failure_errno);
|
|
||||||
|
|
||||||
if (!oid)
|
if (!oid)
|
||||||
oid = &unused_oid;
|
oid = &unused_oid;
|
||||||
if (!flags)
|
if (!flags)
|
||||||
|
@ -1700,10 +1690,8 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
|
||||||
|
|
||||||
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
|
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
|
||||||
if (!(resolve_flags & RESOLVE_REF_ALLOW_BAD_NAME) ||
|
if (!(resolve_flags & RESOLVE_REF_ALLOW_BAD_NAME) ||
|
||||||
!refname_is_safe(refname)) {
|
!refname_is_safe(refname))
|
||||||
*failure_errno = EINVAL;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* dwim_ref() uses REF_ISBROKEN to distinguish between
|
* dwim_ref() uses REF_ISBROKEN to distinguish between
|
||||||
|
@ -1718,9 +1706,10 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
|
||||||
|
|
||||||
for (symref_count = 0; symref_count < SYMREF_MAXDEPTH; symref_count++) {
|
for (symref_count = 0; symref_count < SYMREF_MAXDEPTH; symref_count++) {
|
||||||
unsigned int read_flags = 0;
|
unsigned int read_flags = 0;
|
||||||
|
int failure_errno;
|
||||||
|
|
||||||
if (refs_read_raw_ref(refs, refname, oid, &sb_refname,
|
if (refs_read_raw_ref(refs, refname, oid, &sb_refname,
|
||||||
&read_flags, failure_errno)) {
|
&read_flags, &failure_errno)) {
|
||||||
*flags |= read_flags;
|
*flags |= read_flags;
|
||||||
|
|
||||||
/* In reading mode, refs must eventually resolve */
|
/* In reading mode, refs must eventually resolve */
|
||||||
|
@ -1732,9 +1721,9 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
|
||||||
* may show errors besides ENOENT if there are
|
* may show errors besides ENOENT if there are
|
||||||
* similarly-named refs.
|
* similarly-named refs.
|
||||||
*/
|
*/
|
||||||
if (*failure_errno != ENOENT &&
|
if (failure_errno != ENOENT &&
|
||||||
*failure_errno != EISDIR &&
|
failure_errno != EISDIR &&
|
||||||
*failure_errno != ENOTDIR)
|
failure_errno != ENOTDIR)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
oidclr(oid);
|
oidclr(oid);
|
||||||
|
@ -1760,16 +1749,13 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
|
||||||
}
|
}
|
||||||
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
|
if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) {
|
||||||
if (!(resolve_flags & RESOLVE_REF_ALLOW_BAD_NAME) ||
|
if (!(resolve_flags & RESOLVE_REF_ALLOW_BAD_NAME) ||
|
||||||
!refname_is_safe(refname)) {
|
!refname_is_safe(refname))
|
||||||
*failure_errno = EINVAL;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
*flags |= REF_ISBROKEN | REF_BAD_NAME;
|
*flags |= REF_ISBROKEN | REF_BAD_NAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*failure_errno = ELOOP;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1784,10 +1770,8 @@ int refs_init_db(struct strbuf *err)
|
||||||
const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
|
const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
|
||||||
struct object_id *oid, int *flags)
|
struct object_id *oid, int *flags)
|
||||||
{
|
{
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
return refs_resolve_ref_unsafe(get_main_ref_store(the_repository), refname,
|
return refs_resolve_ref_unsafe(get_main_ref_store(the_repository), refname,
|
||||||
resolve_flags, oid, flags, &ignore_errno);
|
resolve_flags, oid, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int resolve_gitlink_ref(const char *submodule, const char *refname,
|
int resolve_gitlink_ref(const char *submodule, const char *refname,
|
||||||
|
@ -1795,15 +1779,14 @@ int resolve_gitlink_ref(const char *submodule, const char *refname,
|
||||||
{
|
{
|
||||||
struct ref_store *refs;
|
struct ref_store *refs;
|
||||||
int flags;
|
int flags;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
refs = get_submodule_ref_store(submodule);
|
refs = get_submodule_ref_store(submodule);
|
||||||
|
|
||||||
if (!refs)
|
if (!refs)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &flags,
|
if (!refs_resolve_ref_unsafe(refs, refname, 0, oid, &flags) ||
|
||||||
&ignore_errno) || is_null_oid(oid))
|
is_null_oid(oid))
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
7
refs.h
7
refs.h
|
@ -58,11 +58,6 @@ struct worktree;
|
||||||
* resolved. The function returns NULL for such ref names.
|
* resolved. The function returns NULL for such ref names.
|
||||||
* Caps and underscores refers to the special refs, such as HEAD,
|
* Caps and underscores refers to the special refs, such as HEAD,
|
||||||
* FETCH_HEAD and friends, that all live outside of the refs/ directory.
|
* FETCH_HEAD and friends, that all live outside of the refs/ directory.
|
||||||
*
|
|
||||||
* Callers should not inspect "errno" on failure, but rather pass in a
|
|
||||||
* "failure_errno" parameter, on failure the "errno" will indicate the
|
|
||||||
* type of failure encountered, but not necessarily one that came from
|
|
||||||
* a syscall. We might have faked it up.
|
|
||||||
*/
|
*/
|
||||||
#define RESOLVE_REF_READING 0x01
|
#define RESOLVE_REF_READING 0x01
|
||||||
#define RESOLVE_REF_NO_RECURSE 0x02
|
#define RESOLVE_REF_NO_RECURSE 0x02
|
||||||
|
@ -72,7 +67,7 @@ const char *refs_resolve_ref_unsafe(struct ref_store *refs,
|
||||||
const char *refname,
|
const char *refname,
|
||||||
int resolve_flags,
|
int resolve_flags,
|
||||||
struct object_id *oid,
|
struct object_id *oid,
|
||||||
int *flags, int *failure_errno);
|
int *flags);
|
||||||
|
|
||||||
const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
|
const char *resolve_ref_unsafe(const char *refname, int resolve_flags,
|
||||||
struct object_id *oid, int *flags);
|
struct object_id *oid, int *flags);
|
||||||
|
|
|
@ -277,11 +277,10 @@ static void loose_fill_ref_dir(struct ref_store *ref_store,
|
||||||
create_dir_entry(dir->cache, refname.buf,
|
create_dir_entry(dir->cache, refname.buf,
|
||||||
refname.len));
|
refname.len));
|
||||||
} else {
|
} else {
|
||||||
int ignore_errno;
|
|
||||||
if (!refs_resolve_ref_unsafe(&refs->base,
|
if (!refs_resolve_ref_unsafe(&refs->base,
|
||||||
refname.buf,
|
refname.buf,
|
||||||
RESOLVE_REF_READING,
|
RESOLVE_REF_READING,
|
||||||
&oid, &flag, &ignore_errno)) {
|
&oid, &flag)) {
|
||||||
oidclr(&oid);
|
oidclr(&oid);
|
||||||
flag |= REF_ISBROKEN;
|
flag |= REF_ISBROKEN;
|
||||||
} else if (is_null_oid(&oid)) {
|
} else if (is_null_oid(&oid)) {
|
||||||
|
@ -1006,7 +1005,6 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,
|
||||||
{
|
{
|
||||||
struct strbuf ref_file = STRBUF_INIT;
|
struct strbuf ref_file = STRBUF_INIT;
|
||||||
struct ref_lock *lock;
|
struct ref_lock *lock;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
files_assert_main_repository(refs, "lock_ref_oid_basic");
|
files_assert_main_repository(refs, "lock_ref_oid_basic");
|
||||||
assert(err);
|
assert(err);
|
||||||
|
@ -1034,7 +1032,7 @@ static struct ref_lock *lock_ref_oid_basic(struct files_ref_store *refs,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!refs_resolve_ref_unsafe(&refs->base, lock->ref_name, 0,
|
if (!refs_resolve_ref_unsafe(&refs->base, lock->ref_name, 0,
|
||||||
&lock->old_oid, NULL, &ignore_errno))
|
&lock->old_oid, NULL))
|
||||||
oidclr(&lock->old_oid);
|
oidclr(&lock->old_oid);
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -1399,7 +1397,6 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
|
||||||
struct strbuf tmp_renamed_log = STRBUF_INIT;
|
struct strbuf tmp_renamed_log = STRBUF_INIT;
|
||||||
int log, ret;
|
int log, ret;
|
||||||
struct strbuf err = STRBUF_INIT;
|
struct strbuf err = STRBUF_INIT;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
files_reflog_path(refs, &sb_oldref, oldrefname);
|
files_reflog_path(refs, &sb_oldref, oldrefname);
|
||||||
files_reflog_path(refs, &sb_newref, newrefname);
|
files_reflog_path(refs, &sb_newref, newrefname);
|
||||||
|
@ -1413,7 +1410,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
|
||||||
|
|
||||||
if (!refs_resolve_ref_unsafe(&refs->base, oldrefname,
|
if (!refs_resolve_ref_unsafe(&refs->base, oldrefname,
|
||||||
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
|
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
|
||||||
&orig_oid, &flag, &ignore_errno)) {
|
&orig_oid, &flag)) {
|
||||||
ret = error("refname %s not found", oldrefname);
|
ret = error("refname %s not found", oldrefname);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1459,7 +1456,7 @@ static int files_copy_or_rename_ref(struct ref_store *ref_store,
|
||||||
*/
|
*/
|
||||||
if (!copy && refs_resolve_ref_unsafe(&refs->base, newrefname,
|
if (!copy && refs_resolve_ref_unsafe(&refs->base, newrefname,
|
||||||
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
|
RESOLVE_REF_READING | RESOLVE_REF_NO_RECURSE,
|
||||||
NULL, NULL, &ignore_errno) &&
|
NULL, NULL) &&
|
||||||
refs_delete_ref(&refs->base, NULL, newrefname,
|
refs_delete_ref(&refs->base, NULL, newrefname,
|
||||||
NULL, REF_NO_DEREF)) {
|
NULL, REF_NO_DEREF)) {
|
||||||
if (errno == EISDIR) {
|
if (errno == EISDIR) {
|
||||||
|
@ -1828,12 +1825,10 @@ static int commit_ref_update(struct files_ref_store *refs,
|
||||||
*/
|
*/
|
||||||
int head_flag;
|
int head_flag;
|
||||||
const char *head_ref;
|
const char *head_ref;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
|
head_ref = refs_resolve_ref_unsafe(&refs->base, "HEAD",
|
||||||
RESOLVE_REF_READING,
|
RESOLVE_REF_READING,
|
||||||
NULL, &head_flag,
|
NULL, &head_flag);
|
||||||
&ignore_errno);
|
|
||||||
if (head_ref && (head_flag & REF_ISSYMREF) &&
|
if (head_ref && (head_flag & REF_ISSYMREF) &&
|
||||||
!strcmp(head_ref, lock->ref_name)) {
|
!strcmp(head_ref, lock->ref_name)) {
|
||||||
struct strbuf log_err = STRBUF_INIT;
|
struct strbuf log_err = STRBUF_INIT;
|
||||||
|
@ -1877,12 +1872,10 @@ static void update_symref_reflog(struct files_ref_store *refs,
|
||||||
{
|
{
|
||||||
struct strbuf err = STRBUF_INIT;
|
struct strbuf err = STRBUF_INIT;
|
||||||
struct object_id new_oid;
|
struct object_id new_oid;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
if (logmsg &&
|
if (logmsg &&
|
||||||
refs_resolve_ref_unsafe(&refs->base, target,
|
refs_resolve_ref_unsafe(&refs->base, target,
|
||||||
RESOLVE_REF_READING, &new_oid, NULL,
|
RESOLVE_REF_READING, &new_oid, NULL) &&
|
||||||
&ignore_errno) &&
|
|
||||||
files_log_ref_write(refs, refname, &lock->old_oid,
|
files_log_ref_write(refs, refname, &lock->old_oid,
|
||||||
&new_oid, logmsg, 0, &err)) {
|
&new_oid, logmsg, 0, &err)) {
|
||||||
error("%s", err.buf);
|
error("%s", err.buf);
|
||||||
|
@ -2156,7 +2149,6 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
|
||||||
(struct files_reflog_iterator *)ref_iterator;
|
(struct files_reflog_iterator *)ref_iterator;
|
||||||
struct dir_iterator *diter = iter->dir_iterator;
|
struct dir_iterator *diter = iter->dir_iterator;
|
||||||
int ok;
|
int ok;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
while ((ok = dir_iterator_advance(diter)) == ITER_OK) {
|
while ((ok = dir_iterator_advance(diter)) == ITER_OK) {
|
||||||
int flags;
|
int flags;
|
||||||
|
@ -2170,8 +2162,7 @@ static int files_reflog_iterator_advance(struct ref_iterator *ref_iterator)
|
||||||
|
|
||||||
if (!refs_resolve_ref_unsafe(iter->ref_store,
|
if (!refs_resolve_ref_unsafe(iter->ref_store,
|
||||||
diter->relative_path, 0,
|
diter->relative_path, 0,
|
||||||
&iter->oid, &flags,
|
&iter->oid, &flags)) {
|
||||||
&ignore_errno)) {
|
|
||||||
error("bad ref for %s", diter->path.buf);
|
error("bad ref for %s", diter->path.buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2515,11 +2506,9 @@ static int lock_ref_for_update(struct files_ref_store *refs,
|
||||||
* the transaction, so we have to read it here
|
* the transaction, so we have to read it here
|
||||||
* to record and possibly check old_oid:
|
* to record and possibly check old_oid:
|
||||||
*/
|
*/
|
||||||
int ignore_errno;
|
|
||||||
if (!refs_resolve_ref_unsafe(&refs->base,
|
if (!refs_resolve_ref_unsafe(&refs->base,
|
||||||
referent.buf, 0,
|
referent.buf, 0,
|
||||||
&lock->old_oid, NULL,
|
&lock->old_oid, NULL)) {
|
||||||
&ignore_errno)) {
|
|
||||||
if (update->flags & REF_HAVE_OLD) {
|
if (update->flags & REF_HAVE_OLD) {
|
||||||
strbuf_addf(err, "cannot lock ref '%s': "
|
strbuf_addf(err, "cannot lock ref '%s': "
|
||||||
"error reading reference",
|
"error reading reference",
|
||||||
|
@ -3208,14 +3197,12 @@ static int files_reflog_expire(struct ref_store *ref_store,
|
||||||
|
|
||||||
if ((expire_flags & EXPIRE_REFLOGS_UPDATE_REF) &&
|
if ((expire_flags & EXPIRE_REFLOGS_UPDATE_REF) &&
|
||||||
!is_null_oid(&cb.last_kept_oid)) {
|
!is_null_oid(&cb.last_kept_oid)) {
|
||||||
int ignore_errno;
|
|
||||||
int type;
|
int type;
|
||||||
const char *ref;
|
const char *ref;
|
||||||
|
|
||||||
ref = refs_resolve_ref_unsafe(&refs->base, refname,
|
ref = refs_resolve_ref_unsafe(&refs->base, refname,
|
||||||
RESOLVE_REF_NO_RECURSE,
|
RESOLVE_REF_NO_RECURSE,
|
||||||
NULL, &type,
|
NULL, &type);
|
||||||
&ignore_errno);
|
|
||||||
update = !!(ref && !(type & REF_ISSYMREF));
|
update = !!(ref && !(type & REF_ISSYMREF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
remote.c
3
remote.c
|
@ -508,9 +508,8 @@ static void read_config(struct repository *repo)
|
||||||
|
|
||||||
repo->remote_state->current_branch = NULL;
|
repo->remote_state->current_branch = NULL;
|
||||||
if (startup_info->have_repository) {
|
if (startup_info->have_repository) {
|
||||||
int ignore_errno;
|
|
||||||
const char *head_ref = refs_resolve_ref_unsafe(
|
const char *head_ref = refs_resolve_ref_unsafe(
|
||||||
get_main_ref_store(repo), "HEAD", 0, NULL, &flag, &ignore_errno);
|
get_main_ref_store(repo), "HEAD", 0, NULL, &flag);
|
||||||
if (head_ref && (flag & REF_ISSYMREF) &&
|
if (head_ref && (flag & REF_ISSYMREF) &&
|
||||||
skip_prefix(head_ref, "refs/heads/", &head_ref)) {
|
skip_prefix(head_ref, "refs/heads/", &head_ref)) {
|
||||||
repo->remote_state->current_branch = make_branch(
|
repo->remote_state->current_branch = make_branch(
|
||||||
|
|
10
sequencer.c
10
sequencer.c
|
@ -1281,7 +1281,6 @@ void print_commit_summary(struct repository *r,
|
||||||
struct strbuf author_ident = STRBUF_INIT;
|
struct strbuf author_ident = STRBUF_INIT;
|
||||||
struct strbuf committer_ident = STRBUF_INIT;
|
struct strbuf committer_ident = STRBUF_INIT;
|
||||||
struct ref_store *refs;
|
struct ref_store *refs;
|
||||||
int resolve_errno;
|
|
||||||
|
|
||||||
commit = lookup_commit(r, oid);
|
commit = lookup_commit(r, oid);
|
||||||
if (!commit)
|
if (!commit)
|
||||||
|
@ -1332,12 +1331,9 @@ void print_commit_summary(struct repository *r,
|
||||||
diff_setup_done(&rev.diffopt);
|
diff_setup_done(&rev.diffopt);
|
||||||
|
|
||||||
refs = get_main_ref_store(the_repository);
|
refs = get_main_ref_store(the_repository);
|
||||||
head = refs_resolve_ref_unsafe(refs, "HEAD", 0, NULL, NULL,
|
head = refs_resolve_ref_unsafe(refs, "HEAD", 0, NULL, NULL);
|
||||||
&resolve_errno);
|
if (!head)
|
||||||
if (!head) {
|
die(_("unable to resolve HEAD after creating commit"));
|
||||||
errno = resolve_errno;
|
|
||||||
die_errno(_("unable to resolve HEAD after creating commit"));
|
|
||||||
}
|
|
||||||
if (!strcmp(head, "HEAD"))
|
if (!strcmp(head, "HEAD"))
|
||||||
head = _("detached HEAD");
|
head = _("detached HEAD");
|
||||||
else
|
else
|
||||||
|
|
|
@ -180,10 +180,9 @@ static int cmd_resolve_ref(struct ref_store *refs, const char **argv)
|
||||||
int resolve_flags = arg_flags(*argv++, "resolve-flags", empty_flags);
|
int resolve_flags = arg_flags(*argv++, "resolve-flags", empty_flags);
|
||||||
int flags;
|
int flags;
|
||||||
const char *ref;
|
const char *ref;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
ref = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
|
ref = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
|
||||||
&oid, &flags, &ignore_errno);
|
&oid, &flags);
|
||||||
printf("%s %s 0x%x\n", oid_to_hex(&oid), ref ? ref : "(null)", flags);
|
printf("%s %s 0x%x\n", oid_to_hex(&oid), ref ? ref : "(null)", flags);
|
||||||
return ref ? 0 : 1;
|
return ref ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
11
worktree.c
11
worktree.c
|
@ -28,13 +28,11 @@ static void add_head_info(struct worktree *wt)
|
||||||
{
|
{
|
||||||
int flags;
|
int flags;
|
||||||
const char *target;
|
const char *target;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
target = refs_resolve_ref_unsafe(get_worktree_ref_store(wt),
|
target = refs_resolve_ref_unsafe(get_worktree_ref_store(wt),
|
||||||
"HEAD",
|
"HEAD",
|
||||||
0,
|
0,
|
||||||
&wt->head_oid, &flags,
|
&wt->head_oid, &flags);
|
||||||
&ignore_errno);
|
|
||||||
if (!target)
|
if (!target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -416,7 +414,6 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
|
||||||
const char *symref_target;
|
const char *symref_target;
|
||||||
struct ref_store *refs;
|
struct ref_store *refs;
|
||||||
int flags;
|
int flags;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
if (wt->is_bare)
|
if (wt->is_bare)
|
||||||
continue;
|
continue;
|
||||||
|
@ -434,8 +431,7 @@ const struct worktree *find_shared_symref(struct worktree **worktrees,
|
||||||
|
|
||||||
refs = get_worktree_ref_store(wt);
|
refs = get_worktree_ref_store(wt);
|
||||||
symref_target = refs_resolve_ref_unsafe(refs, symref, 0,
|
symref_target = refs_resolve_ref_unsafe(refs, symref, 0,
|
||||||
NULL, &flags,
|
NULL, &flags);
|
||||||
&ignore_errno);
|
|
||||||
if ((flags & REF_ISSYMREF) &&
|
if ((flags & REF_ISSYMREF) &&
|
||||||
symref_target && !strcmp(symref_target, target)) {
|
symref_target && !strcmp(symref_target, target)) {
|
||||||
existing = wt;
|
existing = wt;
|
||||||
|
@ -563,7 +559,6 @@ int other_head_refs(each_ref_fn fn, void *cb_data)
|
||||||
struct worktree *wt = *p;
|
struct worktree *wt = *p;
|
||||||
struct object_id oid;
|
struct object_id oid;
|
||||||
int flag;
|
int flag;
|
||||||
int ignore_errno;
|
|
||||||
|
|
||||||
if (wt->is_current)
|
if (wt->is_current)
|
||||||
continue;
|
continue;
|
||||||
|
@ -573,7 +568,7 @@ int other_head_refs(each_ref_fn fn, void *cb_data)
|
||||||
if (refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
|
if (refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
|
||||||
refname.buf,
|
refname.buf,
|
||||||
RESOLVE_REF_READING,
|
RESOLVE_REF_READING,
|
||||||
&oid, &flag, &ignore_errno))
|
&oid, &flag))
|
||||||
ret = fn(refname.buf, &oid, flag, cb_data);
|
ret = fn(refname.buf, &oid, flag, cb_data);
|
||||||
if (ret)
|
if (ret)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue