зеркало из https://github.com/microsoft/git.git
Merge branch 'rr/die-on-missing-upstream' into maint
When a reflog notation is used for implicit "current branch", we did not say which branch, and worse said "branch ''". * rr/die-on-missing-upstream: sha1_name: fix error message for @{<N>}, @{<date>} sha1_name: fix error message for @{u}
This commit is contained in:
Коммит
b3bf469bf8
24
sha1_name.c
24
sha1_name.c
|
@ -517,12 +517,21 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
|
|||
}
|
||||
if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
|
||||
&co_time, &co_tz, &co_cnt)) {
|
||||
if (!len) {
|
||||
if (!prefixcmp(real_ref, "refs/heads/")) {
|
||||
str = real_ref + 11;
|
||||
len = strlen(real_ref + 11);
|
||||
} else {
|
||||
/* detached HEAD */
|
||||
str = "HEAD";
|
||||
len = 4;
|
||||
}
|
||||
}
|
||||
if (at_time)
|
||||
warning("Log for '%.*s' only goes "
|
||||
"back to %s.", len, str,
|
||||
show_date(co_time, co_tz, DATE_RFC2822));
|
||||
else {
|
||||
free(real_ref);
|
||||
die("Log for '%.*s' only has %d entries.",
|
||||
len, str, co_cnt);
|
||||
}
|
||||
|
@ -1033,14 +1042,15 @@ int interpret_branch_name(const char *name, struct strbuf *buf)
|
|||
* points to something different than a branch.
|
||||
*/
|
||||
if (!upstream)
|
||||
return error(_("HEAD does not point to a branch"));
|
||||
die(_("HEAD does not point to a branch"));
|
||||
if (!upstream->merge || !upstream->merge[0]->dst) {
|
||||
if (!ref_exists(upstream->refname))
|
||||
return error(_("No such branch: '%s'"), cp);
|
||||
if (!upstream->merge)
|
||||
return error(_("No upstream configured for branch '%s'"),
|
||||
upstream->name);
|
||||
return error(
|
||||
die(_("No such branch: '%s'"), cp);
|
||||
if (!upstream->merge) {
|
||||
die(_("No upstream configured for branch '%s'"),
|
||||
upstream->name);
|
||||
}
|
||||
die(
|
||||
_("Upstream branch '%s' not stored as a remote-tracking branch"),
|
||||
upstream->merge[0]->src);
|
||||
}
|
||||
|
|
|
@ -129,8 +129,7 @@ test_expect_success 'branch@{u} works when tracking a local branch' '
|
|||
|
||||
test_expect_success 'branch@{u} error message when no upstream' '
|
||||
cat >expect <<-EOF &&
|
||||
error: No upstream configured for branch ${sq}non-tracking${sq}
|
||||
fatal: Needed a single revision
|
||||
fatal: No upstream configured for branch ${sq}non-tracking${sq}
|
||||
EOF
|
||||
error_message non-tracking@{u} 2>actual &&
|
||||
test_i18ncmp expect actual
|
||||
|
@ -138,8 +137,7 @@ test_expect_success 'branch@{u} error message when no upstream' '
|
|||
|
||||
test_expect_success '@{u} error message when no upstream' '
|
||||
cat >expect <<-EOF &&
|
||||
error: No upstream configured for branch ${sq}master${sq}
|
||||
fatal: Needed a single revision
|
||||
fatal: No upstream configured for branch ${sq}master${sq}
|
||||
EOF
|
||||
test_must_fail git rev-parse --verify @{u} 2>actual &&
|
||||
test_i18ncmp expect actual
|
||||
|
@ -147,8 +145,7 @@ test_expect_success '@{u} error message when no upstream' '
|
|||
|
||||
test_expect_success 'branch@{u} error message with misspelt branch' '
|
||||
cat >expect <<-EOF &&
|
||||
error: No such branch: ${sq}no-such-branch${sq}
|
||||
fatal: Needed a single revision
|
||||
fatal: No such branch: ${sq}no-such-branch${sq}
|
||||
EOF
|
||||
error_message no-such-branch@{u} 2>actual &&
|
||||
test_i18ncmp expect actual
|
||||
|
@ -156,8 +153,7 @@ test_expect_success 'branch@{u} error message with misspelt branch' '
|
|||
|
||||
test_expect_success '@{u} error message when not on a branch' '
|
||||
cat >expect <<-EOF &&
|
||||
error: HEAD does not point to a branch
|
||||
fatal: Needed a single revision
|
||||
fatal: HEAD does not point to a branch
|
||||
EOF
|
||||
git checkout HEAD^0 &&
|
||||
test_must_fail git rev-parse --verify @{u} 2>actual &&
|
||||
|
@ -166,8 +162,7 @@ test_expect_success '@{u} error message when not on a branch' '
|
|||
|
||||
test_expect_success 'branch@{u} error message if upstream branch not fetched' '
|
||||
cat >expect <<-EOF &&
|
||||
error: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
|
||||
fatal: Needed a single revision
|
||||
fatal: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
|
||||
EOF
|
||||
error_message bad-upstream@{u} 2>actual &&
|
||||
test_i18ncmp expect actual
|
||||
|
|
Загрузка…
Ссылка в новой задаче