commit a3599220a642dcd27bacb8def35d06dd79ca3795 from: Stefan Sperling via: Thomas Adam date: Sun Oct 10 10:46:55 2021 UTC display the requested object type when an object could not be found ok millert@ commit - 238050ce7b9ba6527d21b357cea92a51d94d39cc commit + a3599220a642dcd27bacb8def35d06dd79ca3795 blob - d60df001bcb7f20216fb03d0e53bde49d64c0f5a blob + bff284faf906f806e14b3b54a5308cd8dcb7f99b --- lib/repository.c +++ lib/repository.c @@ -1485,8 +1485,29 @@ done: if (err) { free(*id); *id = NULL; - } else if (*id == NULL) - err = got_error_path(id_str_prefix, GOT_ERR_NO_OBJ); + } else if (*id == NULL) { + switch (obj_type) { + case GOT_OBJ_TYPE_BLOB: + err = got_error_fmt(GOT_ERR_NO_OBJ, "%s %s", + GOT_OBJ_LABEL_BLOB, id_str_prefix); + break; + case GOT_OBJ_TYPE_TREE: + err = got_error_fmt(GOT_ERR_NO_OBJ, "%s %s", + GOT_OBJ_LABEL_TREE, id_str_prefix); + break; + case GOT_OBJ_TYPE_COMMIT: + err = got_error_fmt(GOT_ERR_NO_OBJ, "%s %s", + GOT_OBJ_LABEL_COMMIT, id_str_prefix); + break; + case GOT_OBJ_TYPE_TAG: + err = got_error_fmt(GOT_ERR_NO_OBJ, "%s %s", + GOT_OBJ_LABEL_TAG, id_str_prefix); + break; + default: + err = got_error_path(id_str_prefix, GOT_ERR_NO_OBJ); + break; + } + } return err; } @@ -1590,7 +1611,8 @@ got_repo_object_match_tag(struct got_tag_object **tag, } if (err == NULL && *tag == NULL) - err = got_error_path(name, GOT_ERR_NO_OBJ); + err = got_error_fmt(GOT_ERR_NO_OBJ, "%s %s", + GOT_OBJ_LABEL_TAG, name); return err; } blob - f4f0029ca41073b2b76c6a560ab229e160f04d55 blob + fb11f286780b130bb30e7694ace57e52e5548050 --- regress/cmdline/log.sh +++ regress/cmdline/log.sh @@ -500,7 +500,8 @@ test_log_end_at_commit() { return 1 fi echo -n > $testroot/stdout.expected - echo "got: $empty_sha1: object not found" > $testroot/stderr.expected + echo "got: commit $empty_sha1: object not found" \ + > $testroot/stderr.expected cmp -s $testroot/stderr.expected $testroot/stderr ret="$?" if [ "$ret" != "0" ]; then blob - 2e90851555c6dbe52c187b1f339b87326b87ad22 blob + c8859f46c8278cf558c597f855aa02630021aa69 --- regress/cmdline/tag.sh +++ regress/cmdline/tag.sh @@ -98,7 +98,8 @@ test_tag_create() { return 1 fi - echo "got: $tree_id: object not found" > $testroot/stderr.expected + echo "got: commit $tree_id: object not found" \ + > $testroot/stderr.expected cmp -s $testroot/stderr $testroot/stderr.expected ret="$?" if [ "$ret" != "0" ]; then