git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jakob Jarmar <jakob.j@gmail.com>
To: git@vger.kernel.org
Subject: Possible bug in git stash with submodule.recurse
Date: Thu, 10 Oct 2019 17:26:10 +0200	[thread overview]
Message-ID: <CA+xNDHseTCoD+7Vbb4AG0kt9itXn0Z1Kto0vDjF9bBn+Fuk3TA@mail.gmail.com> (raw)

Hi,

I ran into an issue where git stash seems to be losing modified content
from submodules without warning, if submodule.recurse is true. See
below for an example:

1. enable submodule.recurse:

~ $ git config --global submodule.recurse true

2. create the repo to be used as a submodule:

~ $ git init sub
Initialized empty Git repository in /home/jakob/sub/.git/
~ $ cd sub/
~/sub $ touch sub.txt
~/sub $ git add sub.txt
~/sub $ git commit -m initial
[master (root-commit) 651a90c] initial
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 sub.txt
~/sub $ cd ..

3. create the main repo, add sub as a submodule:

~ $ git init main
Initialized empty Git repository in /home/jakob/main/.git/
~ $ cd main/
~/main $ touch main.txt
~/main $ git add main.txt
~/main $ git submodule add ../sub/
Cloning into '/home/jakob/main/sub'...
done.
~/main $ git commit -m initial
[master (root-commit) 2f9f4e8] initial
 3 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 100644 main.txt
 create mode 160000 sub

4. make *both* main and sub dirty (if main is clean, stash does nothing):

~/main $ echo changes > main.txt
~/main $ echo changes > sub/sub.txt
~/main $ git diff sub/
Submodule sub contains modified content

5. git stash and git stash pop:

~/main $ git stash
Saved working directory and index state WIP on master: 2f9f4e8 initial
~/main $ git stash pop
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   main.txt

no changes added to commit (use "git add" and/or "git commit -a")
Dropped refs/stash@{0} (00a38b73407e7e3041c9459ef6d61bc90940b91f)
~/main $ git diff sub/
~/main $

At this point, I can't seem to find any way to retrieve the changes
made to sub/sub.txt.

Thanks,
Jakob

                 reply	other threads:[~2019-10-10 15:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CA+xNDHseTCoD+7Vbb4AG0kt9itXn0Z1Kto0vDjF9bBn+Fuk3TA@mail.gmail.com \
    --to=jakob.j@gmail.com \
    --cc=git@vger.kernel.org \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).