]> git.phdru.name Git - git-scripts.git/commitdiff
Refactor(submodules/diff-name-only): Remove excessive backslashes
authorOleg Broytman <phd@phdru.name>
Fri, 28 May 2021 09:28:05 +0000 (12:28 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 28 May 2021 09:28:05 +0000 (12:28 +0300)
Use apostrophes for the internal script.
Export variables from the external shell
to be available in the internal script.

submodules/diff-name-only

index d5136135e5d2e5e4369b36f3b49a6f3a4ea9bfa1..2209563f725ee62693257002f8642a77254d115d 100755 (executable)
@@ -8,13 +8,14 @@ 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}")`
+    git --no-pager diff --name-only $prev_commit $curr_commit
+'