| 11 | #include "strbuf.h" |
| 12 | |
| 13 | static int notes_cache_match_validity(struct repository *r, |
| 14 | const char *ref, |
| 15 | const char *validity) |
| 16 | { |
| 17 | struct object_id oid; |
| 18 | struct commit *commit; |
| 19 | struct pretty_print_context pretty_ctx; |
| 20 | struct strbuf msg = STRBUF_INIT; |
| 21 | int ret; |
| 22 | |
| 23 | if (refs_read_ref(get_main_ref_store(the_repository), ref, &oid) < 0) |
| 24 | return 0; |
| 25 | |
| 26 | commit = lookup_commit_reference_gently(r, &oid, 1); |
| 27 | if (!commit) |
| 28 | return 0; |
| 29 | |
| 30 | memset(&pretty_ctx, 0, sizeof(pretty_ctx)); |
| 31 | repo_format_commit_message(r, commit, "%s", &msg, |
| 32 | &pretty_ctx); |
| 33 | strbuf_trim(&msg); |
| 34 | |
| 35 | ret = !strcmp(msg.buf, validity); |
| 36 | strbuf_release(&msg); |
| 37 | |
| 38 | return ret; |
| 39 | } |
| 40 | |
| 41 | void notes_cache_init(struct repository *r, struct notes_cache *c, |
| 42 | const char *name, const char *validity) |
no test coverage detected