[PATCH v2 1/2] t5516: introduce 'push ref expression with non-existent oid src'
From: Denton Liu <hidden>
Date: 2025-08-05 06:24:41
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Denton Liu <hidden>
Date: 2025-08-05 06:24:41
Subsystem:
the rest · Maintainer:
Linus Torvalds
It is possible to trigger a Git bug by pushing a refspec where the
source is an oid that's non-existent. An example of the error message
produced is as follows:
error: The destination you provided is not a full refname (i.e.,
starting with "refs/"). We tried to guess what you meant by:
- Looking for a ref that matches 'branch' on the remote side.
- Checking if the <src> being pushed ('0000000000000000000000000000000000000001')
is a ref in "refs/{heads,tags}/". If so we add a corresponding
refs/{heads,tags}/ prefix on the remote side.
Neither worked, so we gave up. You must fully qualify the ref.
BUG: remote.c:1221: '0000000000000000000000000000000000000001' should be commit/tag/tree/blob, is '-1'
fatal: the remote end hung up unexpectedly
Aborted (core dumped)
Document this failure in a test case so that it can be confirmed fixed
later.
Signed-off-by: Denton Liu <redacted>
---
t/t5516-fetch-push.sh | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 4e9c27b0f2..c2fcfeca92 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh@@ -509,6 +509,13 @@ test_expect_success 'push ref expression with non-existent, incomplete dest' ' ' +test_expect_failure 'push ref expression with non-existent oid src' ' + + mk_test testrepo && + test_must_fail git push testrepo $(test_oid 001):branch + +' + for head in HEAD @ do
--
2.50.1