| 791 | } |
| 792 | |
| 793 | static void write_refspec_config(const char *src_ref_prefix, |
| 794 | const struct ref *our_head_points_at, |
| 795 | const struct ref *remote_head_points_at, |
| 796 | struct strbuf *branch_top) |
| 797 | { |
| 798 | struct strbuf key = STRBUF_INIT; |
| 799 | struct strbuf value = STRBUF_INIT; |
| 800 | |
| 801 | if (option_mirror || !option_bare) { |
| 802 | if (option_single_branch && !option_mirror) { |
| 803 | if (option_branch) { |
| 804 | if (starts_with(our_head_points_at->name, "refs/tags/")) |
| 805 | strbuf_addf(&value, "+%s:%s", our_head_points_at->name, |
| 806 | our_head_points_at->name); |
| 807 | else |
| 808 | strbuf_addf(&value, "+%s:%s%s", our_head_points_at->name, |
| 809 | branch_top->buf, option_branch); |
| 810 | } else if (remote_head_points_at) { |
| 811 | const char *head = remote_head_points_at->name; |
| 812 | if (!skip_prefix(head, "refs/heads/", &head)) |
| 813 | BUG("remote HEAD points at non-head?"); |
| 814 | |
| 815 | strbuf_addf(&value, "+%s:%s%s", remote_head_points_at->name, |
| 816 | branch_top->buf, head); |
| 817 | } |
| 818 | /* |
| 819 | * otherwise, the next "git fetch" will |
| 820 | * simply fetch from HEAD without updating |
| 821 | * any remote-tracking branch, which is what |
| 822 | * we want. |
| 823 | */ |
| 824 | } else { |
| 825 | strbuf_addf(&value, "+%s*:%s*", src_ref_prefix, branch_top->buf); |
| 826 | } |
| 827 | /* Configure the remote */ |
| 828 | if (value.len) { |
| 829 | strbuf_addf(&key, "remote.%s.fetch", remote_name); |
| 830 | repo_config_set_multivar(the_repository, key.buf, value.buf, "^$", 0); |
| 831 | strbuf_reset(&key); |
| 832 | |
| 833 | if (option_mirror) { |
| 834 | strbuf_addf(&key, "remote.%s.mirror", remote_name); |
| 835 | repo_config_set(the_repository, key.buf, "true"); |
| 836 | strbuf_reset(&key); |
| 837 | } |
| 838 | } |
| 839 | } |
| 840 | |
| 841 | strbuf_release(&key); |
| 842 | strbuf_release(&value); |
| 843 | } |
| 844 | |
| 845 | static void dissociate_from_references(void) |
| 846 | { |
no test coverage detected