- if (!all && strncmp(path, "refs/tags/", 10))
- return 0;
- add_to_known_names(path, commit);
+ object = parse_object(sha1);
+ /* If --all, then any refs are used.
+ * If --tags, then any tags are used.
+ * Otherwise only annotated tags are used.
+ */
+ if (!strncmp(path, "refs/tags/", 10)) {
+ if (object->type == tag_type)
+ prio = 2;
+ else
+ prio = 1;
+ }
+ else
+ prio = 0;
+
+ if (!all) {
+ if (!prio)
+ return 0;
+ if (!tags && prio < 2)
+ return 0;
+ }
+ add_to_known_names(all ? path + 5 : path + 10, commit, prio);