Merge branch 'fc/oid-quietly-parse-upstream'
"git rev-parse --quiet foo@{u}", or anything that asks @{u} to be parsed with GET_OID_QUIETLY option, did not quietly fail, which has been corrected. * fc/oid-quietly-parse-upstream: object-name: fix quiet @{u} parsing
This commit is contained in:
commit
8069aa01cd
@ -899,6 +899,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
|
|||||||
char *real_ref = NULL;
|
char *real_ref = NULL;
|
||||||
int refs_found = 0;
|
int refs_found = 0;
|
||||||
int at, reflog_len, nth_prior = 0;
|
int at, reflog_len, nth_prior = 0;
|
||||||
|
int fatal = !(flags & GET_OID_QUIETLY);
|
||||||
|
|
||||||
if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) {
|
if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) {
|
||||||
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
|
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
|
||||||
@ -953,11 +954,11 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
|
|||||||
|
|
||||||
if (!len && reflog_len)
|
if (!len && reflog_len)
|
||||||
/* allow "@{...}" to mean the current branch reflog */
|
/* allow "@{...}" to mean the current branch reflog */
|
||||||
refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, 0);
|
refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, !fatal);
|
||||||
else if (reflog_len)
|
else if (reflog_len)
|
||||||
refs_found = repo_dwim_log(r, str, len, oid, &real_ref);
|
refs_found = repo_dwim_log(r, str, len, oid, &real_ref);
|
||||||
else
|
else
|
||||||
refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, 0);
|
refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, !fatal);
|
||||||
|
|
||||||
if (!refs_found)
|
if (!refs_found)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -183,6 +183,11 @@ test_expect_success '@{u} error message when no upstream' '
|
|||||||
test_cmp expect actual
|
test_cmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success '@{u} silent error when no upstream' '
|
||||||
|
test_must_fail git rev-parse --verify --quiet @{u} 2>actual &&
|
||||||
|
test_must_be_empty actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'branch@{u} error message with misspelt branch' '
|
test_expect_success 'branch@{u} error message with misspelt branch' '
|
||||||
cat >expect <<-EOF &&
|
cat >expect <<-EOF &&
|
||||||
fatal: no such branch: ${SQ}no-such-branch${SQ}
|
fatal: no such branch: ${SQ}no-such-branch${SQ}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user