Skip to content

Instantly share code, notes, and snippets.

@andersson
Created June 10, 2019 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andersson/d9109530bed1d002477d62c945b28713 to your computer and use it in GitHub Desktop.
Save andersson/d9109530bed1d002477d62c945b28713 to your computer and use it in GitHub Desktop.
git am-and-tags - Apply patches and tags
#!/bin/bash -e
# Apply patches and tags directly from e.g. mutt
# Add following to .muttrc
# macro index,pager A "| git am-and-tags"
MSG=`cat; echo x`
SUBJECT=$(echo "${MSG%x}" |grep '^Subject:')
if [[ $SUBJECT == 'Subject: ['* ]]; then
git am -s <<< ${MSG%x}
else
TAGS=$(grep -e '^Acked-by' -e '^Reviewed-by' -e '^Tested-by' <<< ${MSG%x})
while read -r TAG; do
GIT_EDITOR="git interpret-trailers --where after --if-exists addIfDifferent --if-missing doNothing --in-place --trailer '${TAG}'" git commit --amend
GIT_EDITOR="git interpret-trailers --where start --if-exists addIfDifferent --in-place --trailer '${TAG}'" git commit --amend
done <<< "$TAGS"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment