threads / patch / 36138

patchsubmodule: add verbose mode for add/update

Subject: [PATCH] submodule: add verbose mode for add/update

## tl;dr

5 messages between Mar 12, 2014 and Apr 12, 2020. Diffs are folded; open one to read it.

replies: 4people: 4as markdown or json

Orgad Shaneh· Mar 12, 2014, 13:42 UTC · lore
From: Orgad Shaneh <orgads@gmail.com>
Executes checkout without -q
Signed-off-by: Orgad Shaneh <orgads@gmail.com>
---
 Documentation/git-submodule.txt |  7 +++++--
 git-submodule.sh                | 24 +++++++++++++++++++-----
 t/t7406-submodule-update.sh     |  9 +++++++++
 3 files changed, 33 insertions(+), 7 deletions(-)
Show changes to 3 files +33 −7

Documentation/git-submodule.txt, git-submodule.sh, t/t7406-submodule-update.sh

diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 21cb59a..1867e94 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -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. Show output of
+  checkout.
 
 <path>...::
 	Paths to submodule(s). When specified this will restrict the command
diff --git a/git-submodule.sh b/git-submodule.sh
index a33f68d..5c4e057 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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 ${start_point:+"$start_point"} ;;
+		?*) git checkout -f $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"
 				die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
 				say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
 				;;
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 28ca763..04a0fcc 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -83,6 +83,15 @@ 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>&1 | grep -q "HEAD is now at"
+	)
+'
+
 test_expect_success 'submodule update from subdirectory' '
 	(cd super/submodule &&
 	 git reset --hard HEAD~1
-- 
1.9.0.msysgit.0
Jens Lehmann· Mar 12, 2014, 16:15 UTC · re: Orgad Shaneh · lore

Re: [PATCH] submodule: add verbose mode for add/update

Am 12.03.2014 14:42, schrieb Orgad Shaneh:
> From: Orgad Shaneh <orgads@gmail.com>
You don't need the line above when you are the sender ;-)
> Executes checkout without -q
That's a bit terse. What about:
"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."
Show 34 quoted lines
> Signed-off-by: Orgad Shaneh <orgads@gmail.com>
> ---
>  Documentation/git-submodule.txt |  7 +++++--
>  git-submodule.sh                | 24 +++++++++++++++++++-----
>  t/t7406-submodule-update.sh     |  9 +++++++++
>  3 files changed, 33 insertions(+), 7 deletions(-)
> 
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index 21cb59a..1867e94 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -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. Show output of
> +  checkout.

The above looks whitespace-damaged, you should use TABs here to indent (just like the other options do).

Show 36 quoted lines
>  <path>...::
>  	Paths to submodule(s). When specified this will restrict the command
> diff --git a/git-submodule.sh b/git-submodule.sh
> index a33f68d..5c4e057 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -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 ${start_point:+"$start_point"} ;;
> +		?*) git checkout -f $subquiet -B "$local_branch" ${start_point:+"$start_point"} ;;

Wouldn't it be better to use the ${subquiet:+"$subquiet"} notation here like the other optional arguments do? After all the subquiet isn't always set.

Show 33 quoted lines
>  		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"
Same as above.
Show 17 quoted lines
>  				die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
>  				say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
>  				;;
> diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
> index 28ca763..04a0fcc 100755
> --- a/t/t7406-submodule-update.sh
> +++ b/t/t7406-submodule-update.sh
> @@ -83,6 +83,15 @@ 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>&1 | grep -q "HEAD is now at"

This string is translated, so you need to use test_i18ngrep. Please see t7201-co.sh for an example of how to pipe the output into a file and then compare it.

