Skip to content

Commit 6c6a79c

Browse files
committed
Merge branch 'fc/oid-quietly-parse-upstream' into seen
* fc/oid-quietly-parse-upstream: object-name: fix quiet @{u} parsing
2 parents 868e255 + dfbfdc5 commit 6c6a79c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

object-name.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
901901
char *real_ref = NULL;
902902
int refs_found = 0;
903903
int at, reflog_len, nth_prior = 0;
904+
int fatal = !(flags & GET_OID_QUIETLY);
904905

905906
if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) {
906907
if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) {
@@ -955,11 +956,11 @@ static int get_oid_basic(struct repository *r, const char *str, int len,
955956

956957
if (!len && reflog_len)
957958
/* allow "@{...}" to mean the current branch reflog */
958-
refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, 0);
959+
refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref, !fatal);
959960
else if (reflog_len)
960961
refs_found = repo_dwim_log(r, str, len, oid, &real_ref);
961962
else
962-
refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, 0);
963+
refs_found = repo_dwim_ref(r, str, len, oid, &real_ref, !fatal);
963964

964965
if (!refs_found)
965966
return -1;

t/t1507-rev-parse-upstream.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ test_expect_success '@{u} error message when no upstream' '
183183
test_cmp expect actual
184184
'
185185

186+
test_expect_success '@{u} silent error when no upstream' '
187+
test_must_fail git rev-parse --verify --quiet @{u} 2>actual &&
188+
test_must_be_empty actual
189+
'
190+
186191
test_expect_success 'branch@{u} error message with misspelt branch' '
187192
cat >expect <<-EOF &&
188193
fatal: no such branch: ${SQ}no-such-branch${SQ}

0 commit comments

Comments
 (0)