Skip to contentSkip to conversation

git-am support for naked email messages (take 2)

PATCH In review H. Peter Anvin 2 participants 2 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-am support for naked email messages (take 2)

This allows git-am to accept single-message files as well as mboxes. Unlike the previous version, this one doesn't need to be explicitly told which one it is; rather, it looks to see if the first line is a From line and uses it to select mbox mode or not.

I moved the logic to do all this into git-mailsplit, which got a new user interface as result, although the old interface is still available for backwards compatibility.

Documentation/git-mailsplit.txt +8 -1
index 03a9477..e0703e9 100644
@@ -7,7 +7,7 @@ git-mailsplit - Totally braindamaged mbo
 
 SYNOPSIS
 --------
-'git-mailsplit' [-d<prec>] [<mbox>] <directory>
+'git-mailsplit' [-b] [-f<nn>] [-d<prec>] -o<directory> [--] [<mbox>...]
 
 DESCRIPTION
 -----------
@@ -23,11 +23,18 @@ OPTIONS
 <directory>::
 	Directory in which to place the individual messages.
 
+-b::
+	If any file doesn't begin with a From line, assume it is a
+	single mail message instead of signalling error.
+
 -d<prec>::
 	Instead of the default 4 digits with leading zeros,
 	different precision can be specified for the generated
 	filenames.
 
+-f<nn>::
+	Skip the first <nn> numbers, for example if -f3 is specified,
+	start the numbering with 0004.
 
 Author
 ------
git-am.sh +1 -4
index 6ed527c..f143b7e 100755
@@ -164,10 +164,7 @@ else
 	# Start afresh.
 	mkdir -p "$dotest" || exit
 
-	# cat does the right thing for us, including '-' to mean
-	# standard input.
-	cat "$@" |
-	git-mailsplit -d$prec "$dotest/" >"$dotest/last" || {
+	git-mailsplit -d"$prec" -o"$dotest" -b -- "$@" > "$dotest/last" ||  {
 		rm -fr "$dotest"
 		exit 1
 	}
mailsplit.c +69 -38

151 lines not on this page · raw message

#1 lore raw
Quoted 4 lines · H. Peter Anvin

This allows git-am to accept single-message files as well as mboxes. Unlike the previous version, this one doesn't need to be explicitly told which one it is; rather, it looks to see if the first line is a From line and uses it to select mbox mode or not.

Yes, please. These changes to git-am/git-mailsplit are very welcome by those that don't use mbox-based MUAs. The whole workflow if git-am is really trying if you are IMAP or Gmail/webmail based.

BTW, I recently had a go at using a Perl Gmail library to fetch messages with a particular label into an mbox, but the library didn't work, and I don't want to be chasing the taillights of gmails internal API. If the python Gmail library works better, I may have a go at learning python ;-)

cheers,

martin