git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] submodule: handle trailing slash, warn about non-submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 7, 2009, 08:36 UTC
Message-ID
<7vfxiqy76k.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<b14e34d2529721c24437ec9da3f8f15c916d4051.1233892769u.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
Show 7 quoted lines
> Earlier, when you called
>
> 	git submodule path/to/submodule/
>
> (which happens easily if you are a heavy user of tab-completion), Git
> would silently ignore the given path, as "git ls-files path/to/submodule/"
> does not return anything due to the trailing slash.

I see a sign of concentrating too much on the topic you were interested in to blind yourself here in this patch.

Show 22 quoted lines
> diff --git a/git-submodule.sh b/git-submodule.sh
> index 2f47e06..b878909 100755
> --- a/git-submodule.sh
> +++ b/git-submodule.sh
> @@ -59,7 +59,19 @@ resolve_relative_url ()
>  #
>  module_list()
>  {
> -	git ls-files --stage -- "$@" | grep '^160000 '
> +	while test $# -gt 0
> +	do
> +		line=$(git ls-files --stage "${1%/}" | grep '^160000 ')
> +		case "$line" in
> +		'')
> +			echo "Warning: ignoring non-submodule '$1'" >&2
> +			;;
> +		*)
> +			echo "$line"
> +			;;
> +		esac
> +		shift
> +	done

Almost everybody seems to call module_list with the arguments it received from the caller, but that "$@" could be none. Worse, cmd_foreach always calls module_list with no argument. Earlier you got all submodules, now you get none.

So you would need:
        case $# in
        0)
                git ls-files --stage -- | grep '^160000 '
                ;;
        *)
                your while loop
                ;;
        esac
or something, I think.
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 4 of 8 in “submodule: handle trailing slash, warn about non-submodules”
  1. submodule: handle trailing slash, warn about non-submodulesJohannes Schindelin, Feb 6, 2009
  2. Junio C HamanoFeb 6, 2009
  3. Johannes SchindelinFeb 6, 2009
  4. Junio C HamanoFeb 7, 2009
  5. 0/2 submodule path handling fixesJohannes Schindelin, Feb 7, 2009
  6. Junio C HamanoFeb 7, 2009
  7. 1/2 Let ls-files strip trailing slashes in submodules' pathsJohannes Schindelin, Feb 7, 2009
  8. 2/2 submodule: warn about non-submodulesJohannes Schindelin, Feb 7, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.