{"thread":{"id":"52024","subject":"bug: \"rev-parse --short\" with \"--not --remote\"","startedAt":"2019-10-11T20:12:13Z","lastAt":"2019-10-11T20:58:34Z","messageCount":2,"participants":["Brent Casavant","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"383929","messageId":"83e4f54f-190b-115f-b31b-7177c681128b@hpe.com","threadId":"52024","inReplyTo":null,"subject":"bug: \"rev-parse --short\" with \"--not --remote\"","fromName":"Brent Casavant","fromEmail":"brent.casavant@hpe.com","sentAt":"2019-10-11T20:10:33Z","receivedAt":"2019-10-11T20:12:13Z","isPatch":false,"sender":{"key":"brent.casavant@hpe.com","avatar":null},"body":"Hello,\n\nI noticed what appears to be a bug in rev-parse with an admittedly somewhat unusual combination of arguments.\n\nCompare the output of the following:\n\n% git rev-parse HEAD --not --remotes=origin\n3de09080eb219149a8596dc21915d5a496cba171\n^4fb157bf360413fe3fad38d03b02ce7232d12961\n^757cfa6938c3d510d1597096d9f0b6878b884270\n\nTo this:\n\n% git rev-parse --short HEAD --not --remotes=origin\n^4fb157b\n^757cfa6\n^3de0908\n\nIn the first case rev-parse emits the commit-id of HEAD, followed by negated commit-ids of all remote branches in origin.  I believe this is the correct and intended behavior.\n\nIn the second case rev-parse emits the negated short commit-ids of all remote branches in origin, followed by the negated short commit-id of HEAD.  This is inconsistent with the results of the (presumably correct) prior example.\n\nI would expect both commands to emit the same output, modulo the number of characters emitted for the commit-id.\n\nThank you,\nBrent Casavant\n\n-- \nBrent Casavant\nHewlett Packard Enterprise\n"},{"id":"383934","messageId":"20191011205831.GA30244@sigill.intra.peff.net","threadId":"52024","inReplyTo":"83e4f54f-190b-115f-b31b-7177c681128b@hpe.com","subject":"Re: bug: \"rev-parse --short\" with \"--not --remote\"","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-10-11T20:58:32Z","receivedAt":"2019-10-11T20:58:34Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 11, 2019 at 03:10:33PM -0500, Brent Casavant wrote:\n\n> I noticed what appears to be a bug in rev-parse with an admittedly\n> somewhat unusual combination of arguments.\n> \n> Compare the output of the following:\n> \n> % git rev-parse HEAD --not --remotes=origin\n> 3de09080eb219149a8596dc21915d5a496cba171\n> ^4fb157bf360413fe3fad38d03b02ce7232d12961\n> ^757cfa6938c3d510d1597096d9f0b6878b884270\n> \n> To this:\n> \n> % git rev-parse --short HEAD --not --remotes=origin\n> ^4fb157b\n> ^757cfa6\n> ^3de0908\n> \n> In the first case rev-parse emits the commit-id of HEAD, followed by\n> negated commit-ids of all remote branches in origin.  I believe this\n> is the correct and intended behavior.\n> \n> In the second case rev-parse emits the negated short commit-ids of all\n> remote branches in origin, followed by the negated short commit-id of\n> HEAD.  This is inconsistent with the results of the (presumably\n> correct) prior example.\n> \n> I would expect both commands to emit the same output, modulo the\n> number of characters emitted for the commit-id.\n\nThat's what I'd have naively expected, too, but that's not what\n\"--short\" is documented to do:\n\n  $ git help rev-parse | grep -A2 -e --short\n         --short[=length]\n\t     Same as --verify but shortens the object name to a unique\n\t     prefix with at least length characters. The minimum length\n\t     is 4, the default is the effective value of the core.abbrev\n\t     configuration variable (see git-config(1)).\n\nand --verify itself is a bit magical:\n\n  $ git help rev-parse | grep -m1 -A2 -e --verify\n         --verify\n\t     Verify that exactly one parameter is provided, and that it\n\t     can be turned into a raw 20-byte SHA-1 that can be used to\n\t     access the object database. If so, emit it to the standard\n\t     output; otherwise, error out.\n\nYou can see the same weirdness with --verify (e.g., `git rev-parse\n--verify HEAD --not --remotes=origin`). And I think it is kind of buggy,\nin that I'd expect it to complain about seeing more than one parameter.\n\nI'm not sure exactly what you're trying to do. If you actually want a\ntraversal, you probably should be using rev-list (with --abbrev-commit\nif you want to abbreviate). If you just want to resolve some names\nwithout traversing, you might be better off using for-each-ref or\nsimilar.\n\n-Peff\n"}]}