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

diff-index does not consider a removed submodule to be staged with --ignore-submodules

From
DHDaniel Hahler <genml+git-2014@thequod.de>
Date
Sep 20, 2014, 16:20 UTC
Message-ID
<541DA95A.2030407@thequod.de>
After staging the removal of a submodule, diff-index does not consider this when "--ignore-submodules" is being used:
    # In a repository with submodule "sm":
    % git rm --cached sm
    % git diff-index --cached --quiet --ignore-submodules HEAD
    % echo $?
    0
    % git status
    On branch master
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
        deleted:    sm
"git status --ignore-submodules" behaves the same.
>From the man page of "--ignore-submodules" it looks like the option is meant to prevent scanning of submodules itself, but in this case the main repository is affected.
This command is used by zsh's vcs_info module (in Functions/VCS_Info/Backends/VCS_INFO_get_data_git):
    if (( querystaged )) ; then
        if ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then
            ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null
            (( $? && $? != 128 )) && gitstaged=1

Is this a bug/oversight in Git or by design? Is there a better way to detect if there are any staged changes?

Regards, Daniel.

-- 
http://daniel.hahler.de/
Next: Jens Lehmann
Message 1 of 2 in “diff-index does not consider a removed submodule to be staged with --ignore-submodules”
  1. Daniel HahlerSep 20, 2014
  2. Jens LehmannSep 21, 2014

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.