summary refs log tree commit diff
path: root/git-fetch-email.sh
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-16 20:38:04 -0500
committerJune McEnroe <june@causal.agency>2021-02-16 20:38:04 -0500
commit4ea8f158a7965f866e91e5f11c1ba189079bd935 (patch)
tree25cea835df81a25a6fac7780e7a2108d61bc6f88 /git-fetch-email.sh
parentDon't use Fl Fl for long options (diff)
downloadimbox-4ea8f158a7965f866e91e5f11c1ba189079bd935.tar.gz
imbox-4ea8f158a7965f866e91e5f11c1ba189079bd935.zip
Add -M to move messages after export
Diffstat (limited to '')
-rw-r--r--git-fetch-email.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/git-fetch-email.sh b/git-fetch-email.sh
index 52aa74f..6109091 100644
--- a/git-fetch-email.sh
+++ b/git-fetch-email.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (C) 2019, 2020  C. McEnroe <june@causal.agency>
+# Copyright (C) 2019-2021  C. McEnroe <june@causal.agency>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,12 +27,14 @@ subject=$(git config fetchemail.subject)
 from=$(git config fetchemail.from)
 to=$(git config fetchemail.to)
 cc=$(git config fetchemail.cc)
+move=$(git config fetchemail.moveTo)
 
 OPTS_SPEC="\
 git fetch-email [<options>]
 --
 C,cc= fetch patches with matching Cc headers
 F,from= fetch patches with matching From headers
+M,move-to= move patches to mailbox
 S,subject= fetch patches with matching Subject headers
 T,to= fetch patches with matching To headers
 a,apply apply patches with git-am
@@ -50,6 +52,7 @@ while [ $# -gt 0 ]; do
 	case "${opt}" in
 		(-C) cc=$1; shift;;
 		(-F) from=$1; shift;;
+		(-M) move=$1; shift;;
 		(-S) subject=$1; shift;;
 		(-T) to=$1; shift;;
 		(-a) apply=yes;;
@@ -61,6 +64,7 @@ while [ $# -gt 0 ]; do
 		(--no-apply) apply=;;
 		(--no-cc) cc=;;
 		(--no-from) from=;;
+		(--no-move-to) move=;;
 		(--no-subject) subject=;;
 		(--no-to) to=;;
 		(--no-verbose) verbose=;;
@@ -96,6 +100,7 @@ fetch() {
 		${from:+-F "${from}"} \
 		${to:+-T "${to}"} \
 		${cc:+-C "${cc}"} \
+		${move:+-M "${move}"} \
 		${user}
 	status=$?
 	if [ $status -ne 78 ]; then
@@ -107,7 +112,15 @@ fetch() {
 }
 
 if [ -n "${apply}" ]; then
+	applyMove=$move
+	move=
 	fetch | git am --patch-format=mboxrd "$@"
+	status=$?
+	if [ $status -eq 0 ] && [ -n "${applyMove}" ]; then
+		move=$applyMove
+		fetch
+	fi
+	exit $status
 else
 	fetch
 fi