1

As an example of my problem, consider ssh2-rs repo has a submodule at the path libssh2-sys/libssh2 that points to libssh2 repo. Now, within ssh2-rs@0.2.19 [d2ef03f] and ssh2-rs@0.2.20[1fcf8d3], the reference pointer to the submodule was updated. Now when I run git diff --submodule=diff d2ef03f..1fcf8d3< i expect the diff to show me the code changes within the submodule too, but it does not. For example, the GitHub compare page shows a link to the diff for the files within the submodule. Ideally, I would want a single diff command to show all the code changes between two commits, including changes within the submodule files in the case where the submodule reference pointer was updated. Is that doable? How can I achieve that?

Nasif Imtiaz Ohi
  • 1,563
  • 5
  • 24
  • 45
  • 1
    I just tried `git diff --submodule=diff d2ef03f..1fcf8d3` and it did show me the actual code changes within libssh2, in diff format. – jingx Jan 30 '22 at 17:43
  • you cloned the repo by `git clone --recurse-submodules https://github.com/alexcrichton/ssh2-rs`? And then run the diff command? Did you do anything else? – Nasif Imtiaz Ohi Jan 30 '22 at 17:48
  • I cloned ssh2-rs first, then went in and did `git submodule init; git submodule update`. Nothing else. – jingx Jan 30 '22 at 17:51
  • Followup question: `git diff --submodule=diff d2ef03f..1fcf8d3 -- libssh2-sys/libssh2/src/agent.c` does this command show you anything? – Nasif Imtiaz Ohi Jan 30 '22 at 17:53
  • 1
    Returns `Submodule libssh2-sys/libssh2 6da9d78...cfe0bf6 (commits not present)`. – jingx Jan 30 '22 at 17:54
  • If I do `git diff --submodule=diff d2ef03f..1fcf8d3 -- libssh2-sys/libssh2`, it shows me `Submodule libssh2-sys/libssh2 6da9d78...cfe0bf6 (commits not present)`. I did the init and update thing, but no difference. – Nasif Imtiaz Ohi Jan 30 '22 at 17:54
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/241546/discussion-between-nasif-imtiaz-ohi-and-jingx). – Nasif Imtiaz Ohi Jan 30 '22 at 17:54

1 Answers1

0

I had to git submodule init; git submodule update at both the commit points where I wanted the diff (d2ef03f..1fcf8d3 in the example). Apparently, that enables my repo to fetch updates from the old reference pointers from the submodule remote in order to have the corresponding commits of the remote repository available within my repo and git to show me the diff.

Nasif Imtiaz Ohi
  • 1,563
  • 5
  • 24
  • 45