{"thread":{"id":"50346","subject":"No clear API/Error message to validate a \"revision object\" using git rev-parse","startedAt":"2019-01-29T09:25:57Z","lastAt":"2019-01-29T12:01:50Z","messageCount":3,"participants":["Ντέντος Σταύρος","Christian Couder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"367936","messageId":"CAHMHMxWpqTDyCQPXPY6WPeMBHFzYGE=Z0Q8pSL=9TecwuP9fwg@mail.gmail.com","threadId":"50346","inReplyTo":null,"subject":"No clear API/Error message to validate a \"revision object\" using git rev-parse","fromName":"Ντέντος Σταύρος","fromEmail":"stdedos@gmail.com","sentAt":"2019-01-29T09:25:18Z","receivedAt":"2019-01-29T09:25:57Z","isPatch":false,"sender":{"key":"stdedos@gmail.com","avatar":null},"body":"Hello there everyone,\n\nMinor bug report:\nI have a utility script to find \"reference points\" that contain a\ncommit (git-x-in-y)\n\nThe script needs to accept \"any valid reference point\", that includes\ne.g. tags as well.\nI validate said input by passing whatever argument through git rev-parse.\n\nIf the tag name is invalid, say:\n$ git rev-parse version.3\nversion.3\nfatal: ambiguous argument 'version.3': unknown revision or path not in\nthe working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n\nSo, I follow the recommendation to add '--', since I know that I won't\nbe adding any paths:\n\n$ git rev-parse version.3 --\nfatal: bad revision 'version.3'\n\nHowever, what happens with the correct tags is, I get the trailing\ndouble dash in:\n$  git rev-parse version-0.false --\nd43292476ea9ab8c3d32940352b680549b64e8d8\n--\n$\n\nA further leading argument, e.g. '' makes the situation worse:\n$ git rev-parse version-0.false -- ''\nd43292476ea9ab8c3d32940352b680549b64e8d8\n--\n\n$\n\n`--verify`s error message is even more cryptic:\n$ git rev-parse --verify version.3\nfatal: Needed a single revision\n$ git rev-parse --verify version-0.false\n80f20b100cca5166b22cbcc1f4a6ac1eae64a0d0\n\nFurther attempts do not help either:\n$  git rev-parse --revs-only version-3 ; echo $?\n0\n$\n\nAm I writing the command wrong, or is there some part of it I don't understand?\n\nNtentos Stavros\n"},{"id":"367942","messageId":"CAP8UFD0eQ0hPkd-wsNR8e0hQSJC+dUQatvV1xgdJOUxtXYqC_g@mail.gmail.com","threadId":"50346","inReplyTo":"CAHMHMxWpqTDyCQPXPY6WPeMBHFzYGE=Z0Q8pSL=9TecwuP9fwg@mail.gmail.com","subject":"Re: No clear API/Error message to validate a \"revision object\" using git rev-parse","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2019-01-29T10:51:29Z","receivedAt":"2019-01-29T10:51:44Z","isPatch":false,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Hi,\n\nOn Tue, Jan 29, 2019 at 10:30 AM Ντέντος Σταύρος <stdedos@gmail.com> wrote:\n\n> So, I follow the recommendation to add '--', since I know that I won't\n> be adding any paths:\n>\n> $ git rev-parse version.3 --\n> fatal: bad revision 'version.3'\n>\n> However, what happens with the correct tags is, I get the trailing\n> double dash in:\n> $  git rev-parse version-0.false --\n> d43292476ea9ab8c3d32940352b680549b64e8d8\n> --\n> $\n\nYeah, it looks like a bug to me.\n\n> A further leading argument, e.g. '' makes the situation worse:\n> $ git rev-parse version-0.false -- ''\n> d43292476ea9ab8c3d32940352b680549b64e8d8\n> --\n>\n> $\n\nThis also.\n\n> `--verify`s error message is even more cryptic:\n> $ git rev-parse --verify version.3\n> fatal: Needed a single revision\n\nYeah, but it works.\n\nThe error message could perhaps be improved. On the other hand it has\nbeen the same for a very very long time and very few people complained\nabout it.\n\nAs you are writing a script, you can at least easily redirect it to\n/dev/null and output something else.\n\nIn fact as `git rev-parse` is a \"plumbing command\" it's supposed to be\nused mostly by scripts and power user who can easily deal with such an\nerror message, which explains why there has not been much incentive to\nchange this error message.\n\n> $ git rev-parse --verify version-0.false\n> 80f20b100cca5166b22cbcc1f4a6ac1eae64a0d0\n\nThis also works correctly.\n\nAnd:\n\n$ git rev-parse --verify v2.2.0 --\n74d2a8cf12bf102a8cedaf66736503bb3fe88dfb\n$\n\nalso works correctly.\n\nBest,\nChristian.\n"},{"id":"367948","messageId":"CAHMHMxU7fzHDqWnqx=d016FFPTpyR_Q9f8=oDt+BPBT2WS5bcA@mail.gmail.com","threadId":"50346","inReplyTo":"CAP8UFD0eQ0hPkd-wsNR8e0hQSJC+dUQatvV1xgdJOUxtXYqC_g@mail.gmail.com","subject":"Re: No clear API/Error message to validate a \"revision object\" using git rev-parse","fromName":"Ντέντος Σταύρος","fromEmail":"stdedos@gmail.com","sentAt":"2019-01-29T12:01:09Z","receivedAt":"2019-01-29T12:01:50Z","isPatch":false,"sender":{"key":"stdedos@gmail.com","avatar":null},"body":"On Tue, Jan 29, 2019 at 12:51 PM Christian Couder\n<christian.couder@gmail.com> wrote:\n> > `--verify`s error message is even more cryptic:\n> > $ git rev-parse --verify version.3\n> > fatal: Needed a single revision\n>\n> Yeah, but it works.\n>\n> The error message could perhaps be improved. On the other hand it has\n> been the same for a very very long time and very few people complained\n> about it.\n>\n> [...]\n>\n> In fact as `git rev-parse` is a \"plumbing command\" it's supposed to be\n> used mostly by scripts and power user who can easily deal with such an\n> error message, which explains why there has not been much incentive to\n> change this error message.\n\nI understand the points here, and I understand how minor this \"issue\"\nis in a sense.\nMaintainers / fixer can decide on it, but I thought I should bring it\nto lists' attention.\n\n> As you are writing a script, you can at least easily redirect it to\n> /dev/null and output something else.\n\nI like the \"expected\" output in that way, since:\n```\n'version.0-false' is not matching. I am asking git ...\n80d790c17c9a3f10c156561efc323ac5d4684b16\n'version.0' is not matching. I am asking git ... fatal: bad revision 'version.0'\n```\nit \"complements\" the previous output, and sounds \"fluent enough\".\nAnd also that I don't have to patchwork it (I can, obviously).\n\nThe reason I mentioned:\n\n> $ git rev-parse --verify version.3\n> fatal: Needed a single revision\n\nis that the message sounds counter-intuitive. I already gave (what I\nthought was) a revision, and it is \"already\" one.\nI \"could\" claim that `git rev-parse` is reading 2 arguments\n(`--verify` and `version.3`),\nand somehow `git rev-parse --verify` checks that `argc == 1`, and\nfailing due to a bug in the code.\n\nI would understand that message in this context:\n> $ git rev-parse --verify version.3 version.4\n> fatal: Needed a single revision\nsince I gave 2 arguments instead of 1.\n\nWith regards,\nΝτέντος Σταύρος\n"}]}