{"thread":{"id":"24983","subject":"[PATCH/RFC] Restructure some of the checkout opts.","startedAt":"2010-09-05T12:09:06Z","lastAt":"2010-09-06T06:25:23Z","messageCount":4,"participants":["Jared Hance","Jens Lehmann","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"149964","messageId":"9f6f4947af20df9dc0ebd8915dcdb9b5f756d35d.1283688482.git.jaredhance@gmail.com","threadId":"24983","inReplyTo":null,"subject":"[PATCH/RFC] Restructure some of the checkout opts.","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2010-09-05T12:09:06Z","receivedAt":"2010-09-05T12:09:06Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"Previously, most opts in `builtin.checkout.c' had been an instance of\n`struct checkout_opts'. It appears that some of the opts that were\nperhaps added later were not in the struct. Move them into the struct\nin order to maintain consistency.\n\nSigned-off-by: Jared Hance <jaredhance@gmail.com>\n---\n\n builtin/checkout.c |   27 ++++++++++++++-------------\n 1 files changed, 14 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 7250e5c..3a35cde 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -31,6 +31,9 @@ struct checkout_opts {\n \tint force;\n \tint writeout_stage;\n \tint writeout_error;\n+\tint patch_mode;\n+\tint dwim_new_local_branch;\n+\tchar *conflict_style;\n \n \t/* not set by parse_options */\n \tint branch_exists;\n@@ -660,9 +663,6 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tconst char *arg;\n \tstruct branch_info new;\n \tstruct tree *source_tree = NULL;\n-\tchar *conflict_style = NULL;\n-\tint patch_mode = 0;\n-\tint dwim_new_local_branch = 1;\n \tstruct option options[] = {\n \t\tOPT__QUIET(&opts.quiet),\n \t\tOPT_STRING('b', NULL, &opts.new_branch, \"branch\",\n@@ -679,10 +679,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\t\t    3),\n \t\tOPT_BOOLEAN('f', \"force\", &opts.force, \"force\"),\n \t\tOPT_BOOLEAN('m', \"merge\", &opts.merge, \"merge\"),\n-\t\tOPT_STRING(0, \"conflict\", &conflict_style, \"style\",\n+\t\tOPT_STRING(0, \"conflict\", &opts.conflict_style, \"style\",\n \t\t\t   \"conflict style (merge or diff3)\"),\n-\t\tOPT_BOOLEAN('p', \"patch\", &patch_mode, \"select hunks interactively\"),\n-\t\t{ OPTION_BOOLEAN, 0, \"guess\", &dwim_new_local_branch, NULL,\n+\t\tOPT_BOOLEAN('p', \"patch\", &opts.patch_mode, \"select hunks interactively\"),\n+\t\t{ OPTION_BOOLEAN, 0, \"guess\", &opts.dwim_new_local_branch, NULL,\n \t\t  \"second guess 'git checkout no-such-branch'\",\n \t\t  PARSE_OPT_NOARG | PARSE_OPT_HIDDEN },\n \t\tOPT_END(),\n@@ -695,6 +695,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tgit_config(git_checkout_config, NULL);\n \n \topts.track = BRANCH_TRACK_UNSPECIFIED;\n+\topts.dwim_new_local_branch = 1;\n \n \targc = parse_options(argc, argv, prefix, options, checkout_usage,\n \t\t\t     PARSE_OPT_KEEP_DASHDASH);\n@@ -707,7 +708,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tif (opts.new_branch_force)\n \t\topts.new_branch = opts.new_branch_force;\n \n-\tif (patch_mode && (opts.track > 0 || opts.new_branch\n+\tif (opts.patch_mode && (opts.track > 0 || opts.new_branch\n \t\t\t   || opts.new_branch_log || opts.merge || opts.force))\n \t\tdie (\"--patch is incompatible with all other options\");\n \n@@ -734,9 +735,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\topts.new_branch = opts.new_orphan_branch;\n \t}\n \n-\tif (conflict_style) {\n+\tif (opts.conflict_style) {\n \t\topts.merge = 1; /* implied */\n-\t\tgit_xmerge_config(\"merge.conflictstyle\", conflict_style, NULL);\n+\t\tgit_xmerge_config(\"merge.conflictstyle\", opts.conflict_style, NULL);\n \t}\n \n \tif (opts.force && opts.merge)\n@@ -787,8 +788,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\tif (get_sha1_mb(arg, rev)) {\n \t\t\tif (has_dash_dash)          /* case (1) */\n \t\t\t\tdie(\"invalid reference: %s\", arg);\n-\t\t\tif (!patch_mode &&\n-\t\t\t    dwim_new_local_branch &&\n+\t\t\tif (!opts.patch_mode &&\n+\t\t\t    opts.dwim_new_local_branch &&\n \t\t\t    opts.track == BRANCH_TRACK_UNSPECIFIED &&\n \t\t\t    !opts.new_branch &&\n \t\t\t    !check_filename(NULL, arg) &&\n@@ -851,7 +852,7 @@ no_reference:\n \t\tif (!pathspec)\n \t\t\tdie(\"invalid path specification\");\n \n-\t\tif (patch_mode)\n+\t\tif (opts.patch_mode)\n \t\t\treturn interactive_checkout(new.name, pathspec, &opts);\n \n \t\t/* Checkout paths */\n@@ -869,7 +870,7 @@ no_reference:\n \t\treturn checkout_paths(source_tree, pathspec, &opts);\n \t}\n \n-\tif (patch_mode)\n+\tif (opts.patch_mode)\n \t\treturn interactive_checkout(new.name, NULL, &opts);\n \n \tif (opts.new_branch) {\n-- \n1.7.2.2\n"},{"id":"149965","messageId":"4C838BE9.5000006@web.de","threadId":"24983","inReplyTo":"9f6f4947af20df9dc0ebd8915dcdb9b5f756d35d.1283688482.git.jaredhance@gmail.com","subject":"Re: [PATCH/RFC] Restructure some of the checkout opts.","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-09-05T12:24:09Z","receivedAt":"2010-09-05T12:24:09Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 05.09.2010 14:09, schrieb Jared Hance:\n> Previously, most opts in `builtin.checkout.c' had been an instance of\n> `struct checkout_opts'. It appears that some of the opts that were\n> perhaps added later were not in the struct. Move them into the struct\n> in order to maintain consistency.\n\nHm, they aren't used outside of cmd_checkout() (as the other members\nare), so maybe it is ok that they aren't in the struct?\n"},{"id":"149966","messageId":"20100905125414.GA3230@localhost.localdomain","threadId":"24983","inReplyTo":"4C838BE9.5000006@web.de","subject":"Re: [PATCH/RFC] Restructure some of the checkout opts.","fromName":"Jared Hance","fromEmail":"jaredhance@gmail.com","sentAt":"2010-09-05T12:54:14Z","receivedAt":"2010-09-05T12:54:14Z","isPatch":true,"sender":{"key":"jaredhance@gmail.com","avatar":"https://avatars.githubusercontent.com/u/170192?v=4"},"body":"On Sun, Sep 05, 2010 at 02:24:09PM +0200, Jens Lehmann wrote:\n> Am 05.09.2010 14:09, schrieb Jared Hance:\n> > Previously, most opts in `builtin.checkout.c' had been an instance of\n> > `struct checkout_opts'. It appears that some of the opts that were\n> > perhaps added later were not in the struct. Move them into the struct\n> > in order to maintain consistency.\n> \n> Hm, they aren't used outside of cmd_checkout() (as the other members\n> are), so maybe it is ok that they aren't in the struct?\n\nI guessed that this was the reason that they were overlooked, but it\nseemed a little odd that every other opt was stored in the struct and\nit just seemed to be more consistent to have _everything_ in the\nstruct.\n\nIt also makes it more clear that they opts, whereas before, you might\nthink they weren't at a first glance because they weren't in the\nstruct like the others.\n\nI'll leave this to you guys to decide what to do with it.\n"},{"id":"150046","messageId":"7v39tnwfqk.fsf@alter.siamese.dyndns.org","threadId":"24983","inReplyTo":"4C838BE9.5000006@web.de","subject":"Re: [PATCH/RFC] Restructure some of the checkout opts.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-06T06:25:23Z","receivedAt":"2010-09-06T06:25:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jens Lehmann <Jens.Lehmann@web.de> writes:\n\n> Am 05.09.2010 14:09, schrieb Jared Hance:\n>> Previously, most opts in `builtin.checkout.c' had been an instance of\n>> `struct checkout_opts'. It appears that some of the opts that were\n>> perhaps added later were not in the struct. Move them into the struct\n>> in order to maintain consistency.\n>\n> Hm, they aren't used outside of cmd_checkout() (as the other members\n> are), so maybe it is ok that they aren't in the struct?\n\nCorrect.  I do not think they are outside the structure because they are\noverlooked.\n\nThey simply do not make sense outside the context of \"builtin/checkout.c\"\nwhere \"struct checkout\" is used (e.g. what would patch-mode possibly mean\nin the context of \"builtin/apply\" where the struct is used to check out a\npath that is not checked out to the working tree).  Moving them into the\nstructure would thus make no sense and _will_ confuse people.\n"}]}