{"thread":{"id":"20586","subject":"[PATCH] git submodule summary: add --files option","startedAt":"2009-08-13T19:32:50Z","lastAt":"2009-08-15T11:40:55Z","messageCount":4,"participants":["Jens Lehmann","Junio C Hamano","Lars Hjemli"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"120564","messageId":"4A846A62.7010306@web.de","threadId":"20586","inReplyTo":null,"subject":"[PATCH] git submodule summary: add --files option","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2009-08-13T19:32:50Z","receivedAt":"2009-08-13T19:32:50Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"git submodule summary is providing similar functionality for submodules as\ngit diff-index does for a git project (including the meaning of --cached).\nBut the analogon to git diff-files is missing, so add a --files option to\nsummarize the differences between the index of the super project and the\nlast commit checked out in the working tree of the submodule.\n\nSigned-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n---\n Documentation/git-submodule.txt |   13 +++++++++++--\n git-submodule.sh                |   19 ++++++++++++++++---\n t/t7401-submodule-summary.sh    |   22 ++++++++++++++++++++++\n 3 files changed, 49 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 7dd73ae..145802a 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -15,7 +15,7 @@ SYNOPSIS\n 'git submodule' [--quiet] init [--] [<path>...]\n 'git submodule' [--quiet] update [--init] [-N|--no-fetch] [--rebase]\n \t      [--reference <repository>] [--merge] [--] [<path>...]\n-'git submodule' [--quiet] summary [--cached] [--summary-limit <n>] [commit] [--] [<path>...]\n+'git submodule' [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]\n 'git submodule' [--quiet] foreach <command>\n 'git submodule' [--quiet] sync [--] [<path>...]\n\n@@ -127,7 +127,11 @@ summary::\n \tShow commit summary between the given commit (defaults to HEAD) and\n \tworking tree/index. For a submodule in question, a series of commits\n \tin the submodule between the given super project commit and the\n-\tindex or working tree (switched by --cached) are shown.\n+\tindex or working tree (switched by --cached) are shown. If the option\n+\t--files is given, show the series of commits in the submodule between\n+\tthe index of super project the and the working tree of the submodule\n+\t(this option doesn't allow to use the --cached option or to provide an\n+\texplicit commit).\n\n foreach::\n \tEvaluates an arbitrary shell command in each checked out submodule.\n@@ -169,6 +173,11 @@ OPTIONS\n \tcommands typically use the commit found in the submodule HEAD, but\n \twith this option, the commit stored in the index is used instead.\n\n+--files::\n+\tThis option is only valid for the summary command. This command\n+\tcompares the commit in the index with that in the submodule HEAD\n+\twhen this option is used.\n+\n -n::\n --summary-limit::\n \tThis option is only valid for the summary command.\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex ebed711..9bdd6ea 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -4,7 +4,7 @@\n #\n # Copyright (c) 2007 Lars Hjemli\n\n-USAGE=\"[--quiet] [--cached] \\\n+USAGE=\"[--quiet] [--cached|--files] \\\n [add [-b branch] <repo> <path>]|[status|init|update [-i|--init] [-N|--no-fetch] [--rebase|--merge]|summary [-n|--summary-limit <n>] [<commit>]] \\\n [--] [<path>...]|[foreach <command>]|[sync [--] [<path>...]]\"\n OPTIONS_SPEC=\n@@ -16,6 +16,7 @@ command=\n branch=\n reference=\n cached=\n+files=\n nofetch=\n update=\n\n@@ -460,6 +461,7 @@ set_name_rev () {\n cmd_summary() {\n \tsummary_limit=-1\n \tfor_status=\n+\tdiff_cmd=diff-index\n\n \t# parse $args after \"submodule ... summary\".\n \twhile test $# -ne 0\n@@ -468,6 +470,9 @@ cmd_summary() {\n \t\t--cached)\n \t\t\tcached=\"$1\"\n \t\t\t;;\n+\t\t--files)\n+\t\t\tfiles=\"$1\"\n+\t\t\t;;\n \t\t--for-status)\n \t\t\tfor_status=\"$1\"\n \t\t\t;;\n@@ -504,9 +509,17 @@ cmd_summary() {\n \t\thead=HEAD\n \tfi\n\n+\tif [ -n \"$files\" ]\n+\tthen\n+\t\ttest -n \"$cached\" &&\n+\t\tdie \"--cached cannot be used with --files\"\n+\t\tdiff_cmd=diff-files\n+\t\thead=\n+\tfi\n+\n \tcd_to_toplevel\n \t# Get modified modules cared by user\n-\tmodules=$(git diff-index $cached --raw $head -- \"$@\" |\n+\tmodules=$(git $diff_cmd $cached --raw $head -- \"$@\" |\n \t\tegrep '^:([0-7]* )?160000' |\n \t\twhile read mod_src mod_dst sha1_src sha1_dst status name\n \t\tdo\n@@ -520,7 +533,7 @@ cmd_summary() {\n\n \ttest -z \"$modules\" && return\n\n-\tgit diff-index $cached --raw $head -- $modules |\n+\tgit $diff_cmd $cached --raw $head -- $modules |\n \tegrep '^:([0-7]* )?160000' |\n \tcut -c2- |\n \twhile read mod_src mod_dst sha1_src sha1_dst status name\ndiff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh\nindex 6149829..6cc16c3 100755\n--- a/t/t7401-submodule-summary.sh\n+++ b/t/t7401-submodule-summary.sh\n@@ -56,6 +56,15 @@ test_expect_success 'modified submodule(forward)' \"\n EOF\n \"\n\n+test_expect_success 'modified submodule(forward), --files' \"\n+\tgit submodule summary --files >actual &&\n+\tdiff actual - <<-EOF\n+* sm1 $head1...$head2 (1):\n+  > Add foo3\n+\n+EOF\n+\"\n+\n commit_file sm1 &&\n cd sm1 &&\n git reset --hard HEAD~2 >/dev/null &&\n@@ -114,6 +123,15 @@ test_expect_success 'typechanged submodule(submodule->blob), --cached' \"\n EOF\n \"\n\n+test_expect_success 'typechanged submodule(submodule->blob), --files' \"\n+    git submodule summary --files >actual &&\n+    diff actual - <<-EOF\n+* sm1 $head5(blob)->$head4(submodule) (3):\n+  > Add foo5\n+\n+EOF\n+\"\n+\n rm -rf sm1 &&\n git checkout-index sm1\n test_expect_success 'typechanged submodule(submodule->blob)' \"\n@@ -205,4 +223,8 @@ test_expect_success '--for-status' \"\n EOF\n \"\n\n+test_expect_success 'fail when using --files together with --cached' \"\n+    test_must_fail git submodule summary --files --cached\n+\"\n+\n test_done\n-- \n1.6.4.114.gefd1\n"},{"id":"120648","messageId":"7v8whmjhqh.fsf@alter.siamese.dyndns.org","threadId":"20586","inReplyTo":"4A846A62.7010306@web.de","subject":"Re: [PATCH] git submodule summary: add --files option","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-14T19:52:22Z","receivedAt":"2009-08-14T19:52:22Z","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> git submodule summary is providing similar functionality for submodules as\n> git diff-index does for a git project (including the meaning of --cached).\n> But the analogon to git diff-files is missing, so add a --files option to\n> summarize the differences between the index of the super project and the\n> last commit checked out in the working tree of the submodule.\n>\n> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n\nMakes sense to me.  Comments?\n"},{"id":"120692","messageId":"8c5c35580908150140q1d209664ic5e3816609365e24@mail.gmail.com","threadId":"20586","inReplyTo":"7v8whmjhqh.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git submodule summary: add --files option","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2009-08-15T08:40:42Z","receivedAt":"2009-08-15T08:40:42Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On Fri, Aug 14, 2009 at 21:52, Junio C Hamano<gitster@pobox.com> wrote:\n> Jens Lehmann <Jens.Lehmann@web.de> writes:\n>\n>> git submodule summary is providing similar functionality for submodules as\n>> git diff-index does for a git project (including the meaning of --cached).\n>> But the analogon to git diff-files is missing, so add a --files option to\n>> summarize the differences between the index of the super project and the\n>> last commit checked out in the working tree of the submodule.\n>>\n>> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n>\n> Makes sense to me.  Comments?\n\nAcked-by: Lars Hjemli <hjemli@gmail.com> with a tiny fixup:\n\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -129,7 +129,7 @@ summary::\n        in the submodule between the given super project commit and the\n        index or working tree (switched by --cached) are shown. If the option\n        --files is given, show the series of commits in the submodule between\n-       the index of super project the and the working tree of the submodule\n+       the index of the super project and the working tree of the submodule\n        (this option doesn't allow to use the --cached option or to provide an\n        explicit commit).\n"},{"id":"120705","messageId":"4A869EC7.7080701@web.de","threadId":"20586","inReplyTo":"8c5c35580908150140q1d209664ic5e3816609365e24@mail.gmail.com","subject":"Re: [PATCH] git submodule summary: add --files option","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2009-08-15T11:40:55Z","receivedAt":"2009-08-15T11:40:55Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Lars Hjemli schrieb:\n> On Fri, Aug 14, 2009 at 21:52, Junio C Hamano<gitster@pobox.com> wrote:\n>> Jens Lehmann <Jens.Lehmann@web.de> writes:\n>>\n>>> git submodule summary is providing similar functionality for submodules as\n>>> git diff-index does for a git project (including the meaning of --cached).\n>>> But the analogon to git diff-files is missing, so add a --files option to\n>>> summarize the differences between the index of the super project and the\n>>> last commit checked out in the working tree of the submodule.\n>>>\n>>> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>\n>> Makes sense to me.  Comments?\n> \n> Acked-by: Lars Hjemli <hjemli@gmail.com> with a tiny fixup:\n> \n> --- a/Documentation/git-submodule.txt\n> +++ b/Documentation/git-submodule.txt\n> @@ -129,7 +129,7 @@ summary::\n>         in the submodule between the given super project commit and the\n>         index or working tree (switched by --cached) are shown. If the option\n>         --files is given, show the series of commits in the submodule between\n> -       the index of super project the and the working tree of the submodule\n> +       the index of the super project and the working tree of the submodule\n>         (this option doesn't allow to use the --cached option or to provide an\n>         explicit commit).\n\nYup, sentence this makes much more sense now ... :-)\n\nShall i send an updated patch?\n\n\nJens\n"}]}