{"thread":{"id":"24857","subject":"[PATCH] checkout: respect diff.ignoreSubmodules setting","startedAt":"2010-08-25T10:34:57Z","lastAt":"2010-08-28T14:50:07Z","messageCount":7,"participants":["Johannes Schindelin","Jens Lehmann","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"148962","messageId":"alpine.DEB.1.00.1008251225200.4020@intel-tinevez-2-302","threadId":"24857","inReplyTo":null,"subject":"[PATCH] checkout: respect diff.ignoreSubmodules setting","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2010-08-25T10:34:57Z","receivedAt":"2010-08-25T10:34:57Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nWhen 'git checkout' reports uncommitted changes, it also does so for\nsubmodules.\n\nThe default mode is now to look really hard into submodules, not only\nfor different commits, but also for modified files. Since this can be\npretty expensive when there are a lot (and large) submodules, there is\nthe diff.ignoreSubmodules option.\n\nLet's respect that setting when 'git checkout' reports the uncommitted\nchanges, since it does nothing else than a 'git diff --name-status'.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n builtin/checkout.c |   16 ++++++++++++----\n 1 files changed, 12 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex ff5ac1e..19c23b2 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -18,6 +18,7 @@\n #include \"xdiff-interface.h\"\n #include \"ll-merge.h\"\n #include \"resolve-undo.h\"\n+#include \"submodule.h\"\n \n static const char * const checkout_usage[] = {\n \t\"git checkout [options] <branch>\",\n@@ -40,6 +41,7 @@ struct checkout_opts {\n \tconst char *new_orphan_branch;\n \tint new_branch_log;\n \tenum branch_track track;\n+\tstruct diff_options diff_options;\n };\n \n static int post_checkout_hook(struct commit *old, struct commit *new,\n@@ -282,11 +284,12 @@ static int checkout_paths(struct tree *source_tree, const char **pathspec,\n \treturn errs;\n }\n \n-static void show_local_changes(struct object *head)\n+static void show_local_changes(struct object *head, struct diff_options *opts)\n {\n \tstruct rev_info rev;\n \t/* I think we want full paths, even if we're in a subdirectory. */\n \tinit_revisions(&rev, NULL);\n+\trev.diffopt.flags = opts->flags;\n \trev.diffopt.output_format |= DIFF_FORMAT_NAME_STATUS;\n \tif (diff_setup_done(&rev.diffopt) < 0)\n \t\tdie(\"diff_setup_done failed\");\n@@ -471,7 +474,7 @@ static int merge_working_tree(struct checkout_opts *opts,\n \t\tdie(\"unable to write new index file\");\n \n \tif (!opts->force && !opts->quiet)\n-\t\tshow_local_changes(&new->commit->object);\n+\t\tshow_local_changes(&new->commit->object, &opts->diff_options);\n \n \treturn 0;\n }\n@@ -619,7 +622,12 @@ static int switch_branches(struct checkout_opts *opts, struct branch_info *new)\n \n static int git_checkout_config(const char *var, const char *value, void *cb)\n {\n-\treturn git_xmerge_config(var, value, cb);\n+\tif (!strcmp(var, \"diff.ignoresubmodules\")) {\n+\t\tstruct checkout_opts *opts = cb;\n+\t\thandle_ignore_submodules_arg(&opts->diff_options, value);\n+\t\treturn 0;\n+\t}\n+\treturn git_xmerge_config(var, value, NULL);\n }\n \n static int interactive_checkout(const char *revision, const char **pathspec,\n@@ -703,7 +711,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tmemset(&opts, 0, sizeof(opts));\n \tmemset(&new, 0, sizeof(new));\n \n-\tgit_config(git_checkout_config, NULL);\n+\tgit_config(git_checkout_config, &opts);\n \n \topts.track = BRANCH_TRACK_UNSPECIFIED;\n \n-- \n1.7.2.2.485.gf3638.dirty\n"},{"id":"148975","messageId":"4C755778.7010306@web.de","threadId":"24857","inReplyTo":"alpine.DEB.1.00.1008251225200.4020@intel-tinevez-2-302","subject":"Re: [PATCH] checkout: respect diff.ignoreSubmodules setting","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-08-25T17:48:40Z","receivedAt":"2010-08-25T17:48:40Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 25.08.2010 12:34, schrieb Johannes Schindelin:\n> \n> When 'git checkout' reports uncommitted changes, it also does so for\n> submodules.\n> \n> The default mode is now to look really hard into submodules, not only\n> for different commits, but also for modified files. Since this can be\n> pretty expensive when there are a lot (and large) submodules, there is\n> the diff.ignoreSubmodules option.\n> \n> Let's respect that setting when 'git checkout' reports the uncommitted\n> changes, since it does nothing else than a 'git diff --name-status'.\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThanks for fixing that!\n\nAcked-by: Jens Lehmann <Jens.Lehmann@web.de>\n"},{"id":"148990","messageId":"7vlj7uqwr6.fsf@alter.siamese.dyndns.org","threadId":"24857","inReplyTo":"4C755778.7010306@web.de","subject":"Re: [PATCH] checkout: respect diff.ignoreSubmodules setting","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-25T20:10:21Z","receivedAt":"2010-08-25T20:10:21Z","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 25.08.2010 12:34, schrieb Johannes Schindelin:\n>>  ...\n>> Let's respect that setting when 'git checkout' reports the uncommitted\n>> changes, since it does nothing else than a 'git diff --name-status'.\n>> \n>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n>\n> Thanks for fixing that!\n>\n> Acked-by: Jens Lehmann <Jens.Lehmann@web.de>\n\nMakes sense.\n\nI wondered if the new parameter to show_local_changes() should just be of\ntype (struct checkout_opts *), so that other options given to checkout,\nnot necessarily related to the diff generation, can influence the output\nfurther if we wanted to, but that kind of change can be done if and when\nit becomes necessary.\n\nThanks.  Perhaps we would want a new test or two in t2013?\n"},{"id":"149007","messageId":"4C7591D7.9050508@web.de","threadId":"24857","inReplyTo":"7vlj7uqwr6.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] checkout: respect diff.ignoreSubmodules setting","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-08-25T21:57:43Z","receivedAt":"2010-08-25T21:57:43Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 25.08.2010 22:10, schrieb Junio C Hamano:\n> Thanks.  Perhaps we would want a new test or two in t2013?\n\nSure, I will add some as soon as I find some time ...\n"},{"id":"149164","messageId":"4C7921BD.7030600@web.de","threadId":"24857","inReplyTo":"4C7591D7.9050508@web.de","subject":"[PATCH 0/2] checkout: diff.ignoreSubmodules: Add test and honor per submodule settings too","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-08-28T14:48:29Z","receivedAt":"2010-08-28T14:48:29Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 25.08.2010 23:57, schrieb Jens Lehmann:\n> Am 25.08.2010 22:10, schrieb Junio C Hamano:\n>> Thanks.  Perhaps we would want a new test or two in t2013?\n> \n> Sure, I will add some as soon as I find some time ...\n\nOk, here we go!\n\nWhile writing the test I noticed it might be nice to use the\nconfiguration settings consistently. So I did a second patch\nteaching checkout to honor the submodule.*.ignore settings\nthe same way diff and status do.\n\nTwo other issues surfaced while working on these patches:\n\n1) We might have to teach the --ignore-submodules option to\n   checkout too to be able to override the configuration on\n   the command line and in scripts.\n\n2) It might be a good idea to let \"git status\" honor the\n   diff.ignoreSubmodules setting too, so that the output is\n   consistent with that of diff and checkout.\n\nOpinions?\n\n(While I am willing to write the patches, I am not a user of\nthese config options myself, so feedback from people who do\nuse them is very much appreciated!)\n\n\nJens Lehmann (2):\n  checkout: Add test for diff.ignoreSubmodules\n  checkout: Use submodule.*.ignore settings from .git/config and\n    .gitmodules\n\n Documentation/config.txt      |    3 ++-\n builtin/checkout.c            |    5 +++++\n t/t2013-checkout-submodule.sh |   23 +++++++++++++++++++++++\n 3 files changed, 30 insertions(+), 1 deletions(-)\n\n-- \n1.7.2.2.515.g13860\n"},{"id":"149165","messageId":"4C7921F5.1050701@web.de","threadId":"24857","inReplyTo":"4C7921BD.7030600@web.de","subject":"[PATCH 1/2] checkout: Add test for diff.ignoreSubmodules","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-08-28T14:49:25Z","receivedAt":"2010-08-28T14:49:25Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"While at it, document that checkout uses this flag too in the Documentation.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n Documentation/config.txt      |    3 ++-\n t/t2013-checkout-submodule.sh |    7 +++++++\n 2 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 0510ac7..cda6721 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -829,7 +829,8 @@ diff.renames::\n diff.ignoreSubmodules::\n \tSets the default value of --ignore-submodules. Note that this\n \taffects only 'git diff' Porcelain, and not lower level 'diff'\n-\tcommands such as 'git diff-files'.\n+\tcommands such as 'git diff-files'. 'git checkout' also honors\n+\tthis setting when reporting uncommitted changes.\n\n diff.suppressBlankEmpty::\n \tA boolean to inhibit the standard behavior of printing a space\ndiff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh\nindex fda3f0a..3beb0b3 100755\n--- a/t/t2013-checkout-submodule.sh\n+++ b/t/t2013-checkout-submodule.sh\n@@ -39,4 +39,11 @@ test_expect_success '\"checkout <submodule>\" updates the index only' '\n \tgit diff-files --quiet\n '\n\n+test_expect_success '\"checkout <submodule>\" honors diff.ignoreSubmodules' '\n+\tgit config diff.ignoreSubmodules dirty &&\n+\techo x> submodule/untracked &&\n+\tgit checkout HEAD >actual 2>&1 &&\n+\t! test -s actual\n+'\n+\n test_done\n-- \n1.7.2.2.515.g13860\n"},{"id":"149166","messageId":"4C79221F.907@web.de","threadId":"24857","inReplyTo":"4C7921BD.7030600@web.de","subject":"[PATCH 2/2] checkout: Use submodule.*.ignore settings from .git/config and .gitmodules","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2010-08-28T14:50:07Z","receivedAt":"2010-08-28T14:50:07Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"For \"git status\" and the diff family the submodule.*.ignore settings from\n.git/config and .gitmodules can be used to override the default set via\ndiff.ignoreSubmodules on a per-submodule basis. Let's do this consistently\nand teach checkout to use these settings too.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n builtin/checkout.c            |    5 +++++\n t/t2013-checkout-submodule.sh |   16 ++++++++++++++++\n 2 files changed, 21 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/checkout.c b/builtin/checkout.c\nindex 19c23b2..f365169 100644\n--- a/builtin/checkout.c\n+++ b/builtin/checkout.c\n@@ -627,6 +627,10 @@ static int git_checkout_config(const char *var, const char *value, void *cb)\n \t\thandle_ignore_submodules_arg(&opts->diff_options, value);\n \t\treturn 0;\n \t}\n+\n+\tif (!prefixcmp(var, \"submodule.\"))\n+\t\treturn parse_submodule_config_option(var, value);\n+\n \treturn git_xmerge_config(var, value, NULL);\n }\n\n@@ -711,6 +715,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \tmemset(&opts, 0, sizeof(opts));\n \tmemset(&new, 0, sizeof(new));\n\n+\tgitmodules_config();\n \tgit_config(git_checkout_config, &opts);\n\n \topts.track = BRANCH_TRACK_UNSPECIFIED;\ndiff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh\nindex 3beb0b3..70edbb3 100755\n--- a/t/t2013-checkout-submodule.sh\n+++ b/t/t2013-checkout-submodule.sh\n@@ -46,4 +46,20 @@ test_expect_success '\"checkout <submodule>\" honors diff.ignoreSubmodules' '\n \t! test -s actual\n '\n\n+test_expect_success '\"checkout <submodule>\" honors submodule.*.ignore from .gitmodules' '\n+\tgit config diff.ignoreSubmodules none &&\n+\tgit config -f .gitmodules submodule.submodule.path submodule &&\n+\tgit config -f .gitmodules submodule.submodule.ignore untracked &&\n+\tgit checkout HEAD >actual 2>&1 &&\n+\t! test -s actual\n+'\n+\n+test_expect_success '\"checkout <submodule>\" honors submodule.*.ignore from .git/config' '\n+\tgit config -f .gitmodules submodule.submodule.ignore none &&\n+\tgit config submodule.submodule.path submodule &&\n+\tgit config submodule.submodule.ignore all &&\n+\tgit checkout HEAD >actual 2>&1 &&\n+\t! test -s actual\n+'\n+\n test_done\n-- \n1.7.2.2.515.g13860\n"}]}