Show 7 quoted lines
> +	)
> +'
> +
>  test_expect_success 'submodule update from subdirectory' '
>  	(cd super/submodule &&
>  	 git reset --hard HEAD~1
> 
Orgad Shaneh· Mar 12, 2014, 20:00 UTC · re: Jens Lehmann · lore

Re: [PATCH] submodule: add verbose mode for add/update

On Wed, Mar 12, 2014 at 6:15 PM, Jens Lehmann <Jens.Lehmann@web.de> wrote:
Show 160 quoted lines
>
> Am 12.03.2014 14:42, schrieb Orgad Shaneh:
> > From: Orgad Shaneh <orgads@gmail.com>
>
> You don't need the line above when you are the sender ;-)
>
> > Executes checkout without -q
>
> That's a bit terse. What about:
>
> "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."
>
> > Signed-off-by: Orgad Shaneh <orgads@gmail.com>
> > ---
> >  Documentation/git-submodule.txt |  7 +++++--
> >  git-submodule.sh                | 24 +++++++++++++++++++-----
> >  t/t7406-submodule-update.sh     |  9 +++++++++
> >  3 files changed, 33 insertions(+), 7 deletions(-)
> >
> > diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> > index 21cb59a..1867e94 100644
> > --- a/Documentation/git-submodule.txt
> > +++ b/Documentation/git-submodule.txt
> > @@ -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. Show output of
> > +  checkout.
>
> The above looks whitespace-damaged, you should use TABs here to
> indent (just like the other options do).
>
> >  <path>...::
> >       Paths to submodule(s). When specified this will restrict the command
> > diff --git a/git-submodule.sh b/git-submodule.sh
> > index a33f68d..5c4e057 100755
> > --- a/git-submodule.sh
> > +++ b/git-submodule.sh
> > @@ -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 ${start_point:+"$start_point"} ;;
> > +             ?*) git checkout -f $subquiet -B "$local_branch" ${start_point:+"$start_point"} ;;
>
> Wouldn't it be better to use the ${subquiet:+"$subquiet"} notation
> here like the other optional arguments do? After all the subquiet
> isn't always set.
>
> >               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"
>
> Same as above.
>
> >                               die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
> >                               say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
> >                               ;;
> > diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
> > index 28ca763..04a0fcc 100755
> > --- a/t/t7406-submodule-update.sh
> > +++ b/t/t7406-submodule-update.sh
> > @@ -83,6 +83,15 @@ 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>&1 | grep -q "HEAD is now at"
>
> This string is translated, so you need to use test_i18ngrep.
> Please see t7201-co.sh for an example of how to pipe the
> output into a file and then compare it.
>
> > +     )
> > +'
> > +
> >  test_expect_success 'submodule update from subdirectory' '
> >       (cd super/submodule &&
> >        git reset --hard HEAD~1
> >
>
Thanks a lot for your review! I'll post a revised patch soon.
- Orgad
Vladimir Nikishkin· Apr 11, 2020, 12:08 UTC · re: Orgad Shaneh · lore

When will this patch be merged?

When will this patch be merged? It is 2020, and git submodule is barely usable with my internet provider, since outbound connections are randomly shaped to 10k/s. At the moment I set up updating submodules for the night, hoping that it works. If this patch was accepted I would just see at which attempt the stream is not shaped and reissue the command if it is.

-- 
--
Vladimir Nikishkin (MiEr, lockywolf)
Jonathan Nieder· Apr 12, 2020, 06:31 UTC · re: Vladimir Nikishkin · lore

Re: When will this patch be merged?

Hi Vladimir,
Vladimir Nikishkin wrote:
> [Subject: Re: When will this patch be merged?]

Please keep in mind that these mails appear in people's crowded inboxes, where a subject line can provide valuable context.

Which patch do you mean?
Show 6 quoted lines
> When will this patch be merged? It is 2020, and git submodule is
> barely usable with my internet provider, since outbound connections
> are randomly shaped to 10k/s. At the moment I set up updating
> submodules for the night, hoping that it works. If this patch was
> accepted I would just see at which attempt the stream is not shaped
> and reissue the command if it is.

From the In-Reply-To field, it looks like you're responding to [1] ("submodule: add verbose mode for add/update"), from 2014. Have you tested that patch? Does it apply to current Git? Has it been working well for you?

For your application, it sounds like having a timeout (plus Git's existing support for retries when fetching submodules) would help. Am I understanding correctly?

Thanks and hope that helps, Jonathan

[1] https://lore.kernel.org/git/1394631731-4678-1-git-send-email-orgad.shaneh@audiocodes.com/

← back to recent threads