{"thread":{"id":"1619","subject":"git-rev-parse question.","startedAt":"2005-08-23T08:02:49Z","lastAt":"2005-08-23T17:47:54Z","messageCount":3,"participants":["Junio C Hamano","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"7644","messageId":"7v7jedulli.fsf@assigned-by-dhcp.cox.net","threadId":"1619","inReplyTo":null,"subject":"git-rev-parse question.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-08-23T08:02:49Z","receivedAt":"2005-08-23T08:02:49Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I have been looking at what git-rev-parse does and could not\nfigure out a way to convince it to give me only arguments with\na '-' prefix.  Specifically, I wanted to remove the hardcoded -p\nand -M flags from git-diff-script.  Running\n\n    $ sh -x git-diff-script -C HEAD^ HEAD\n\nreveals that none of the following would pick up \"-C\" from the\ncommand line:\n\n    rev=($(git-rev-parse --revs-only \"$@\")) || exit\n    flags=($(git-rev-parse --no-revs --flags \"$@\"))\n    files=($(git-rev-parse --no-revs --no-flags \"$@\"))\n\nI am not even sure if the current implementation of rev-parse\nmatches what you originally wanted it to do; I suspect it does\nnot.  I would like to know what was the intended behaviour\nfirst, so that I can enhance it to be usable for my purpose\nwithout breaking things.\n\nWhat I want the rev-parse flags to mean is as follows.  By \"rev\nargument\", I mean what get_sha1() can understand.  I have to\nadmit that some flags are what I introduced while I was\nbutchering it without really knowing the original intention:\n\n  output format:\n  --sq\t\toutput in a format usable for shell \"eval\".\n  --symbolic\toutput rev argument in symbolic form, not SHA1.\n\n  output selection:\n  --flags\tshow only arguments with '-' prefix.\n  --no-flags\tdo not show arguments with '-' prefix.\n\n  --revs-only\tshow only arguments meant for rev-list.\n  --no-revs\tshow arguments not meant for rev-list.\n\n  input munging:\n  --default R\tif no revision, pretend R is given.\n  --not\t\tpretend all rev arguments without prefix ^ have\n                prefix ^, and the ones with prefix ^ do not.\n  --all\t\tpretend all refs under $GIT_DIR/refs are given\n  \t\ton the command line.\n\n  special:\n  --verify\tmake sure only one rev argument is given, nothing else.\n\nI think flags/no-flags and revs-only/no-revs *should* be\northogonal.  That is, \"rev-parse --flags --no-revs\" should give\nparameters that start with '-' and not meant for rev-list\n(e.g. '-C' in earlier example); \"rev-parse --revs-only\n--merge-order HEAD Documentation/\" should yield \"--merge-order\nHEAD\".\n\nAlso there is an undocumented --show-prefix.  What is it?\n\n-jc\n\nPS. BTW, any response about unsuspecting companies?\n"},{"id":"7654","messageId":"Pine.LNX.4.58.0508231004180.3317@g5.osdl.org","threadId":"1619","inReplyTo":"7v7jedulli.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-rev-parse question.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-08-23T17:07:31Z","receivedAt":"2005-08-23T17:07:31Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 23 Aug 2005, Junio C Hamano wrote:\n>\n> I have been looking at what git-rev-parse does and could not\n> figure out a way to convince it to give me only arguments with\n> a '-' prefix.\n\nGaah. Understandable. It got broken during some cleanup.\n\nTry this trivial patch, it should work better.\n\nNOTE! The behaviour of \"--\" for git-rev-parse is somewhat unclear. Right \nnow it prints it out with \"--flags\", which is probably wrong.\n\n\t\tLinus\n---\nSubject: Fix git-rev-parse --default and --flags handling\n\nThis makes the argument to --default and any --flags arguments should up \ncorrectly.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/rev-parse.c b/rev-parse.c\n--- a/rev-parse.c\n+++ b/rev-parse.c\n@@ -107,7 +107,7 @@ static void show_arg(char *arg)\n \tif (do_rev_argument && is_rev_argument(arg))\n \t\tshow_rev_arg(arg);\n \telse\n-\t\tshow_norev(arg);\n+\t\tshow(arg);\n }\n \n static void show_default(void)\n@@ -122,7 +122,7 @@ static void show_default(void)\n \t\t\tshow_rev(NORMAL, sha1, s);\n \t\t\treturn;\n \t\t}\n-\t\tshow_arg(s);\n+\t\tshow(s);\n \t}\n }\n \n"},{"id":"7657","messageId":"Pine.LNX.4.58.0508231038140.3317@g5.osdl.org","threadId":"1619","inReplyTo":"Pine.LNX.4.58.0508231004180.3317@g5.osdl.org","subject":"Re: git-rev-parse question.","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-08-23T17:47:54Z","receivedAt":"2005-08-23T17:47:54Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Tue, 23 Aug 2005, Linus Torvalds wrote:\n> \n> Try this trivial patch, it should work better.\n\nActually, don't do the \"show_default()\" part of this. We should _not_ show \nthe default string if we haev \"--no-revs\" and the string doesn't match a \nrev.\n\nAlso, this fixes \"--\" handlign with \"--flags\". Thinking about it for a \nfew seconds made it obvious that we shouldn't show it.\n\n\t\tLinus\n---\nSubject: Fix git-rev-parse --default and --flags handling\n\nThis makes the argument to --default and any --flags arguments should up \ncorrectly, and makes \"--\" together with --flags act sanely.\n\nSigned-off-by: Linus Torvalds <torvalds@osdl.org>\n---\ndiff --git a/rev-parse.c b/rev-parse.c\n--- a/rev-parse.c\n+++ b/rev-parse.c\n@@ -107,7 +107,7 @@ static void show_arg(char *arg)\n \tif (do_rev_argument && is_rev_argument(arg))\n \t\tshow_rev_arg(arg);\n \telse\n-\t\tshow_norev(arg);\n+\t\tshow(arg);\n }\n \n static void show_default(void)\n@@ -122,7 +122,7 @@ static void show_default(void)\n \t\t\tshow_rev(NORMAL, sha1, s);\n \t\t\treturn;\n \t\t}\n-\t\tshow_arg(s);\n+\t\tshow_norev(s);\n \t}\n }\n \n@@ -149,7 +149,7 @@ int main(int argc, char **argv)\n \t\tif (*arg == '-') {\n \t\t\tif (!strcmp(arg, \"--\")) {\n \t\t\t\tshow_default();\n-\t\t\t\tif (revs_only)\n+\t\t\t\tif (revs_only || flags_only)\n \t\t\t\t\tbreak;\n \t\t\t\tas_is = 1;\n \t\t\t}\n"}]}