Skip to content

Commit 4dac530

Browse files
Denton-Lgitster
authored andcommitted
remote.c: remove BUG in show_push_unqualified_ref_name_error()
When "git push <remote> <src>:<dst>" does not spell out the destination side of the ref fully, and when <src> is not given as a reference but an object name, the code tries to give advice messages based on the type of that object. The type is determined by calling odb_read_object_info() and signalled by its return value. The code however reported a programming error with BUG() when this function said that there is no such object, which happens when the object name is given as a full hexadecimal (if the object name is given as a partial hexadecimal or an non-existing ref, the function would have died without returning, so this BUG() wouldn't have triggered). This is wrong. It is an ordinary end-user mistake to give an object name that does not exist and treated as such. Helped-by: Junio C Hamano <[email protected]> Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6b971f6 commit 4dac530

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

remote.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,8 +1204,7 @@ static void show_push_unqualified_ref_name_error(const char *dst_value,
12041204
"'%s:refs/tags/%s'?"),
12051205
matched_src_name, dst_value);
12061206
} else {
1207-
BUG("'%s' should be commit/tag/tree/blob, is '%d'",
1208-
matched_src_name, type);
1207+
advise(_("The <src> part of the refspec is an oid that doesn't exist.\n"));
12091208
}
12101209
}
12111210

t/t5516-fetch-push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ test_expect_success 'push ref expression with non-existent, incomplete dest' '
509509
510510
'
511511

512-
test_expect_failure 'push ref expression with non-existent oid src' '
512+
test_expect_success 'push ref expression with non-existent oid src' '
513513
514514
mk_test testrepo &&
515515
test_must_fail git push testrepo $(test_oid 001):branch

0 commit comments

Comments
 (0)