# Output of 'diff' and 'diff --raw' not the same for modified submodule

2 messages from 2012-04-04 to 2012-04-04. Participants: Tim Henigan, Junio C Hamano.
Thread: https://gitlist.dev/t/30145

## Tim Henigan, 2012-04-04 13:03

Subject: Output of 'diff' and 'diff --raw' not the same for modified submodule
Message-ID: <CAFouetg6rB7oyYGBuMMSgWzaKFwUWTdp4OUo3czvJro4iHa_kg@mail.gmail.com>
URL: https://gitlist.dev/e/CAFouetg6rB7oyYGBuMMSgWzaKFwUWTdp4OUo3czvJro4iHa_kg%40mail.gmail.com

```
If a submodule has new commits, then 'git diff' and 'git diff --raw'
report different outputs.

For example, the following output is given after adding a new commit
to a submodule:

$ git version
git version 1.7.10.rc4

$ git diff
diff --git a/lib/tst-mergetool b/lib/tst-mergetool
index 9917ea0..5bc1908 160000
--- a/lib/tst-mergetool
+++ b/lib/tst-mergetool
@@ -1 +1 @@
-Subproject commit 9917ea0c228a0c24153da38df954f8a9d78cafac
+Subproject commit 5bc19083c436aaa85762cdc309e62ed98f5cc276

$ git diff --raw --no-abbrev
:160000 160000 9917ea0c228a0c24153da38df954f8a9d78cafac
0000000000000000000000000000000000000000 M  lib/tst-mergetool


'git diff' shows the new SHA1 for the submodule, but 'git diff --raw'
shows the NULL ID.  From the diff man page, I understand that the NULL
ID indicates "creation, unmerged or 'look at the work tree'", but I
expected the output of two commands to match.

Is this the intended behavior?

Thanks,
Tim

```

## Junio C Hamano, 2012-04-04 18:02

Subject: Re: Output of 'diff' and 'diff --raw' not the same for modified submodule
Message-ID: <7v1uo39xyx.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1uo39xyx.fsf%40alter.siamese.dyndns.org
In-Reply-To: <CAFouetg6rB7oyYGBuMMSgWzaKFwUWTdp4OUo3czvJro4iHa_kg@mail.gmail.com>

```
Tim Henigan <tim.henigan@gmail.com> writes:

> If a submodule has new commits, then 'git diff' and 'git diff --raw'
> report different outputs.

There is nothing different except for the inherent difference between a
patch and the row information.

> $ git version
> git version 1.7.10.rc4
>
> $ git diff
> diff --git a/lib/tst-mergetool b/lib/tst-mergetool
> index 9917ea0..5bc1908 160000
> --- a/lib/tst-mergetool
> +++ b/lib/tst-mergetool
> @@ -1 +1 @@
> -Subproject commit 9917ea0c228a0c24153da38df954f8a9d78cafac
> +Subproject commit 5bc19083c436aaa85762cdc309e62ed98f5cc276
>
> $ git diff --raw --no-abbrev
> :160000 160000 9917ea0c228a0c24153da38df954f8a9d78cafac
> 0000000000000000000000000000000000000000 M  lib/tst-mergetool
>
>
> 'git diff' shows the new SHA1 for the submodule, but 'git diff --raw'
> shows the NULL ID.  From the diff man page, I understand that the NULL
> ID indicates "creation, unmerged or 'look at the work tree'", but I
> expected the output of two commands to match.

You are fooled by the textual patch output.

Consider "Subproject commit <blah>" a textconv-ed version of what is on
that path.  Repeat the above but with a regular file at tst-mergetool in
both preimage and postimage.  You will see exactly the same output.  Lines
that begin with "-" show the information for the preimage, while those
that begin with "+" show the information for the postimage.

The --raw output always uses 0{40} to tell you that you need to look at
the working tree for the information you seek for the right hand side (for
"U" entries, 0{40} merely means that we do not have any information to
show on the unmerged side in the first place), and also to mark that the
side that has 0{40} on an "M" entry talks about the working tree.

```
