submodule: add verbose mode for add/update
PATCH 1/1 submodule: add verbose mode for add/update
Add the verbose flag to add and update which displays the progress of the actual submodule checkout when given. This is useful for checkouts that take a long time, as the user can then see the progress.
--- Documentation/git-submodule.txt | 7 +++++-- git-submodule.sh | 24 +++++++++++++++++++----- t/t7406-submodule-update.sh | 10 ++++++++++ 3 files changed, 34 insertions(+), 7 deletions(-)
Documentation/git-submodule.txt +5 -2
@@ -10,13 +10,13 @@ SYNOPSIS -------- [verse] 'git submodule' [--quiet] add [-b <branch>] [-f|--force] [--name <name>] - [--reference <repository>] [--depth <depth>] [--] <repository> [<path>] + [--reference <repository>] [--depth <depth>] [-v|--verbose] [--] <repository> [<path>] 'git submodule' [--quiet] status [--cached] [--recursive] [--] [<path>...] 'git submodule' [--quiet] init [--] [<path>...] 'git submodule' [--quiet] deinit [-f|--force] [--] <path>... 'git submodule' [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase|--merge|--checkout] [--reference <repository>] - [--depth <depth>] [--recursive] [--] [<path>...] + [--depth <depth>] [--recursive] [-v|--verbose] [--] [<path>...] 'git submodule' [--quiet] summary [--cached|--files] [(-n|--summary-limit) <n>] [commit] [--] [<path>...] 'git submodule' [--quiet] foreach [--recursive] <command>
@@ -363,6 +363,9 @@ for linkgit:git-clone[1]'s `--reference` and `--shared` options carefully. clone with a history truncated to the specified number of revisions. See linkgit:git-clone[1] +--verbose:: + This option is valid for add and update commands. Display the progress + of the actual submodule checkout. <path>...:: Paths to submodule(s). When specified this will restrict the command
git-submodule.sh +19 -5
@@ -5,11 +5,11 @@ # Copyright (c) 2007 Lars Hjemli dashless=$(basename "$0" | sed -e 's/-/ /') -USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>] +USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [-v|--verbose] [--] <repository> [<path>] or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...] or: $dashless [--quiet] init [--] [<path>...] or: $dashless [--quiet] deinit [-f|--force] [--] <path>... - or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...] + or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [-v|--verbose] [--] [<path>...] or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...] or: $dashless [--quiet] foreach [--recursive] <command> or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
@@ -319,12 +319,16 @@ module_clone() rel=$(echo $a | sed -e 's|[^/][^/]*|..|g') ( clear_local_git_env + if test -z "$verbose" + then + subquiet=-q + fi cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b" && # ash fails to wordsplit ${local_branch:+-B "$local_branch"...} case "$local_branch" in - '') git checkout -f -q ${start_point:+"$start_point"} ;; - ?*) git checkout -f -q -B "$local_branch" ${start_point:+"$start_point"} ;; + '') git checkout -f ${subquiet:+"$subquiet"} ${start_point:+"$start_point"} ;; + ?*) git checkout -f ${subquiet:+"$subquiet"} -B "$local_branch" ${start_point:+"$start_point"} ;; esac ) || die "$(eval_gettext "Unable to setup cloned submodule '\$sm_path'")" }
@@ -380,6 +384,9 @@ cmd_add() --depth=*) depth=$1 ;; + -v|--verbose) + verbose=1 + ;; --) shift break
@@ -786,6 +793,9 @@ cmd_update() --depth=*) depth=$1 ;; + -v|--verbose) + verbose=1 + ;; --) shift break
@@ -913,7 +923,11 @@ Maybe you want to use 'update --init'?")" must_die_on_failure= case "$update_module" in checkout) - command="git checkout $subforce -q" + if test -z "$verbose" + then + subquiet=-q + fi + command="git checkout $subforce ${subquiet:+"$subquiet"}" die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")" say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")" ;;
t/t7406-submodule-update.sh +10 -0
@@ -83,6 +83,16 @@ test_expect_success 'submodule update detaching the HEAD ' ' ) ' +test_expect_success 'submodule update verbose' ' + (cd super/submodule && + git checkout master + ) && + (cd super && + git submodule update --verbose submodule 2>messages && + test_i18ngrep "HEAD is now at" messages + ) +' + test_expect_success 'submodule update from subdirectory' ' (cd super/submodule && git reset --hard HEAD~1
Signature · 1 line
1.9.0
Documentation/git-submodule.txt for linkgit:git-clone[1]'s `--reference` and `--shared` options carefully. · line 368
Quoted 3 lines · Orgad Shaneh
+--verbose::
Documentation/git-submodule.txt +2
-0+ This option is valid for add and update commands. Display the progress + of the actual submodule checkout.
Hmm, is the "valid for add and update" part we want to keep? I do not think it is a crime if some other subcommand accepted --verbose option but its output under verbose mode and normal mode happened to be the same.
I doubt it would take a lot of imagination to see that people would want to see "git submodule status --verbose" to get richer output, and at that point, "progress of checkout" as part of the description of the "--verbose" option does not make any sense. Perhaps the second part that is specific to "add" and "update" subcommands should move to the description of these two subcommands?
I dunno.
Quoted 38 lines
git-submodule.sh +8
-4@@ -5,11 +5,11 @@ # Copyright (c) 2007 Lars Hjemli dashless=$(basename "$0" | sed -e 's/-/ /') -USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>] +USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [-v|--verbose] [--] <repository> [<path>] or: $dashless [--quiet] status [--cached] [--recursive] [--] [<path>...] or: $dashless [--quiet] init [--] [<path>...] or: $dashless [--quiet] deinit [-f|--force] [--] <path>... - or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [--] [<path>...] + or: $dashless [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--rebase] [--reference <repository>] [--merge] [--recursive] [-v|--verbose] [--] [<path>...] or: $dashless [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...] or: $dashless [--quiet] foreach [--recursive] <command> or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"@@ -319,12 +319,16 @@ module_clone() rel=$(echo $a | sed -e 's|[^/][^/]*|..|g') ( clear_local_git_env + if test -z "$verbose" + then + subquiet=-q + fi cd "$sm_path" && GIT_WORK_TREE=. git config core.worktree "$rel/$b" && # ash fails to wordsplit ${local_branch:+-B "$local_branch"...} case "$local_branch" in - '') git checkout -f -q ${start_point:+"$start_point"} ;; - ?*) git checkout -f -q -B "$local_branch" ${start_point:+"$start_point"} ;; + '') git checkout -f ${subquiet:+"$subquiet"} ${start_point:+"$start_point"} ;; + ?*) git checkout -f ${subquiet:+"$subquiet"} -B "$local_branch" ${start_point:+"$start_point"} ;; esac ) || die "$(eval_gettext "Unable to setup cloned submodule '\$sm_path'")" }
git-submodule.sh cmd_add() · line 389
Quoted 6 lines
git-submodule.sh +3
-0@@ -380,6 +384,9 @@ cmd_add() --depth=*) depth=$1 ;; + -v|--verbose) + verbose=1 + ;;
Compare $depth and $verbose, and think what would happen if the end user had an environment variable whose name happened to be $depth or $verbose. Does this script misbehave under such a stray $verbose? What does the existing script do to prevent it from misbehaving when a stray $depth exists in the environment?