| 1186 | } |
| 1187 | |
| 1188 | static void show_push_unqualified_ref_name_error(const char *dst_value, |
| 1189 | const char *matched_src_name) |
| 1190 | { |
| 1191 | struct object_id oid; |
| 1192 | |
| 1193 | /* |
| 1194 | * TRANSLATORS: "matches '%s'%" is the <dst> part of "git push |
| 1195 | * <remote> <src>:<dst>" push, and "being pushed ('%s')" is |
| 1196 | * the <src>. |
| 1197 | */ |
| 1198 | error(_("The destination you provided is not a full refname (i.e.,\n" |
| 1199 | "starting with \"refs/\"). We tried to guess what you meant by:\n" |
| 1200 | "\n" |
| 1201 | "- Looking for a ref that matches '%s' on the remote side.\n" |
| 1202 | "- Checking if the <src> being pushed ('%s')\n" |
| 1203 | " is a ref in \"refs/{heads,tags}/\". If so we add a corresponding\n" |
| 1204 | " refs/{heads,tags}/ prefix on the remote side.\n" |
| 1205 | "\n" |
| 1206 | "Neither worked, so we gave up. You must fully qualify the ref."), |
| 1207 | dst_value, matched_src_name); |
| 1208 | |
| 1209 | if (!advice_enabled(ADVICE_PUSH_UNQUALIFIED_REF_NAME)) |
| 1210 | return; |
| 1211 | |
| 1212 | if (repo_get_oid(the_repository, matched_src_name, &oid)) |
| 1213 | BUG("'%s' is not a valid object, " |
| 1214 | "match_explicit_lhs() should catch this!", |
| 1215 | matched_src_name); |
| 1216 | |
| 1217 | switch (odb_read_object_info(the_repository->objects, &oid, NULL)) { |
| 1218 | case OBJ_COMMIT: |
| 1219 | advise(_("The <src> part of the refspec is a commit object.\n" |
| 1220 | "Did you mean to create a new branch by pushing to\n" |
| 1221 | "'%s:refs/heads/%s'?"), |
| 1222 | matched_src_name, dst_value); |
| 1223 | break; |
| 1224 | case OBJ_TAG: |
| 1225 | advise(_("The <src> part of the refspec is a tag object.\n" |
| 1226 | "Did you mean to create a new tag by pushing to\n" |
| 1227 | "'%s:refs/tags/%s'?"), |
| 1228 | matched_src_name, dst_value); |
| 1229 | break; |
| 1230 | case OBJ_TREE: |
| 1231 | advise(_("The <src> part of the refspec is a tree object.\n" |
| 1232 | "Did you mean to tag a new tree by pushing to\n" |
| 1233 | "'%s:refs/tags/%s'?"), |
| 1234 | matched_src_name, dst_value); |
| 1235 | break; |
| 1236 | case OBJ_BLOB: |
| 1237 | advise(_("The <src> part of the refspec is a blob object.\n" |
| 1238 | "Did you mean to tag a new blob by pushing to\n" |
| 1239 | "'%s:refs/tags/%s'?"), |
| 1240 | matched_src_name, dst_value); |
| 1241 | break; |
| 1242 | default: |
| 1243 | advise(_("The <src> part of the refspec ('%s') " |
| 1244 | "is an object ID that doesn't exist.\n"), |
| 1245 | matched_src_name); |
no test coverage detected