]> git.phdru.name Git - git-scripts.git/blobdiff - submodules/diff-name-only
Feat(submodules/diff-name-only): Run recursively
[git-scripts.git] / submodules / diff-name-only
index d5136135e5d2e5e4369b36f3b49a6f3a4ea9bfa1..445df523d2c1ce2d4ed5ca5276d05110cd38b982 100755 (executable)
@@ -6,15 +6,27 @@ if [ -z "$1" ]; then
     exit 1
 fi
 
+if [ -z "$prog_dir" -o -z "$prog_name" ]; then
+    start_dir="`pwd`"
+    prog_dir="`dirname \"$0\"`"
+    prog_name="`basename \"$0\"`"
+    cd "$prog_dir"
+    # Get full path
+    prog_dir="`pwd`"
+    cd "$start_dir"
+    export prog_dir prog_name
+fi
+
 from_commit="$1"
 to_commit="${2:-HEAD}"
+export from_commit to_commit
 
 # In the superproject
 git --no-pager diff --name-only "$from_commit" "$to_commit"
 
-git submodule foreach "
-    # In submodule \"\$name\"
-    prev_commit=\`(git -C \"\$toplevel\" ls-tree "$from_commit" \"\$sm_path\" | awk '{print \$3}')\`
-    curr_commit=\`(git -C \"\$toplevel\" ls-tree "$to_commit" \"\$sm_path\" | awk '{print \$3}')\`
-    git --no-pager diff --name-only \$prev_commit \$curr_commit
-"
+git submodule foreach '
+    # In submodule "$name"
+    prev_commit=`(git -C "$toplevel" ls-tree "$from_commit" "$sm_path" | awk "{print \\$3}")`
+    curr_commit=`(git -C "$toplevel" ls-tree "$to_commit" "$sm_path" | awk "{print \\$3}")`
+    "$prog_dir/$prog_name" $prev_commit $curr_commit
+'