{"thread":{"id":"34301","subject":"Parse --o in format-patch","startedAt":"2013-06-28T16:05:00Z","lastAt":"2013-06-28T16:49:59Z","messageCount":4,"participants":["Fredrik Gustafsson","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"222186","messageId":"20130628160459.GA16832@paksenarrion.iveqy.com","threadId":"34301","inReplyTo":null,"subject":"Parse --o in format-patch","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2013-06-28T16:05:00Z","receivedAt":"2013-06-28T16:05:00Z","isPatch":false,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"Hi,\nI don't quite manage to figure out gits argv parsing and would need some\nhelp on the way.\n\nI want:\ngit format-patch -o outdir HEAD~\n\nWork exactly the way it does now, setting output_directory to outdir.\nBut I also want\ngit format-patch -o HEAD~\n\nto set output_directory with a NULL value so that I can assign a default\nvalue to it. Is that even possible with the current argv-parsing implementation?\n\nThe currect argv parser is using OPTION_CALLBACK so I thought that that\ncallback should be able to determine if there was an outdir supplied or\nnot.\n\nOr is the correct solution to also add a bolean type OPTION_BOOLEAN for\n-o?\n-- \nMed vänliga hälsningar\nFredrik Gustafsson\n\ntel: 0733-608274\ne-post: iveqy@iveqy.com\n"},{"id":"222187","messageId":"20130628163153.GA9127@sigill.intra.peff.net","threadId":"34301","inReplyTo":"20130628160459.GA16832@paksenarrion.iveqy.com","subject":"Re: Parse --o in format-patch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-06-28T16:31:53Z","receivedAt":"2013-06-28T16:31:53Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 28, 2013 at 06:05:00PM +0200, Fredrik Gustafsson wrote:\n\n> I don't quite manage to figure out gits argv parsing and would need some\n> help on the way.\n> \n> I want:\n> git format-patch -o outdir HEAD~\n> \n> Work exactly the way it does now, setting output_directory to outdir.\n> But I also want\n> git format-patch -o HEAD~\n> \n> to set output_directory with a NULL value so that I can assign a default\n> value to it. Is that even possible with the current argv-parsing implementation?\n\nIt's possible to have an \"optional\" argument by using the\nPARSE_OPT_OPTARG flag. However, it is not backwards compatible from the\nuser's perspective, as they must use the \"sticked\" form:\n\n  git format-patch -ooutdir ...\n\nto specify the argument. Otherwise, it is not clear in:\n\n  git format-patch -o outdir HEAD~\n\nwhether \"outdir\" is the argument to \"-o\", or if it is simply the next\nargument.\n\nHowever, if you are just interested in \"turning off\" a previously given\nargument, we usually spell that with the \"--no-\" prefix to the long\noption (e.g., \"--no-output-directory\" in this case).\n\nI'm not clear how that interacts with your example, though. Your example\ntries to use \"-o\" to set output_directory to NULL. But it is already\nNULL if you do not specify any \"-o\" at all.\n\n-Peff\n"},{"id":"222188","messageId":"20130628164440.GA21354@paksenarrion.iveqy.com","threadId":"34301","inReplyTo":"20130628163153.GA9127@sigill.intra.peff.net","subject":"Re: Parse --o in format-patch","fromName":"Fredrik Gustafsson","fromEmail":"iveqy@iveqy.com","sentAt":"2013-06-28T16:44:40Z","receivedAt":"2013-06-28T16:44:40Z","isPatch":false,"sender":{"key":"iveqy@iveqy.com","avatar":"https://avatars.githubusercontent.com/u/761743?v=4"},"body":"On Fri, Jun 28, 2013 at 12:31:53PM -0400, Jeff King wrote:\n> It's possible to have an \"optional\" argument by using the\n> PARSE_OPT_OPTARG flag. However, it is not backwards compatible from the\n> user's perspective, as they must use the \"sticked\" form:\n> \n>   git format-patch -ooutdir ...\n> \n> to specify the argument. Otherwise, it is not clear in:\n> \n>   git format-patch -o outdir HEAD~\n> \n> whether \"outdir\" is the argument to \"-o\", or if it is simply the next\n> argument.\n\nThat would be a possibility but I don't like breaking backwards\ncompability.\n\n> I'm not clear how that interacts with your example, though. Your example\n> tries to use \"-o\" to set output_directory to NULL. But it is already\n> NULL if you do not specify any \"-o\" at all.\n\nmy goal is to make:\n       git format-patch [-k] [(-o|--output-directory) <dir> | --stdout] [ <since> | <revision range> ]\nto be:\n       git format-patch [-k] [(-o|--output-directory) [dir] | --stdout] [ <since> | <revision range> ]\n\nthat would do:\ngit format patch -> current dir\ngit format patch -o -> default dir (for example GIT_DIR/.outgoing/)\ngit format patch -o <dir> -> user defined <dir>\n\nBut I guess I would need a new option instead. Something like\n--default-output-dir.\n\n-- \nMed vänliga hälsningar\nFredrik Gustafsson\n\ntel: 0733-608274\ne-post: iveqy@iveqy.com\n"},{"id":"222190","messageId":"20130628164959.GC9127@sigill.intra.peff.net","threadId":"34301","inReplyTo":"20130628164440.GA21354@paksenarrion.iveqy.com","subject":"Re: Parse --o in format-patch","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-06-28T16:49:59Z","receivedAt":"2013-06-28T16:49:59Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Jun 28, 2013 at 06:44:40PM +0200, Fredrik Gustafsson wrote:\n\n> On Fri, Jun 28, 2013 at 12:31:53PM -0400, Jeff King wrote:\n> > It's possible to have an \"optional\" argument by using the\n> > PARSE_OPT_OPTARG flag. However, it is not backwards compatible from the\n> > user's perspective, as they must use the \"sticked\" form:\n> \n> That would be a possibility but I don't like breaking backwards\n> compability.\n\nYes, I did not say it outright, but I meant \"...and that is why we\ncannot go that route.\" :)\n\n> my goal is to make:\n>        git format-patch [-k] [(-o|--output-directory) <dir> | --stdout] [ <since> | <revision range> ]\n> to be:\n>        git format-patch [-k] [(-o|--output-directory) [dir] | --stdout] [ <since> | <revision range> ]\n> \n> that would do:\n> git format patch -> current dir\n> git format patch -o -> default dir (for example GIT_DIR/.outgoing/)\n> git format patch -o <dir> -> user defined <dir>\n\nAh, that makes much more sense to me.\n\n> But I guess I would need a new option instead. Something like\n> --default-output-dir.\n\nIt depends on how the default is specified. Is it hard-coded? Or do you\nspecify format.outputDirectory? If the latter, I would think you would\nwant it on all the time when \"-o\" is not given[1], and no new option is\nrequired. Otherwise, yes, I'd think you would want a new option.\n\n-Peff\n\n[1] format-patch may be considered plumbing, in which case an output\n    directory config option might cause problems with scripts that\n    expect to run it and find the output in the current directory. I'm\n    not sure how big a deal that is.\n"}]}