| 1861 | } |
| 1862 | |
| 1863 | const char *branch_get_upstream(struct branch *branch, struct strbuf *err) |
| 1864 | { |
| 1865 | if (!branch) |
| 1866 | return error_buf(err, _("HEAD does not point to a branch")); |
| 1867 | |
| 1868 | if (!branch->merge || !branch->merge[0]) { |
| 1869 | /* |
| 1870 | * no merge config; is it because the user didn't define any, |
| 1871 | * or because it is not a real branch, and get_branch |
| 1872 | * auto-vivified it? |
| 1873 | */ |
| 1874 | if (!refs_ref_exists(get_main_ref_store(the_repository), branch->refname)) |
| 1875 | return error_buf(err, _("no such branch: '%s'"), |
| 1876 | branch->name); |
| 1877 | return error_buf(err, |
| 1878 | _("no upstream configured for branch '%s'"), |
| 1879 | branch->name); |
| 1880 | } |
| 1881 | |
| 1882 | if (!branch->merge[0]->dst) |
| 1883 | return error_buf(err, |
| 1884 | _("upstream branch '%s' not stored as a remote-tracking branch"), |
| 1885 | branch->merge[0]->src); |
| 1886 | |
| 1887 | return branch->merge[0]->dst; |
| 1888 | } |
| 1889 | |
| 1890 | static char *tracking_for_push_dest(struct remote *remote, |
| 1891 | const char *refname, |
no test coverage detected