| 666 | static int interpret_nth_prior_checkout(struct repository *r, const char *name, int namelen, struct strbuf *buf); |
| 667 | |
| 668 | static int get_oid_basic(struct repository *r, const char *str, int len, |
| 669 | struct object_id *oid, unsigned int flags) |
| 670 | { |
| 671 | static const char *warn_msg = "refname '%.*s' is ambiguous."; |
| 672 | static const char *object_name_msg = N_( |
| 673 | "Git normally never creates a ref that ends with 40 hex characters\n" |
| 674 | "because it will be ignored when you just specify 40-hex. These refs\n" |
| 675 | "may be created by mistake. For example,\n" |
| 676 | "\n" |
| 677 | " git switch -c $br $(git rev-parse ...)\n" |
| 678 | "\n" |
| 679 | "where \"$br\" is somehow empty and a 40-hex ref is created. Please\n" |
| 680 | "examine these refs and maybe delete them. Turn this message off by\n" |
| 681 | "running \"git config set advice.objectNameWarning false\""); |
| 682 | struct object_id tmp_oid; |
| 683 | char *real_ref = NULL; |
| 684 | int refs_found = 0; |
| 685 | int at, reflog_len, nth_prior = 0; |
| 686 | int fatal = !(flags & GET_OID_QUIETLY); |
| 687 | struct repo_config_values *cfg = repo_config_values(the_repository); |
| 688 | |
| 689 | if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) { |
| 690 | if (!(flags & GET_OID_SKIP_AMBIGUITY_CHECK) && |
| 691 | repo_settings_get_warn_ambiguous_refs(r) && |
| 692 | cfg->warn_on_object_refname_ambiguity) { |
| 693 | refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref, 0); |
| 694 | if (refs_found > 0) { |
| 695 | warning(warn_msg, len, str); |
| 696 | if (advice_enabled(ADVICE_OBJECT_NAME_WARNING)) |
| 697 | fprintf(stderr, "%s\n", _(object_name_msg)); |
| 698 | } |
| 699 | free(real_ref); |
| 700 | } |
| 701 | return 0; |
| 702 | } |
| 703 | |
| 704 | /* basic@{time or number or -number} format to query ref-log */ |
| 705 | reflog_len = at = 0; |
| 706 | if (len && str[len-1] == '}') { |
| 707 | for (at = len-4; at >= 0; at--) { |
| 708 | if (str[at] == '@' && str[at+1] == '{') { |
| 709 | if (str[at+2] == '-') { |
| 710 | if (at != 0) |
| 711 | /* @{-N} not at start */ |
| 712 | return -1; |
| 713 | nth_prior = 1; |
| 714 | continue; |
| 715 | } |
| 716 | if (!upstream_mark(str + at, len - at) && |
| 717 | !push_mark(str + at, len - at)) { |
| 718 | reflog_len = (len-1) - (at+2); |
| 719 | len = at; |
| 720 | } |
| 721 | break; |
| 722 | } |
| 723 | } |
| 724 | } |
| 725 |
no test coverage detected