{"thread":{"id":"36143","subject":"[PATCH] submodule: add verbose mode for add/update","startedAt":"2014-03-12T20:03:45Z","lastAt":"2014-03-12T20:19:59Z","messageCount":2,"participants":["Orgad Shaneh","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"236617","messageId":"1394654625-4586-1-git-send-email-orgads@gmail.com","threadId":"36143","inReplyTo":null,"subject":"[PATCH] submodule: add verbose mode for add/update","fromName":"Orgad Shaneh","fromEmail":"orgads@gmail.com","sentAt":"2014-03-12T20:03:45Z","receivedAt":"2014-03-12T20:03:45Z","isPatch":true,"sender":{"key":"orgads@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1246544?v=4"},"body":"Add the verbose flag to add and update which displays the\nprogress of the actual submodule checkout when given. This\nis useful for checkouts that take a long time, as the user\ncan then see the progress.\n\nSigned-off-by: Orgad Shaneh <orgads@gmail.com>\n---\n Documentation/git-submodule.txt |  7 +++++--\n git-submodule.sh                | 24 +++++++++++++++++++-----\n t/t7406-submodule-update.sh     | 10 ++++++++++\n 3 files changed, 34 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 21cb59a..0147b23 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -10,13 +10,13 @@ SYNOPSIS\n --------\n [verse]\n 'git submodule' [--quiet] add [-b <branch>] [-f|--force] [--name <name>]\n-\t      [--reference <repository>] [--depth <depth>] [--] <repository> [<path>]\n+\t      [--reference <repository>] [--depth <depth>] [-v|--verbose] [--] <repository> [<path>]\n 'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...]\n 'git submodule' [--quiet] init [--] [<path>...]\n 'git submodule' [--quiet] deinit [-f|--force] [--] <path>...\n 'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch]\n \t      [-f|--force] [--rebase|--merge|--checkout] [--reference <repository>]\n-\t      [--depth <depth>] [--recursive] [--] [<path>...]\n+\t      [--depth <depth>] [--recursive] [-v|--verbose] [--] [<path>...]\n 'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) <n>]\n \t      [commit] [--] [<path>...]\n 'git submodule' [--quiet] foreach [--recursive] <command>\n@@ -363,6 +363,9 @@ for linkgit:git-clone[1]'s `--reference` and `--shared` options carefully.\n \tclone with a history truncated to the specified number of revisions.\n \tSee linkgit:git-clone[1]\n \n+--verbose::\n+\tThis option is valid for add and update commands. Display the progress\n+\tof the actual submodule\tcheckout.\n \n <path>...::\n \tPaths to submodule(s). When specified this will restrict the command\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex a33f68d..e1df2c8 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -5,11 +5,11 @@\n # Copyright (c) 2007 Lars Hjemli\n \n dashless=$(basename \"$0\" | sed -e 's/-/ /')\n-USAGE=\"[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]\n+USAGE=\"[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [-v|--verbose] [--] <repository> [<path>]\n    or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]\n    or: $dashless [--quiet] init [--] [<path>...]\n    or: $dashless [--quiet] deinit [-f|--force] [--] <path>...\n-   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]\n+   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [-v|--verbose] [--] [<path>...]\n    or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]\n    or: $dashless [--quiet] foreach [--recursive] <command>\n    or: $dashless [--quiet] sync [--recursive] [--] [<path>...]\"\n@@ -319,12 +319,16 @@ module_clone()\n \trel=$(echo $a | sed -e 's|[^/][^/]*|..|g')\n \t(\n \t\tclear_local_git_env\n+\t\tif test -z \"$verbose\"\n+\t\tthen\n+\t\t\tsubquiet=-q\n+\t\tfi\n \t\tcd \"$sm_path\" &&\n \t\tGIT_WORK_TREE=. git config core.worktree \"$rel/$b\" &&\n \t\t# ash fails to wordsplit ${local_branch:+-B \"$local_branch\"...}\n \t\tcase \"$local_branch\" in\n-\t\t'') git checkout -f -q ${start_point:+\"$start_point\"} ;;\n-\t\t?*) git checkout -f -q -B \"$local_branch\" ${start_point:+\"$start_point\"} ;;\n+\t\t'') git checkout -f ${subquiet:+\"$subquiet\"} ${start_point:+\"$start_point\"} ;;\n+\t\t?*) git checkout -f ${subquiet:+\"$subquiet\"} -B \"$local_branch\" ${start_point:+\"$start_point\"} ;;\n \t\tesac\n \t) || die \"$(eval_gettext \"Unable to setup cloned submodule '\\$sm_path'\")\"\n }\n@@ -380,6 +384,9 @@ cmd_add()\n \t\t--depth=*)\n \t\t\tdepth=$1\n \t\t\t;;\n+\t\t-v|--verbose)\n+\t\t\tverbose=1\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -786,6 +793,9 @@ cmd_update()\n \t\t--depth=*)\n \t\t\tdepth=$1\n \t\t\t;;\n+\t\t-v|--verbose)\n+\t\t\tverbose=1\n+\t\t\t;;\n \t\t--)\n \t\t\tshift\n \t\t\tbreak\n@@ -913,7 +923,11 @@ Maybe you want to use 'update --init'?\")\"\n \t\t\tmust_die_on_failure=\n \t\t\tcase \"$update_module\" in\n \t\t\tcheckout)\n-\t\t\t\tcommand=\"git checkout $subforce -q\"\n+\t\t\t\tif test -z \"$verbose\"\n+\t\t\t\tthen\n+\t\t\t\t\tsubquiet=-q\n+\t\t\t\tfi\n+\t\t\t\tcommand=\"git checkout $subforce ${subquiet:+\"$subquiet\"}\"\n \t\t\t\tdie_msg=\"$(eval_gettext \"Unable to checkout '\\$sha1' in submodule path '\\$displaypath'\")\"\n \t\t\t\tsay_msg=\"$(eval_gettext \"Submodule path '\\$displaypath': checked out '\\$sha1'\")\"\n \t\t\t\t;;\ndiff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh\nindex 28ca763..c3de90a 100755\n--- a/t/t7406-submodule-update.sh\n+++ b/t/t7406-submodule-update.sh\n@@ -83,6 +83,16 @@ test_expect_success 'submodule update detaching the HEAD ' '\n \t)\n '\n \n+test_expect_success 'submodule update verbose' '\n+\t(cd super/submodule &&\n+\t git checkout master\n+\t) &&\n+\t(cd super &&\n+\t git submodule update --verbose submodule 2>messages &&\n+\t test_i18ngrep \"HEAD is now at\" messages\n+\t)\n+'\n+\n test_expect_success 'submodule update from subdirectory' '\n \t(cd super/submodule &&\n \t git reset --hard HEAD~1\n-- \n1.9.0\n"},{"id":"236624","messageId":"xmqqwqfzjhjk.fsf@gitster.dls.corp.google.com","threadId":"36143","inReplyTo":"1394654625-4586-1-git-send-email-orgads@gmail.com","subject":"Re: [PATCH] submodule: add verbose mode for add/update","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-03-12T20:19:59Z","receivedAt":"2014-03-12T20:19:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Orgad Shaneh <orgads@gmail.com> writes:\n\n> +--verbose::\n> +\tThis option is valid for add and update commands. Display the progress\n> +\tof the actual submodule\tcheckout.\n\nHmm, is the \"valid for add and update\" part we want to keep?  I do\nnot think it is a crime if some other subcommand accepted --verbose\noption but its output under verbose mode and normal mode happened to\nbe the same.\n\nI doubt it would take a lot of imagination to see that people would\nwant to see \"git submodule status --verbose\" to get richer output,\nand at that point, \"progress of checkout\" as part of the description\nof the \"--verbose\" option does not make any sense.  Perhaps the\nsecond part that is specific to \"add\" and \"update\" subcommands\nshould move to the description of these two subcommands?\n\nI dunno.\n\n> diff --git a/git-submodule.sh b/git-submodule.sh\n> index a33f68d..e1df2c8 100755\n> --- a/git-submodule.sh\n> +++ b/git-submodule.sh\n> @@ -5,11 +5,11 @@\n>  # Copyright (c) 2007 Lars Hjemli\n>  \n>  dashless=$(basename \"$0\" | sed -e 's/-/ /')\n> -USAGE=\"[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]\n> +USAGE=\"[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [-v|--verbose] [--] <repository> [<path>]\n>     or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...]\n>     or: $dashless [--quiet] init [--] [<path>...]\n>     or: $dashless [--quiet] deinit [-f|--force] [--] <path>...\n> -   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...]\n> +   or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [-v|--verbose] [--] [<path>...]\n>     or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]\n>     or: $dashless [--quiet] foreach [--recursive] <command>\n>     or: $dashless [--quiet] sync [--recursive] [--] [<path>...]\"\n> @@ -319,12 +319,16 @@ module_clone()\n>  \trel=$(echo $a | sed -e 's|[^/][^/]*|..|g')\n>  \t(\n>  \t\tclear_local_git_env\n> +\t\tif test -z \"$verbose\"\n> +\t\tthen\n> +\t\t\tsubquiet=-q\n> +\t\tfi\n>  \t\tcd \"$sm_path\" &&\n>  \t\tGIT_WORK_TREE=. git config core.worktree \"$rel/$b\" &&\n>  \t\t# ash fails to wordsplit ${local_branch:+-B \"$local_branch\"...}\n>  \t\tcase \"$local_branch\" in\n> -\t\t'') git checkout -f -q ${start_point:+\"$start_point\"} ;;\n> -\t\t?*) git checkout -f -q -B \"$local_branch\" ${start_point:+\"$start_point\"} ;;\n> +\t\t'') git checkout -f ${subquiet:+\"$subquiet\"} ${start_point:+\"$start_point\"} ;;\n> +\t\t?*) git checkout -f ${subquiet:+\"$subquiet\"} -B \"$local_branch\" ${start_point:+\"$start_point\"} ;;\n>  \t\tesac\n>  \t) || die \"$(eval_gettext \"Unable to setup cloned submodule '\\$sm_path'\")\"\n>  }\n> @@ -380,6 +384,9 @@ cmd_add()\n>  \t\t--depth=*)\n>  \t\t\tdepth=$1\n>  \t\t\t;;\n> +\t\t-v|--verbose)\n> +\t\t\tverbose=1\n> +\t\t\t;;\n\nCompare $depth and $verbose, and think what would happen if the end\nuser had an environment variable whose name happened to be $depth or\n$verbose.  Does this script misbehave under such a stray $verbose?\nWhat does the existing script do to prevent it from misbehaving when\na stray $depth exists in the environment?\n"}]}