diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-11-15 12:04:52 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-11-15 12:04:52 +0900 |
commit | 9fbcb51ec548318f0088a5fee6c77a5f1d8512b4 (patch) | |
tree | 548dfa2d249d03ddb7bec8653d8e596727bf94ae | |
parent | bb2c9262a5eff9e4d6ddca23f6e0787afbd7b091 (diff) | |
parent | dbd2b55cb7b06e94096b8c18852a94732e3f76a8 (diff) | |
download | git-9fbcb51ec548318f0088a5fee6c77a5f1d8512b4.tar.gz |
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
-rw-r--r-- | builtin/remote.c | 2 | ||||
-rw-r--r-- | log-tree.c | 2 | ||||
-rw-r--r-- | t/helper/test-ref-store.c | 2 | ||||
-rw-r--r-- | worktree.c | 3 |
4 files changed, 5 insertions, 4 deletions
diff --git a/builtin/remote.c b/builtin/remote.c index 4f5cac96b0..bc89623695 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -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; diff --git a/log-tree.c b/log-tree.c index cea056234d..580b3a98a0 100644 --- a/log-tree.c +++ b/log-tree.c @@ -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/")) diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 05d8c4d8af..6ec2670044 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -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; } diff --git a/worktree.c b/worktree.c index 70015629dc..f8c40f2f5f 100644 --- a/worktree.c +++ b/worktree.c @@ -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; } |