about summary refs log tree commit diff
path: root/git-fetch-email.sh
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-24 15:07:25 -0500
committerJune McEnroe <june@causal.agency>2021-02-24 15:07:25 -0500
commit8251ca27c1fa826ad090d20f853c58d454abb9c5 (patch)
tree2422501e4cd89b0beb78e4bf13d61a6b754f66b3 /git-fetch-email.sh
parentFactor out printNums (diff)
downloadimbox-8251ca27c1fa826ad090d20f853c58d454abb9c5.tar.gz
imbox-8251ca27c1fa826ad090d20f853c58d454abb9c5.zip
Add -U and -s flags to git-fetch-email
Diffstat (limited to 'git-fetch-email.sh')
-rw-r--r--git-fetch-email.sh17
1 files changed, 15 insertions, 2 deletions
diff --git a/git-fetch-email.sh b/git-fetch-email.sh
index cb3969c..571fc4f 100644
--- a/git-fetch-email.sh
+++ b/git-fetch-email.sh
@@ -28,7 +28,11 @@ subject=$(git config fetchemail.subject)
 from=$(git config fetchemail.from)
 to=$(git config fetchemail.to)
 cc=$(git config fetchemail.cc)
+unseen=$(git config --type bool fetchemail.unseen)
+seen=$(git config --type bool fetchemail.markSeen)
 move=$(git config fetchemail.moveTo)
+[ "${unseen}" = 'false' ] && unseen=
+[ "${seen}" = 'false' ] && seen=
 
 OPTS_SPEC="\
 git fetch-email [<options>]
@@ -38,11 +42,13 @@ 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
+U,unseen fetch unseen patches
 a,apply apply patches with git-am
 h,host=! connect to IMAP on host
 i,idle wait for matching patches
 m,mailbox=! fetch patches from mailbox
 p,port=! connect to IMAP on port
+s,mark-seen mark matching patches as seen
 u,user=! log in to IMAP as user
 v,verbose log IMAP protocol to standard error
 "
@@ -57,20 +63,24 @@ while [ $# -gt 0 ]; do
 		(-M) move=$1; shift;;
 		(-S) subject=$1; shift;;
 		(-T) to=$1; shift;;
+		(-U) unseen=true;;
 		(-a) apply=yes;;
 		(-h) host=$1; shift;;
 		(-i) idle=yes;;
 		(-m) mailbox=$1; shift;;
 		(-p) port=$1; shift;;
+		(-s) seen=true; shift;;
 		(-u) user=$1; shift;;
 		(-v) verbose=yes;;
 		(--no-apply) apply=;;
 		(--no-cc) cc=;;
 		(--no-from) from=;;
 		(--no-idle) idle=;;
+		(--no-mark-seen) seen=;;
 		(--no-move-to) move=;;
 		(--no-subject) subject=;;
 		(--no-to) to=;;
+		(--no-unseen) unseen=;;
 		(--no-verbose) verbose=;;
 		(--) break;;
 	esac
@@ -96,7 +106,7 @@ fi
 
 fetch() {
 	echo "${pass}" | imbox -w \
-		${verbose:+-v} ${idle:+-i} \
+		${verbose:+-v} ${idle:+-i} ${unseen:+-U} ${seen:+-s} \
 		${host:+-h "${host}"} \
 		${port:+-p "${port}"} \
 		${mailbox:+-m "${mailbox}"} \
@@ -116,11 +126,14 @@ fetch() {
 }
 
 if [ -n "${apply}" ]; then
+	applySeen=$seen
 	applyMove=$move
+	seen=
 	move=
 	fetch | git am --patch-format=mboxrd "$@"
 	status=$?
-	if [ $status -eq 0 ] && [ -n "${applyMove}" ]; then
+	if [ $status -eq 0 ] && [ -n "${applySeen}${applyMove}" ]; then
+		seen=$applySeen
 		move=$applyMove
 		fetch >/dev/null
 	fi