diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-01-07 12:40:59 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-01-07 12:41:00 -0800 |
commit | da178ac793047c41e4806a3c32fb421992642683 (patch) | |
tree | 65b6053da74fc52bccd25efe3687b71c3af57dd4 /remote.c | |
parent | c5b9256360b06efb9453c1627b78b14598e288b8 (diff) | |
parent | 05e73682cd28eeaf6d949badefd85b94244fca3f (diff) | |
download | git-da178ac793047c41e4806a3c32fb421992642683.tar.gz git-da178ac793047c41e4806a3c32fb421992642683.tar.xz |
Merge branch 'jc/checkout-local-track-report'
The report from "git checkout" on a branch that builds on another
local branch by setting its branch.*.merge to branch name (not a
full refname) incorrectly said that the upstream is gone.
* jc/checkout-local-track-report:
checkout: report upstream correctly even with loosely defined branch.*.merge
Diffstat (limited to 'remote.c')
-rw-r--r-- | remote.c | 34 |
1 files changed, 23 insertions, 11 deletions
@@ -1631,6 +1631,27 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror, } } +static void set_merge(struct branch *ret) +{ + char *ref; + unsigned char sha1[20]; + int i; + + ret->merge = xcalloc(ret->merge_nr, sizeof(*ret->merge)); + for (i = 0; i < ret->merge_nr; i++) { + ret->merge[i] = xcalloc(1, sizeof(**ret->merge)); + ret->merge[i]->src = xstrdup(ret->merge_name[i]); + if (!remote_find_tracking(ret->remote, ret->merge[i]) || + strcmp(ret->remote_name, ".")) + continue; + if (dwim_ref(ret->merge_name[i], strlen(ret->merge_name[i]), + sha1, &ref) == 1) + ret->merge[i]->dst = ref; + else + ret->merge[i]->dst = xstrdup(ret->merge_name[i]); + } +} + struct branch *branch_get(const char *name) { struct branch *ret; @@ -1642,17 +1663,8 @@ struct branch *branch_get(const char *name) ret = make_branch(name, 0); if (ret && ret->remote_name) { ret->remote = remote_get(ret->remote_name); - if (ret->merge_nr) { - int i; - ret->merge = xcalloc(ret->merge_nr, sizeof(*ret->merge)); - for (i = 0; i < ret->merge_nr; i++) { - ret->merge[i] = xcalloc(1, sizeof(**ret->merge)); - ret->merge[i]->src = xstrdup(ret->merge_name[i]); - if (remote_find_tracking(ret->remote, ret->merge[i]) - && !strcmp(ret->remote_name, ".")) - ret->merge[i]->dst = xstrdup(ret->merge_name[i]); - } - } + if (ret->merge_nr) + set_merge(ret); } return ret; } |