{"thread":{"id":"37604","subject":"diff-index does not consider a removed submodule to be staged with --ignore-submodules","startedAt":"2014-09-20T16:20:42Z","lastAt":"2014-09-21T21:36:10Z","messageCount":2,"participants":["Daniel Hahler","Jens Lehmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"249699","messageId":"541DA95A.2030407@thequod.de","threadId":"37604","inReplyTo":null,"subject":"diff-index does not consider a removed submodule to be staged with --ignore-submodules","fromName":"Daniel Hahler","fromEmail":"genml+git-2014@thequod.de","sentAt":"2014-09-20T16:20:42Z","receivedAt":"2014-09-20T16:20:42Z","isPatch":false,"sender":{"key":"genml+git-2014@thequod.de","avatar":null},"body":"After staging the removal of a submodule, diff-index does not consider this when \"--ignore-submodules\" is being used:\n\n    # In a repository with submodule \"sm\":\n    % git rm --cached sm\n    % git diff-index --cached --quiet --ignore-submodules HEAD\n    % echo $?\n    0\n    % git status\n    On branch master\n    Changes to be committed:\n      (use \"git reset HEAD <file>...\" to unstage)\n\n        deleted:    sm\n\n\"git status --ignore-submodules\" behaves the same.\n\n>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.\n\nThis command is used by zsh's vcs_info module (in Functions/VCS_Info/Backends/VCS_INFO_get_data_git):\n\n    if (( querystaged )) ; then\n        if ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then\n            ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null\n            (( $? && $? != 128 )) && gitstaged=1\n\nIs this a bug/oversight in Git or by design?\nIs there a better way to detect if there are any staged changes?\n\n\nRegards,\nDaniel.\n\n-- \nhttp://daniel.hahler.de/\n"},{"id":"249730","messageId":"541F44CA.7080403@web.de","threadId":"37604","inReplyTo":"541DA95A.2030407@thequod.de","subject":"Re: diff-index does not consider a removed submodule to be staged with --ignore-submodules","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2014-09-21T21:36:10Z","receivedAt":"2014-09-21T21:36:10Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 20.09.2014 um 18:20 schrieb Daniel Hahler:\n> After staging the removal of a submodule, diff-index does not consider this when \"--ignore-submodules\" is being used:\n>\n>      # In a repository with submodule \"sm\":\n>      % git rm --cached sm\n>      % git diff-index --cached --quiet --ignore-submodules HEAD\n>      % echo $?\n>      0\n>      % git status\n>      On branch master\n>      Changes to be committed:\n>        (use \"git reset HEAD <file>...\" to unstage)\n>\n>          deleted:    sm\n>\n> \"git status --ignore-submodules\" behaves the same.\n>\n>>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.\n\nSorry, but I don't know what man page you are talking about here ...\n\n> This command is used by zsh's vcs_info module (in Functions/VCS_Info/Backends/VCS_INFO_get_data_git):\n>\n>      if (( querystaged )) ; then\n>          if ${vcs_comm[cmd]} rev-parse --quiet --verify HEAD &> /dev/null ; then\n>              ${vcs_comm[cmd]} diff-index --cached --quiet --ignore-submodules HEAD 2> /dev/null\n>              (( $? && $? != 128 )) && gitstaged=1\n>\n> Is this a bug/oversight in Git or by design?\n> Is there a better way to detect if there are any staged changes?\n\nIt might be that --ignore-submodules=dirty is what you want. It will\nreport changes in the committed submodule SHA-1, added and removed\nsubmodules but won't care about any modifications inside the submodule.\n"}]}