git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* diff-index does not consider a removed submodule to be staged with --ignore-submodules
@ 2014-09-20 16:20 Daniel Hahler
  2014-09-21 21:36 ` Jens Lehmann
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Hahler @ 2014-09-20 16:20 UTC (permalink / raw)
  To: git

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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: diff-index does not consider a removed submodule to be staged with --ignore-submodules
  2014-09-20 16:20 diff-index does not consider a removed submodule to be staged with --ignore-submodules Daniel Hahler
@ 2014-09-21 21:36 ` Jens Lehmann
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Lehmann @ 2014-09-21 21:36 UTC (permalink / raw)
  To: Daniel Hahler, git

Am 20.09.2014 um 18:20 schrieb Daniel Hahler:
> 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.

Sorry, but I don't know what man page you are talking about here ...

> 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?

It might be that --ignore-submodules=dirty is what you want. It will
report changes in the committed submodule SHA-1, added and removed
submodules but won't care about any modifications inside the submodule.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-21 21:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-20 16:20 diff-index does not consider a removed submodule to be staged with --ignore-submodules Daniel Hahler
2014-09-21 21:36 ` Jens Lehmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).