{"thread":{"id":"12566","subject":"[PATCH v3 4/4] git-submodule summary: documentation","startedAt":"2008-03-07T18:27:16Z","lastAt":"2008-03-09T13:12:57Z","messageCount":6,"participants":["Ping Yin","Junio C Hamano"],"isPatch":true,"patchVersion":3,"patchTotal":4},"messages":[{"id":"71366","messageId":"1204914439-23145-1-git-send-email-pkufranky@gmail.com","threadId":"12566","inReplyTo":null,"subject":"[PATCH v3 1/4] git-submodule summary: code framework","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-07T18:27:16Z","receivedAt":"2008-03-07T18:27:16Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Following patches will teach git-submodule a new subcommand 'summary' to\nshow commit summary of user-cared (i.e. checked out) submodules between\na given super project commit (default to HEAD) and working tree\n(or index, switched by --cached).\n\nThis patch just introduces the framework and find submodules which has\nsummary to show. A submodule will have summary if it fits into any one of\nfollowing cases.\n\n  - type 'M': modified and checked out    (1)\n  - type 'A': added and checked out       (2)\n  - type 'D': deleted\n  - type 'T': typechanged (blob <-> submodule)\n\nNote:\n  1. There may be modified but not checked out cases. In the case of a\n     merge conflict, even if the submodule is not checked out, there may\n\t be still a diff between index and HEAD on the submodule entry\n\t (i.e. modified). The summary will not be show for such a submodule.\n  2. A similar explanation applies to the added but not checked out case.\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n git-submodule.sh |   61 +++++++++++++++++++++++++++++++++++++++++++++++++----\n 1 files changed, 56 insertions(+), 5 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex a6aaf40..0a48f57 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@@ -320,7 +320,58 @@ set_name_rev () {\n \t) )\n \ttest -z \"$revname\" || revname=\" ($revname)\"\n }\n+#\n+# Show commit summary for submodules in index or working tree\n+#\n+# If '--cached' is given, show summary between index and given commit,\n+# or between working tree and given commit\n+#\n+# $@ = [commit (default 'HEAD'),] requested paths (default all)\n+#\n+cmd_summary() {\n+\t# parse $args after \"submodule ... summary\".\n+\twhile test $# -ne 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t--cached)\n+\t\t\tcached=\"$1\"\n+\t\t\t;;\n+\t\t--)\n+\t\t\tshift\n+\t\t\tbreak\n+\t\t\t;;\n+\t\t-*)\n+\t\t\tusage\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\t\tshift\n+\tdone\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+\tcd_to_toplevel\n+\t# Get modified modules cared by user\n+\tmodules=$(git diff-index $cached --raw $head -- \"$@\" |\n+\t\tgrep -e '^:160000' -e '^:[0-7]* 160000' |\n+\t\twhile read mod_src mod_dst sha1_src sha1_dst status name\n+\t\tdo\n+\t\t\t# Always show modules deleted or type-changed (blob<->module)\n+\t\t\ttest $status = D -o $status = T && echo \"$name\" && continue\n+\t\t\t# Also show added or modified modules which are checked out\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 #\n # List all submodules, prefixed with:\n #  - submodule not initialized\n@@ -391,7 +442,7 @@ cmd_status()\n while test $# != 0 && test -z \"$command\"\n do\n \tcase \"$1\" in\n-\tadd | init | update | status)\n+\tadd | init | update | status | summary)\n \t\tcommand=$1\n \t\t;;\n \t-q|--quiet)\n@@ -406,7 +457,7 @@ do\n \t\tbranch=\"$2\"; shift\n \t\t;;\n \t--cached)\n-\t\tcached=1\n+\t\tcached=\"$1\"\n \t\t;;\n \t--)\n \t\tbreak\n@@ -430,8 +481,8 @@ then\n \tusage\n fi\n \n-# \"--cached\" is accepted only by \"status\"\n-if test -n \"$cached\" && test \"$command\" != status\n+# \"--cached\" is accepted only by \"status\" and \"summary\"\n+if test -n \"$cached\" && test \"$command\" != status -a \"$command\" != summary\n then\n \tusage\n fi\n-- \n1.5.4.3.347.g5314c\n\n"},{"id":"71367","messageId":"1204914439-23145-2-git-send-email-pkufranky@gmail.com","threadId":"12566","inReplyTo":"1204914439-23145-1-git-send-email-pkufranky@gmail.com","subject":"[PATCH v3 2/4] git-submodule summary: show commit summary","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-07T18:27:17Z","receivedAt":"2008-03-07T18:27:17Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"This patch does the hard work to show submodule commit summary.\n\nFor a modified submodule, a series of commits will be shown with\nthe following command\n\n\tgit log --pretty='format:%m %s' --left-right \\\n\t--first-parent sha1_src...sha1_dst\n\nwhere the src sha1 is from the given super project commit and the\ndst sha1 is from the index or working tree (switched by --cached).\n\nFor a deleted, added, or typechanged (blob<->submodule) submodule,\nonly one single newest commit from the existing end (for example,\nsrc end for submodule deleted or type changed from submodule to blob)\nwill be shown.\n\nIf the src/dst sha1 for a submodule is missing in the submodule\ndirectory, a warning will be issued except in two cases where the\nsubmodule directory is deleted (type 'D') or typechanged to blob\n(one case of type 'T').\n\nIn the title line for a submodule, the src/dst sha1 and the number\nof commits (--first-parent) between the two sha1s will be shown.\n\nThe following example demonstrates most cases.\n\nExample: commit summary for modified submodules sm1-sm5.\n--------------------------------------------\n$ git submodule summary\n* sm1 354cd45...3f751e5 (4):\n  < one line message for C\n  < one line message for B\n  > one line message for D\n  > one line message for E\n\n* sm2 5c8bfb5...000000 (3):\n  < one line message for F\n\n* sm3 354cd45...3f751e5:\n  Warn: sm3 doesn't contain commit 354cd45\n\n* sm4 354cd34(submodule)-> 235efa(blob) (1):\n  < one line message for G\n\n* sm5 354cd34(blob)-> 235efa(submodule) (5):\n  > one line message for H\n\n--------------------------------------------\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n git-submodule.sh |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 88 insertions(+), 0 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 0a48f57..1751ab2 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -371,6 +371,94 @@ cmd_summary() {\n \t\t\techo \"$name\"\n \t\tdone\n \t)\n+\n+\ttest -n \"$modules\" &&\n+\tgit diff-index $cached --raw $head -- $modules |\n+\tgrep -e '^:160000' -e '^:[0-7]* 160000' |\n+\tcut -c2- |\n+\twhile read mod_src mod_dst sha1_src sha1_dst status name\n+\tdo\n+\t\tif test -z \"$cached\" &&\n+\t\t\ttest $sha1_dst = 0000000000000000000000000000000000000000\n+\t\tthen\n+\t\t\tsha1_dst=$(GIT_DIR=\"$name/.git\" git rev-parse HEAD) || continue\n+\t\tfi\n+\t\tmissing_src=\n+\t\tmissing_dst=\n+\n+\t\ttest $mod_src = 160000 &&\n+\t\t! GIT_DIR=\"$name/.git\" git-rev-parse --verify $sha1_src^0 >/dev/null 2>&1 &&\n+\t\tmissing_src=t\n+\n+\t\ttest $mod_dst = 160000 &&\n+\t\t! GIT_DIR=\"$name/.git\" git-rev-parse --verify $sha1_dst^0 >/dev/null 2>&1 &&\n+\t\tmissing_dst=t\n+\n+\t\ttotal_commits=\n+\t\tcase \"$missing_src,$missing_dst\" in\n+\t\tt,)\n+\t\t\terrmsg=\"  Warn: $name doesn't contain commit $sha1_src\"\n+\t\t\t;;\n+\t\t,t)\n+\t\t\terrmsg=\"  Warn: $name doesn't contain commit $sha1_dst\"\n+\t\t\t;;\n+\t\tt,t)\n+\t\t\terrmsg=\"  Warn: $name doesn't contain commits $sha1_src and $sha1_dst\"\n+\t\t\t;;\n+\t\t*)\n+\t\t\terrmsg=\n+\t\t\ttotal_commits=$(\n+\t\t\tif test $mod_src = 160000 -a $mod_dst = 160000\n+\t\t\tthen\n+\t\t\t\trange=\"$sha1_src...$sha1_dst\"\n+\t\t\telif test $mod_src = 160000\n+\t\t\tthen\n+\t\t\t\trange=$sha1_src\n+\t\t\telse\n+\t\t\t\trange=$sha1_dst\n+\t\t\tfi\n+\t\t\tGIT_DIR=\"$name/.git\" \\\n+\t\t\tgit log --pretty=oneline --first-parent $range | wc -l\n+\t\t\t)\n+\t\t\ttotal_commits=\" ($total_commits)\"\n+\t\t\t;;\n+\t\tesac\n+\n+\t\tsha1_abbr_src=$(echo $sha1_src | cut -c1-7)\n+\t\tsha1_abbr_dst=$(echo $sha1_dst | cut -c1-7)\n+\t\tif test $status = T\n+\t\tthen\n+\t\t\tif test $mod_dst = 160000\n+\t\t\tthen\n+\t\t\t\techo \"* $name $sha1_abbr_src(blob)->$sha1_abbr_dst(submodule)$total_commits:\"\n+\t\t\telse\n+\t\t\t\techo \"* $name $sha1_abbr_src(submodule)->$sha1_abbr_dst(blob)$total_commits:\"\n+\t\t\tfi\n+\t\telse\n+\t\t\techo \"* $name $sha1_abbr_src...$sha1_abbr_dst$total_commits:\"\n+\t\tfi\n+\t\tif test -n \"$errmsg\"\n+\t\tthen\n+\t\t\t# Don't give error msg for modification whose dst is not submodule\n+\t\t\t# i.e. deleted or changed to blob\n+\t\t\ttest $mod_dst = 160000 && echo \"$errmsg\"\n+\t\telse\n+\t\t\tif test $mod_src = 160000 -a $mod_dst = 160000\n+\t\t\tthen\n+\t\t\t\tGIT_DIR=\"$name/.git\" \\\n+\t\t\t\tgit log --pretty='format:  %m %s' \\\n+\t\t\t\t--left-right --first-parent $sha1_src...$sha1_dst\n+\t\t\telif test $mod_dst = 160000\n+\t\t\tthen\n+\t\t\t\tGIT_DIR=\"$name/.git\" \\\n+\t\t\t\tgit log --pretty='format:  > %h %s' -1 $sha1_dst\n+\t\t\telse\n+\t\t\t\tGIT_DIR=\"$name/.git\" \\\n+\t\t\t\tgit log --pretty='format:  < %h %s' -1 $sha1_src\n+\t\t\tfi\n+\t\tfi\n+\t\techo\n+\tdone\n }\n #\n # List all submodules, prefixed with:\n-- \n1.5.4.3.347.g5314c\n\n"},{"id":"71368","messageId":"1204914439-23145-3-git-send-email-pkufranky@gmail.com","threadId":"12566","inReplyTo":"1204914439-23145-2-git-send-email-pkufranky@gmail.com","subject":"[PATCH v3 3/4] git-submodule summary: limit summary size","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-07T18:27:18Z","receivedAt":"2008-03-07T18:27:18Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"This patch teaches git-submodule an option '--summary-limit|-n <number>'\nto limit number of commits in total for the summary of each submodule in\nthe modified case (only a single commit is shown in other cases).\n\nNumber 0 will disable summary and minus number means unlimted (the default).\n\nSigned-off-by: Ping Yin <pkufranky@gmail.com>\n---\n git-submodule.sh |   21 +++++++++++++++++++--\n 1 files changed, 19 insertions(+), 2 deletions(-)\n\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex 1751ab2..d0a0205 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -4,7 +4,9 @@\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+[add <repo> [-b branch]|status|init|update|summary [-n|--summary-limit <n>] [<commit>]] \\\n+[--] [<path>...]\"\n OPTIONS_SPEC=\n . git-sh-setup\n require_work_tree\n@@ -329,6 +331,8 @@ set_name_rev () {\n # $@ = [commit (default 'HEAD'),] requested paths (default all)\n #\n cmd_summary() {\n+\tsummary_limit=-1\n+\n \t# parse $args after \"submodule ... summary\".\n \twhile test $# -ne 0\n \tdo\n@@ -336,6 +340,15 @@ cmd_summary() {\n \t\t--cached)\n \t\t\tcached=\"$1\"\n \t\t\t;;\n+\t\t-n|--summary-limit)\n+\t\t\tif summary_limit=$(($2 + 0)) 2>/dev/null && test \"$summary_limit\" = \"$2\"\n+\t\t\tthen\n+\t\t\t\t:\n+\t\t\telse\n+\t\t\t\tusage\n+\t\t\tfi\n+\t\t\tshift\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -350,6 +363,8 @@ cmd_summary() {\n \t\tshift\n \tdone\n \n+\ttest $summary_limit = 0 && return\n+\n \tif rev=$(git rev-parse --verify \"$1^0\" 2>/dev/null)\n \tthen\n \t\thead=$rev\n@@ -445,8 +460,10 @@ cmd_summary() {\n \t\telse\n \t\t\tif test $mod_src = 160000 -a $mod_dst = 160000\n \t\t\tthen\n+\t\t\t\tlimit=\n+\t\t\t\ttest $summary_limit -gt 0 && limit=\"-$summary_limit\"\n \t\t\t\tGIT_DIR=\"$name/.git\" \\\n-\t\t\t\tgit log --pretty='format:  %m %s' \\\n+\t\t\t\tgit log $limit --pretty='format:  %m %s' \\\n \t\t\t\t--left-right --first-parent $sha1_src...$sha1_dst\n \t\t\telif test $mod_dst = 160000\n \t\t\tthen\n-- \n1.5.4.3.347.g5314c\n\n"},{"id":"71365","messageId":"1204914439-23145-4-git-send-email-pkufranky@gmail.com","threadId":"12566","inReplyTo":"1204914439-23145-3-git-send-email-pkufranky@gmail.com","subject":"[PATCH v3 4/4] git-submodule summary: documentation","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-07T18:27:19Z","receivedAt":"2008-03-07T18:27:19Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"Signed-off-by: Ping Yin <pkufranky@gmail.com>\n---\n Documentation/git-submodule.txt |   22 +++++++++++++++++++---\n 1 files changed, 19 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex e818e6e..4fbc182 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -12,6 +12,7 @@ SYNOPSIS\n 'git-submodule' [--quiet] add [-b branch] [--] <repository> [<path>]\n 'git-submodule' [--quiet] status [--cached] [--] [<path>...]\n 'git-submodule' [--quiet] [init|update] [--] [<path>...]\n+'git-submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]\n \n \n COMMANDS\n@@ -46,6 +47,12 @@ update::\n \tcheckout the commit specified in the index of the containing repository.\n \tThis will make the submodules HEAD be detached.\n \n+summary::\n+\tShow commit summary between given commit (default to HEAD) and\n+\tworking tree/index. For a submodule in question, a series of commits\n+\tbetween src sha1 and dst sha1 will be shown where src sha1 is from the\n+\tgiven super project commit and dst sha1 is from the index or working\n+\ttree (switched by --cached).\n \n OPTIONS\n -------\n@@ -56,9 +63,18 @@ OPTIONS\n \tBranch of repository to add as submodule.\n \n --cached::\n-\tDisplay the SHA-1 stored in the index, not the SHA-1 of the currently\n-\tchecked out submodule commit. This option is only valid for the\n-\tstatus command.\n+\tThis option is only valid for commands status and summary.\n+\tWhen combined with status, display the SHA-1 stored in the index,\n+\tnot the SHA-1 of the currently checked out submodule commit. When\n+\tcombined with summary, switch dst comparison side from working\n+\ttree to index.\n+\n+-n, --summary-limit::\n+\tThis option is only valid for the summary command.\n+\tLimit the summary size (number of commits shown in total).\n+\tNumber 0 will disable summary and minus number means unlimted\n+\t(the default). This limit only applies to modified submodules. The\n+\tsize is always limited to 1 for added/deleted/typechanged submodules.\n \n <path>::\n \tPath to submodule(s). When specified this will restrict the command\n-- \n1.5.4.3.347.g5314c\n\n"},{"id":"71410","messageId":"7vpru5v9mx.fsf@gitster.siamese.dyndns.org","threadId":"12566","inReplyTo":"1204914439-23145-4-git-send-email-pkufranky@gmail.com","subject":"Re: [PATCH v3 4/4] git-submodule summary: documentation","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-08T09:37:58Z","receivedAt":"2008-03-08T09:37:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"I've replaced the previous series in 'pu' with this series and queued in\n'pu', but with a few wording fixes.\n\nI didn't closely look at the script itself yet.  I thinkthe series is\ngetting closer to a mergeable shape, but it needs tests.\n\n Documentation/git-submodule.txt |   17 +++++++----------\n 1 files changed, 7 insertions(+), 10 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 4fbc182..e96bf36 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -48,11 +48,10 @@ update::\n \tThis will make the submodules HEAD be detached.\n \n summary::\n-\tShow commit summary between given commit (default to HEAD) and\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-\tbetween src sha1 and dst sha1 will be shown where src sha1 is from the\n-\tgiven super project commit and dst sha1 is from the index or working\n-\ttree (switched by --cached).\n+\tin the submodule between the given super project commit and the\n+\tindex or working tree (switched by --cached) are shown.\n \n OPTIONS\n -------\n@@ -63,16 +62,14 @@ OPTIONS\n \tBranch of repository to add as submodule.\n \n --cached::\n-\tThis option is only valid for commands status and summary.\n-\tWhen combined with status, display the SHA-1 stored in the index,\n-\tnot the SHA-1 of the currently checked out submodule commit. When\n-\tcombined with summary, switch dst comparison side from working\n-\ttree to index.\n+\tThis option is only valid for status and summary commands.  These\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 -n, --summary-limit::\n \tThis option is only valid for the summary command.\n \tLimit the summary size (number of commits shown in total).\n-\tNumber 0 will disable summary and minus number means unlimted\n+\tGiving 0 will disable the summary; a negative number means unlimted\n \t(the default). This limit only applies to modified submodules. The\n \tsize is always limited to 1 for added/deleted/typechanged submodules.\n \n\n\n\n"},{"id":"71515","messageId":"46dff0320803090612g5b334a16hac91cbf6864bb9da@mail.gmail.com","threadId":"12566","inReplyTo":"7vpru5v9mx.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v3 4/4] git-submodule summary: documentation","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-03-09T13:12:57Z","receivedAt":"2008-03-09T13:12:57Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Sat, Mar 8, 2008 at 5:37 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> I've replaced the previous series in 'pu' with this series and queued in\n>  'pu', but with a few wording fixes.\n>\n>  I didn't closely look at the script itself yet.  I thinkthe series is\n>  getting closer to a mergeable shape, but it needs tests.\n\nI will send my tests tommorrow\n\n\n>\n>\n>\n>\n\n\n\n-- \nPing Yin\n"}]}