Skip to main content
added header line
Source Link
Warren Young
  • 73.5k
  • 17
  • 182
  • 172

The key bit of syntax you're missing here is:

git commit -m "$(printf "Updated $submodule Submodule\n\n" ; git diff $submodule)"

The use of the $() form of command substitution inside double quotes sends the output of git diff... to git commit as a commit message with newlines intact.

I used printf here instead of echo to prepend the subject line since for anything even slightly complex — like dealing with embedded escapes — echo is basically nonportable, for historical reasons.

The rest of the script is left as an exercise to the student. :)

The key bit of syntax you're missing here is:

git commit -m "$(git diff $submodule)"

The use of the $() form of command substitution inside double quotes sends the output of git diff... to git commit as a commit message with newlines intact.

The rest of the script is left as an exercise to the student. :)

The key bit of syntax you're missing here is:

git commit -m "$(printf "Updated $submodule Submodule\n\n" ; git diff $submodule)"

The use of the $() form of command substitution inside double quotes sends the output of git diff... to git commit as a commit message with newlines intact.

I used printf here instead of echo to prepend the subject line since for anything even slightly complex — like dealing with embedded escapes — echo is basically nonportable, for historical reasons.

The rest of the script is left as an exercise to the student. :)

Source Link
Warren Young
  • 73.5k
  • 17
  • 182
  • 172

The key bit of syntax you're missing here is:

git commit -m "$(git diff $submodule)"

The use of the $() form of command substitution inside double quotes sends the output of git diff... to git commit as a commit message with newlines intact.

The rest of the script is left as an exercise to the student. :)