git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vasily Titskiy <qehgt0@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Ignore dirty submodule states during stash
Date: Mon, 16 May 2016 15:46:06 +0000	[thread overview]
Message-ID: <20160516154606.GA8797@gmail.com> (raw)
In-Reply-To: <CAGZ79kaTss6ctZDCiRP2wjuxH+rJ79RKFLM79_FJN+37Bed+HQ@mail.gmail.com>

Hi Stefan,

On Sun, May 15, 2016 at 11:37:20PM -0700, Stefan Beller wrote:
> On Sun, May 15, 2016 at 7:07 PM, Vasily Titskiy <qehgt0@gmail.com> wrote:
> > Do not save states of submodules as stash should ignore it.
> 
> Can you explain why this is a good idea?
> (It is not obvious to me either way.)
Actually, submodules are already ignored by stash, but not fully (it was introduced in commit 6848d58).
Current behavior is counter-intuitive, for example (if one has a project with a submodule):
 $ cd sub1
 $ edit .. commit .. edit .. commit. Alternatively, just checkout some other commit
 $ cd .. # back to main project
 $ git stash save
   No local changes to save
 $ # so, stash declares there are no changes
 $ edit main.cpp
 $ # For example, I need to update my working tree to latest master
 $ git stash save # save local changes of 'main.cpp'...
 $ git pull --recurse-submodules && git submodule update --recursive # update to latest
 $ git stash pop # I expect to get stashed changes for 'main.cpp', but...
   warning: Failed to merge submodule sub1 (commits don't follow merge-base)
   Auto-merging sub1
   CONFLICT (submodule): Merge conflict in sub1

So, this is the issue. Instead of getting my local changes, I got a conflict (and stash is not 
poped out). The root cause is the 'stash' command does not know how to deal with submodules,
but currently it tries to save the state of submodules, and even tries to re-apply the state
(and it fails of course). The proposed solution fixes this behaviour.

All internal tests work fine with the change.


> 
> Do we need a test/documentation updates for this?
I don't think so, 'stash' have never claimed submodule support.

> 
> >
> > Signed-off-by: Vasily Titskiy <qehgt0@gmail.com>
> > ---
> >  git-stash.sh | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/git-stash.sh b/git-stash.sh
> > index c7c65e2..b500c44 100755
> > --- a/git-stash.sh
> > +++ b/git-stash.sh
> > @@ -116,7 +116,7 @@ create_stash () {
> >                         git read-tree --index-output="$TMPindex" -m $i_tree &&
> >                         GIT_INDEX_FILE="$TMPindex" &&
> >                         export GIT_INDEX_FILE &&
> > -                       git diff --name-only -z HEAD -- >"$TMP-stagenames" &&
> > +                       git diff --name-only --ignore-submodules -z HEAD -- >"$TMP-stagenames" &&
> >                         git update-index -z --add --remove --stdin <"$TMP-stagenames" &&
> >                         git write-tree &&
> >                         rm -f "$TMPindex"
> > --
> > 2.1.4
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe git" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2016-05-16 15:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-16  2:07 [PATCH] Ignore dirty submodule states during stash Vasily Titskiy
2016-05-16  6:37 ` Stefan Beller
2016-05-16 15:46   ` Vasily Titskiy [this message]
2016-05-16 16:09     ` Stefan Beller
2016-05-17  3:17       ` Vasily Titskiy
2016-05-16 16:29     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160516154606.GA8797@gmail.com \
    --to=qehgt0@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sbeller@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).