{"thread":{"id":"11439","subject":"[PATCH] git-submodule: New subcommand 'summary'","startedAt":"2007-12-31T17:35:02Z","lastAt":"2008-01-09T02:25:56Z","messageCount":6,"participants":["Ping Yin","Imran M Yousuf"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"64273","messageId":"1199122505-27478-1-git-send-email-pkufranky@gmail.com","threadId":"11439","inReplyTo":null,"subject":"[PATCH] git-submodule: New subcommand 'summary'","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-12-31T17:35:02Z","receivedAt":"2007-12-31T17:35:02Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"The patch series ( 3 in total) teach git-submodule a new subcommand 'summary'.\n\nPATCH 1 introduces the code framework.\n\nPATCH 2 does the real work for summary.\n\nPATCH 3 teaches a new option '--summary-limit|-n'.\n"},{"id":"64275","messageId":"1199122505-27478-2-git-send-email-pkufranky@gmail.com","threadId":"11439","inReplyTo":"1199122505-27478-1-git-send-email-pkufranky@gmail.com","subject":"[PATCH] git-submodule: New subcommand 'summary' (1) - code framework","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-12-31T17:35:03Z","receivedAt":"2007-12-31T17:35:03Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Following patches teach git-submodule a new subcommand 'summary' to show\ncommit summary of user-cared (i.e. checked out) submodules since a given\ncommit (default HEAD) of super project.\n\nFor a submodule in question, a series of commits will be shown as the path\nfrom the src commit to the dst commit, where the src commit is from the given\nsuper project commit, and the dst commit is from the index or working tree\n(switched by --cached).\n\nFollowing is an example of the output\n\t# Submodules modifiled: sm1 sm2 sm3\n\t#\n\t# * sm1 354cd45...3f751e5:\n\t#   <one line message for C\n\t#   <one line message for B\n\t#   >one line message for D\n\t#   >one line message for E\n\t#\n\t# * sm2 5c8bfb5...000000:\n\t#   <one line message for F\n\t#\n\t# * sm3 354cd45...3f751e5:\n\t#   Warn: sm3 doesn't contain commit 354cd45\n\t#\n\nThis superproject shown above has modified/deleted submodules sm1 to sm3.\n\nsm1 has commit C as src (given commit or HEAD) and commit E as dst (index\nor working tree) as following picture shows.\n\t--A-->B-->C (in src:354cd45)\n\t  \\\n\t   -->D-->E (in dst:3f751e5)\n\nThe 'Submodules modified' section for sm1 shows how to change sm1 from\nsrc commit C to dst commit E: firstly backward (<) to commit A from\ncommit C via commit B, and then forward (>) to commit E via commit D.\n\nIllustration for output of deleted sm2 is similar.\n\nIf the src/dst commit for a submodule is not found in the work tree (say\nthe submodule respository in the work tree), a warning will be issued.\nsm3 falls into this case.\n\nThis patch just gives the framework. It just finds the submodules to be\nshown as follows.\n\t# Submodules modifiled: sm1 sm2 sm3\n\t#\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n git-submodule.sh |   57 ++++++++++++++++++++++++++++++++++++++++++++++++-----\n 1 files changed, 51 insertions(+), 6 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex ad9fe62..0e81484 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] [add <repo> [-b branch]|status|init|update] [--] [<path>...]'\n+USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update|summary <commit>] [--] [<path>...]'\n OPTIONS_SPEC=\n . git-sh-setup\n require_work_tree\n@@ -255,7 +255,46 @@ set_name_rev () {\n \t) )\n \ttest -z \"$revname\" || revname=\" ($revname)\"\n }\n+#\n+# Show commit summary for submodules in index or working tree relative to the given commit\n+#\n+# If '--cached' is given, show summary between index and given commit,\n+# or between working tree and given commit\n+#\n+# @ = [head counting commits from (default 'HEAD'),] requested paths (default to all)\n+#\n+modules_summary()\n+{\n+\tcache_option=${cached:+--cached}\n+\n+\tif rev=$(git rev-parse --verify \"$1^0\" 2>/dev/null)\n+\tthen\n+\t\thead=$rev\n+\t\tshift\n+\telse\n+\t\thead=HEAD\n+\tfi\n \n+\tcwd=$(pwd)\n+\tcd_to_toplevel\n+\n+\t# get modified modules which have been checked out (i.e. cared by user)\n+\tmodules=$(git diff $cache_option --raw $head -- \"$@\" |\n+\t\tgrep '^:160000\\|:000000 160000' |\n+\t\twhile read mod_src mod_dst sha1_src sha1_dst status name\n+\t\tdo\n+\t\t\ttest $status=D && echo \"$name\" && continue\n+\t\t\tGIT_DIR=\"$name/.git\" git-rev-parse --git-dir >/dev/null 2>&1 &&\n+\t\t\techo \"$name\"\n+\t\tdone\n+\t)\n+\n+\t# TODO: quote module names containing space or tab\n+\ttest -n \"$modules\" &&\n+\techo \"# Submodules modified: \"$modules &&\n+\techo \"#\"\n+\tcd \"$cwd\"\n+}\n #\n # List all submodules, prefixed with:\n #  - submodule not initialized\n@@ -305,6 +344,9 @@ do\n \tupdate)\n \t\tupdate=1\n \t\t;;\n+\tsummary)\n+\t\tsummary=1\n+\t\t;;\n \tstatus)\n \t\tstatus=1\n \t\t;;\n@@ -345,17 +387,20 @@ case \"$add,$branch\" in\n \t;;\n esac\n \n-case \"$add,$init,$update,$status,$cached\" in\n-1,,,,)\n+case \"$add,$init,$update,$summary,$status,$cached\" in\n+1,,,,,)\n \tmodule_add \"$@\"\n \t;;\n-,1,,,)\n+,1,,,,)\n \tmodules_init \"$@\"\n \t;;\n-,,1,,)\n+,,1,,,)\n \tmodules_update \"$@\"\n \t;;\n-,,,*,*)\n+,,,1,,*)\n+\tmodules_summary \"$@\"\n+\t;;\n+,,,,*,*)\n \tmodules_list \"$@\"\n \t;;\n *)\n-- \n1.5.4.rc2.9.gf5146-dirty\n"},{"id":"64276","messageId":"1199122505-27478-3-git-send-email-pkufranky@gmail.com","threadId":"11439","inReplyTo":"1199122505-27478-1-git-send-email-pkufranky@gmail.com","subject":"[PATCH] git-submodule: New subcommand 'summary' (2) - hard work","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-12-31T17:35:04Z","receivedAt":"2007-12-31T17:35:04Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"This patch does the hard work of submodule summary and finally gives\noutput shown in last patch.\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n git-submodule.sh |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 files changed, 67 insertions(+), 1 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 0e81484..cccb539 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -292,7 +292,73 @@ modules_summary()\n \t# TODO: quote module names containing space or tab\n \ttest -n \"$modules\" &&\n \techo \"# Submodules modified: \"$modules &&\n-\techo \"#\"\n+\techo \"#\" &&\n+\tgit diff $cache_option --raw $head -- $modules |\n+\tgrep '^:160000\\|:000000 160000' |\n+\tcut -c2- |\n+\twhile read mod_src mod_dst sha1_src sha1_dst status name\n+\tdo\n+\t\tsha1_dst=$(echo $sha1_dst | cut -c1-7)\n+\t\tsha1_src=$(echo $sha1_src | cut -c1-7)\n+\t\tcheck_dst=t\n+\t\tcheck_src=t\n+\t\tcase $status in\n+\t\tD)\n+\t\t\tcheck_dst=\n+\t\t\t;;\n+\t\tA)\n+\t\t\tcheck_src=\n+\t\t\t;;\n+\t\tesac\n+\n+\t\t(\n+\t\t\terrmsg=\n+\t\t\tunfound_src=\n+\t\t\tunfound_dst=\n+\n+\t\t\ttest -z \"$check_src\" ||\n+\t\t\tGIT_DIR=\"$name/.git\" git-rev-parse $sha1_src >&/dev/null ||\n+\t\t\tunfound_src=t\n+\n+\t\t\ttest -z \"$check_dst\" ||\n+\t\t\tGIT_DIR=\"$name/.git\" git-rev-parse $sha1_dst >&/dev/null ||\n+\t\t\tunfound_dst=t\n+\n+\t\t\tcase \"$unfound_src,$unfound_dst\" in\n+\t\t\tt,)\n+\t\t\t\terrmsg=\"  Warn: $name doesn't contain commit $sha1_src\"\n+\t\t\t\t;;\n+\t\t\t,t)\n+\t\t\t\terrmsg=\"  Warn: $name doesn't contain commit $sha1_dst\"\n+\t\t\t\t;;\n+\t\t\tt,t)\n+\t\t\t\terrmsg=\"  Warn: $name doesn't contain commits $sha1_src and $sha1_dst\"\n+\t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\tleft=\n+\t\t\t\tright=\n+\t\t\t\ttest -n \"$check_src\" &&\n+\t\t\t\tleft=$(GIT_DIR=\"$name/.git\" git log --pretty=format:\"  <%s\" \\\n+\t\t\t\t${check_dst:+$sha1_dst..}$sha1_src 2>/dev/null)\n+\n+\t\t\t\ttest -n \"$check_dst\" &&\n+\t\t\t\tright=$(GIT_DIR=\"$name/.git\" git log --reverse --pretty=format:\"  >%s\" \\\n+\t\t\t\t${check_src:+$sha1_src..}$sha1_dst 2>/dev/null)\n+\t\t\t\t;;\n+\t\t\tesac\n+\n+\t\t\techo \"* $name $sha1_src...$sha1_dst:\"\n+\t\t\tif test -n \"$errmsg\"\n+\t\t\tthen\n+\t\t\t\techo \"$errmsg\"\n+\t\t\telse\n+\t\t\t\ttest -n \"$left\" && echo \"$left\"\n+\t\t\t\ttest -n \"$right\" && echo \"$right\"\n+\t\t\tfi\n+\t\t\techo\n+\t\t) | sed 's/^/# /'\n+\tdone\n+\n \tcd \"$cwd\"\n }\n #\n-- \n1.5.4.rc2.9.gf5146-dirty\n"},{"id":"64274","messageId":"1199122505-27478-4-git-send-email-pkufranky@gmail.com","threadId":"11439","inReplyTo":"1199122505-27478-1-git-send-email-pkufranky@gmail.com","subject":"[PATCH] git-submodule: New subcommand 'summary' (3) - limit summary size","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2007-12-31T17:35:05Z","receivedAt":"2007-12-31T17:35:05Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"This patches teaches git-submodule an option '--summary-limit|-n <number>'\nto limit number of commits for the summary. Number 0 will disable summary\nand minus number will not limit the summary size.\n\nFor beauty and clarification, the last commit for each section (backward\nand forward) will always be shown disregarding the given limit. So actual\nsummary size may be greater than the given limit.\n\nIn the same super project of these patch series, 'git submodule -n 2' and\n'git submodule -n 3' will both show\n    # Submodules modifiled: sm1 sm2 sm3\n    #\n    # * sm1 354cd45...3f751e5:\n    #   <one line message for C\n    #   <one line message for B\n    #   >... (1 more)\n    #   >one line message for E\n    #\n    # * sm2 5c8bfb5...000000:\n    #   <one line message for F\n    #\n    # * sm3 354cd45...3f751e5:\n    #   Warn: sm3 doesn't contain commit 354cd45\n    #\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n git-submodule.sh |   40 +++++++++++++++++++++++++++++++++++++---\n 1 files changed, 37 insertions(+), 3 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex cccb539..58d0243 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -4,7 +4,8 @@\n #\n # Copyright (c) 2007 Lars Hjemli\n \n-USAGE='[--quiet] [--cached] [add <repo> [-b branch]|status|init|update|summary <commit>] [--] [<path>...]'\n+USAGE=\"[--quiet] [--cached] [-n|--summary-limit <number>] \\\n+[add <repo> [-b branch]|status|init|update|summary <commit>] [--] [<path>...]\"\n OPTIONS_SPEC=\n . git-sh-setup\n require_work_tree\n@@ -16,6 +17,7 @@ update=\n status=\n quiet=\n cached=\n+summary_limit=\n \n #\n # print stuff on stdout unless -q was specified\n@@ -265,6 +267,10 @@ set_name_rev () {\n #\n modules_summary()\n {\n+\tsummary_limit=${summary_limit:-1000000}\n+\tsummary_limit=$((summary_limit<0?1000000:summary_limit))\n+\ttest $summary_limit = 0 && return\n+\n \tcache_option=${cached:+--cached}\n \n \tif rev=$(git rev-parse --verify \"$1^0\" 2>/dev/null)\n@@ -352,8 +358,29 @@ modules_summary()\n \t\t\tthen\n \t\t\t\techo \"$errmsg\"\n \t\t\telse\n-\t\t\t\ttest -n \"$left\" && echo \"$left\"\n-\t\t\t\ttest -n \"$right\" && echo \"$right\"\n+\t\t\t\tlc0=0\n+\t\t\t\trc0=0\n+\t\t\t\ttest -n \"$left\" && lc0=$(echo \"$left\" | wc -l)\n+\t\t\t\ttest -n \"$right\" && rc0=$(echo \"$right\" | wc -l)\n+\t\t\t\tlc=$((lc0<summary_limit?lc0:summary_limit))\n+\t\t\t\trc=$((summary_limit>lc?summary_limit-lc:1))\n+\t\t\t\trc=$((rc<rc0?rc:rc0))\n+\n+\t\t\t\tif test -n \"$left\"\n+\t\t\t\tthen\n+\t\t\t\t\tskip=$((lc0-lc))\n+\t\t\t\t\techo \"$left\" | head -$((lc-1))\n+\t\t\t\t\ttest $skip != 0 && echo \"  <... ($skip more)\"\n+\t\t\t\t\techo \"$left\" | tail -1\n+\t\t\t\tfi\n+\n+\t\t\t\tif test -n \"$right\"\n+\t\t\t\tthen\n+\t\t\t\t\tskip=$((rc0-rc))\n+\t\t\t\t\techo \"$right\" | head -$((rc-1))\n+\t\t\t\t\ttest $skip != 0 && echo \"  >... ($skip more)\"\n+\t\t\t\t\techo \"$right\" | tail -1\n+\t\t\t\tfi\n \t\t\tfi\n \t\t\techo\n \t\t) | sed 's/^/# /'\n@@ -430,6 +457,13 @@ do\n \t--cached)\n \t\tcached=1\n \t\t;;\n+\t-n|--summary-limit)\n+\t\tif [ -z \"$2\" ]; then\n+\t\t\tusage\n+\t\tfi\n+\t\tsummary_limit=\"$2\"\n+\t\tshift\n+\t\t;;\n \t--)\n \t\tbreak\n \t\t;;\n-- \n1.5.4.rc2.9.gf5146-dirty\n"},{"id":"64730","messageId":"46dff0320801080420v6295939aw86a6cba3ceb8c076@mail.gmail.com","threadId":"11439","inReplyTo":"1199122505-27478-1-git-send-email-pkufranky@gmail.com","subject":"Re: [PATCH] git-submodule: New subcommand 'summary'","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-01-08T12:20:35Z","receivedAt":"2008-01-08T12:20:35Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Any comment to my patch?\n\nFollowing this i will give patches to introduce submodule summary\nfunction into git-commit\n\nOn Jan 1, 2008 1:35 AM, Ping Yin <pkufranky@gmail.com> wrote:\n> The patch series ( 3 in total) teach git-submodule a new subcommand 'summary'.\n>\n> PATCH 1 introduces the code framework.\n>\n> PATCH 2 does the real work for summary.\n>\n> PATCH 3 teaches a new option '--summary-limit|-n'.\n>\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n\n-- \nPing Yin\n"},{"id":"64803","messageId":"7bfdc29a0801081825ue3b51f1p29c8199287aad66b@mail.gmail.com","threadId":"11439","inReplyTo":"46dff0320801080420v6295939aw86a6cba3ceb8c076@mail.gmail.com","subject":"Re: [PATCH] git-submodule: New subcommand 'summary'","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-01-09T02:25:56Z","receivedAt":"2008-01-09T02:25:56Z","isPatch":true,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"Hi Ping,\n\nThough I am not a expert on this myself but from my recent experience\nfrom patches I would request you to have a look at\nDocumentation/Submitting patches.\nhttp://repo.or.cz/w/git.git?a=blob;f=Documentation/SubmittingPatches;hb=HEAD\n\nBest regards,\n\nImran\n\nOn Jan 8, 2008 6:20 PM, Ping Yin <pkufranky@gmail.com> wrote:\n> Any comment to my patch?\n>\n> Following this i will give patches to introduce submodule summary\n> function into git-commit\n>\n>\n> On Jan 1, 2008 1:35 AM, Ping Yin <pkufranky@gmail.com> wrote:\n> > The patch series ( 3 in total) teach git-submodule a new subcommand 'summary'.\n> >\n> > PATCH 1 introduces the code framework.\n> >\n> > PATCH 2 does the real work for summary.\n> >\n> > PATCH 3 teaches a new option '--summary-limit|-n'.\n> >\n> > -\n> > To unsubscribe from this list: send the line \"unsubscribe git\" in\n> > the body of a message to majordomo@vger.kernel.org\n> > More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> >\n>\n>\n>\n> --\n> Ping Yin\n>\n> -\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n\n-- \nImran M Yousuf\nEntrepreneur & Software Engineer\nSmart IT Engineering\nDhaka, Bangladesh\nEmail: imran@smartitengineering.com\nMobile: +880-1711402557\n"}]}