Skip to content
  • Duy Nguyen's avatar
    submodule foreach: fix "<command> --quiet" not being respected · a282f5a9
    Duy Nguyen authored and Junio C Hamano's avatar Junio C Hamano committed
    Robin reported that
    
        git submodule foreach --quiet git pull --quiet origin
    
    is not really quiet anymore [1]. "git pull" behaves as if --quiet is not
    given.
    
    This happens because parseopt in submodule--helper will try to parse
    both --quiet options as if they are foreach's options, not git-pull's.
    The parsed options are removed from the command line. So when we do
    pull later, we execute just this
    
        git pull origin
    
    When calling submodule helper, adding "--" in front of "git pull" will
    stop parseopt for parsing options that do not really belong to
    submodule--helper foreach.
    
    PARSE_OPT_KEEP_UNKNOWN is removed as a safety measure. parseopt should
    never see unknown options or something has gone wrong. There are also
    a couple usage string update while I'm looking at them.
    
    While at it, I also add "--" to other subcommands that pass "$@" to
    submodule--helper. "$@" in these cases are paths and less likely to be
    --something-like-this. But the point still stands, git-submodule has
    parsed and classified what are options, what are paths. submodule--helper
    should never consider paths passed by git-submodule to be options even
    if they look like one.
    
    The test case is also contributed by Robin.
    
    [1] it should be quiet before fc1b9243
    
     (submodule: port submodule
        subcommand 'foreach' from shell to C, 2018-05-10) because parseopt
        can't accidentally eat options then.
    
    Reported-by: default avatarRobin H. Johnson <robbat2@gentoo.org>
    Tested-by: default avatarRobin H. Johnson <robbat2@gentoo.org>
    Signed-off-by: default avatarRobin H. Johnson <robbat2@gentoo.org>
    Signed-off-by: default avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    a282f5a9