提交 9fbcb51e 编写于 作者: J Junio C Hamano

Merge branch 'jk/misc-resolve-ref-unsafe-fixes' into maint

Some codepaths did not check for errors when asking what branch the
HEAD points at, which have been fixed.

* jk/misc-resolve-ref-unsafe-fixes:
  worktree: handle broken symrefs in find_shared_symref()
  log: handle broken HEAD in decoration check
  remote: handle broken symrefs
  test-ref-store: avoid passing NULL to printf
......@@ -565,7 +565,7 @@ static int read_remote_branches(const char *refname,
item = string_list_append(rename->remote_branches, xstrdup(refname));
symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING,
NULL, &flag);
if (flag & REF_ISSYMREF)
if (symref && (flag & REF_ISSYMREF))
item->util = xstrdup(symref);
else
item->util = NULL;
......
......@@ -198,7 +198,7 @@ static const struct name_decoration *current_pointed_by_HEAD(const struct name_d
/* Now resolve and find the matching current branch */
branch_name = resolve_ref_unsafe("HEAD", 0, NULL, &rru_flags);
if (!(rru_flags & REF_ISSYMREF))
if (!branch_name || !(rru_flags & REF_ISSYMREF))
return NULL;
if (!starts_with(branch_name, "refs/"))
......
......@@ -135,7 +135,7 @@ static int cmd_resolve_ref(struct ref_store *refs, const char **argv)
ref = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
sha1, &flags);
printf("%s %s 0x%x\n", sha1_to_hex(sha1), ref, flags);
printf("%s %s 0x%x\n", sha1_to_hex(sha1), ref ? ref : "(null)", flags);
return ref ? 0 : 1;
}
......
......@@ -327,7 +327,8 @@ const struct worktree *find_shared_symref(const char *symref,
refs = get_worktree_ref_store(wt);
symref_target = refs_resolve_ref_unsafe(refs, symref, 0,
NULL, &flags);
if ((flags & REF_ISSYMREF) && !strcmp(symref_target, target)) {
if ((flags & REF_ISSYMREF) &&
symref_target && !strcmp(symref_target, target)) {
existing = wt;
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册