# [PATCH v1 0/2] Ignore dirty submodule states during stash

4 messages from 2016-05-17 to 2016-05-17. Participants: Vasily Titskiy, Eric Sunshine.
Thread: https://gitlist.dev/t/42354

## Vasily Titskiy, 2016-05-17 03:36

Subject: [PATCH v1 0/2] Ignore dirty submodule states during stash
Message-ID: <20160517033632.GA2782@gmail.com>
URL: https://gitlist.dev/e/20160517033632.GA2782%40gmail.com

```
Impoved description + added test

 git-stash.sh     |  2 +-
 t/t3903-stash.sh | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)

```

## Vasily Titskiy, 2016-05-17 03:40

Subject: Re: [PATCH v1 1/2] Ignore dirty submodule states during stash
Message-ID: <20160517034008.GB2782@gmail.com>
URL: https://gitlist.dev/e/20160517034008.GB2782%40gmail.com
In-Reply-To: <20160517033632.GA2782@gmail.com>

```
As stash does not know how to deal with submodules,
it should not try to save/restore their states
as it leads to redundant merge conflicts.

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

```

## Vasily Titskiy, 2016-05-17 03:40

Subject: Re: [PATCH v1 2/2] Ignore dirty submodule states during stash
Message-ID: <20160517034050.GC2782@gmail.com>
URL: https://gitlist.dev/e/20160517034050.GC2782%40gmail.com
In-Reply-To: <20160517033632.GA2782@gmail.com>

```
It checks if 'stash pop' does not trigger merge conflics
in submodules.
---
 t/t3903-stash.sh | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 2142c1f..e48a5b5 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -731,4 +731,39 @@ test_expect_success 'stash list --cc shows combined diff' '
 	test_cmp expect actual
 '
 
+test_expect_success 'stash ignores changes in submodules' '
+	git submodule init &&
+	git init sub1 &&
+	(
+		cd sub1 &&
+		echo "x" > file1 &&
+		git add file1 &&
+		git commit -a -m "initial sub1"
+	) &&
+	git submodule add ./. sub1 &&
+	echo "main" > file1 &&
+	git add file1 &&
+	git commit -a -m "initial main" &&
+	# make changes in submodule
+	(
+		cd sub1 &&
+		echo "y" >> file1 &&
+		git commit -a -m "change y"
+	) &&
+	git commit sub1 -m "update reference" &&
+	# switch submodule to another revision
+	(
+		cd sub1 &&
+		echo "z" >> file1 &&
+		git commit -a -m "change z"
+	) &&
+	# everything is prepared, check if changes in submodules are ignored
+	echo "local change" >> file1 &&
+	git stash save &&
+	git checkout HEAD~1 &&
+	git submodule update &&
+	git stash pop
+'
+
+
 test_done
-- 
2.1.4

```

## Eric Sunshine, 2016-05-17 03:49

Subject: Re: [PATCH v1 2/2] Ignore dirty submodule states during stash
Message-ID: <CAPig+cTShM4Qc7sVN5NXSmwP8Cxz22q+ZAbSrW3bHVm66aaCQg@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcTShM4Qc7sVN5NXSmwP8Cxz22q%2BZAbSrW3bHVm66aaCQg%40mail.gmail.com
In-Reply-To: <20160517034050.GC2782@gmail.com>

```
On Mon, May 16, 2016 at 11:40 PM, Vasily Titskiy <qehgt0@gmail.com> wrote:
> It checks if 'stash pop' does not trigger merge conflics
> in submodules.

Missing sign-off.

Also, it would be best to combine these two patches so that the fix
and patch reside in a single patch.

More below...

> ---
> diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> @@ -731,4 +731,39 @@ test_expect_success 'stash list --cc shows combined diff' '
> +test_expect_success 'stash ignores changes in submodules' '
> +       git submodule init &&
> +       git init sub1 &&
> +       (
> +               cd sub1 &&
> +               echo "x" > file1 &&

Style: Drop space after redirection operator: >file1

Ditto below for both '>' and '>>'.

> +               git add file1 &&
> +               git commit -a -m "initial sub1"
> +       ) &&
> +       git submodule add ./. sub1 &&
> +       echo "main" > file1 &&
> +       git add file1 &&
> +       git commit -a -m "initial main" &&
> +       # make changes in submodule
> +       (
> +               cd sub1 &&
> +               echo "y" >> file1 &&
> +               git commit -a -m "change y"
> +       ) &&
> +       git commit sub1 -m "update reference" &&
> +       # switch submodule to another revision
> +       (
> +               cd sub1 &&
> +               echo "z" >> file1 &&
> +               git commit -a -m "change z"
> +       ) &&
> +       # everything is prepared, check if changes in submodules are ignored
> +       echo "local change" >> file1 &&
> +       git stash save &&
> +       git checkout HEAD~1 &&
> +       git submodule update &&
> +       git stash pop
> +'
> +
> +

Style: drop extra blank line

>  test_done
> --
> 2.1.4

```
