]> git.phdru.name Git - git-scripts.git/blob - submodules/diff-name-only
Feat(submodules/diff-name-only): Use pager
[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 export from_commit to_commit
12
13 # In the superproject
14 { git --no-pager diff --name-only "$from_commit" "$to_commit"
15
16 git submodule foreach '
17     # In submodule "$name"
18     prev_commit=`(git -C "$toplevel" ls-tree "$from_commit" "$sm_path" | awk "{print \\$3}")`
19     curr_commit=`(git -C "$toplevel" ls-tree "$to_commit" "$sm_path" | awk "{print \\$3}")`
20     git --no-pager diff --name-only $prev_commit $curr_commit
21 '; } | { test -t 1 && ${PAGER:-less} || cat -; }