]> git.phdru.name Git - git-scripts.git/blob - submodules/diff-name-only
d5136135e5d2e5e4369b36f3b49a6f3a4ea9bfa1
[git-scripts.git] / submodules / diff-name-only
1 #! /bin/sh
2 # See the discussion at https://stackoverflow.com/q/67724347/7976758
3
4 if [ -z "$1" ]; then
5     echo "Usage $0 from_commit [to_commit]"
6     exit 1
7 fi
8
9 from_commit="$1"
10 to_commit="${2:-HEAD}"
11
12 # In the superproject
13 git --no-pager diff --name-only "$from_commit" "$to_commit"
14
15 git submodule foreach "
16     # In submodule \"\$name\"
17     prev_commit=\`(git -C \"\$toplevel\" ls-tree "$from_commit" \"\$sm_path\" | awk '{print \$3}')\`
18     curr_commit=\`(git -C \"\$toplevel\" ls-tree "$to_commit" \"\$sm_path\" | awk '{print \$3}')\`
19     git --no-pager diff --name-only \$prev_commit \$curr_commit
20 "