* [PATCH] git-am --one
@ 2005-12-14 1:10 H. Peter Anvin
2005-12-14 1:30 ` Junio C Hamano
2005-12-14 2:06 ` Junio C Hamano
0 siblings, 2 replies; 6+ messages in thread
From: H. Peter Anvin @ 2005-12-14 1:10 UTC (permalink / raw)
To: Git Mailing List
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
This patch adds the --one (-o) option to git-am, to apply a single
message in RFC 2822 format, as opposed to an mbox. With some MUAs it's
a lot easier to save individual messages than with mboxes, and either
way the user may want to control the ordering if there are known
interdependencies.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
[-- Attachment #2: git-am-one --]
[-- Type: text/plain, Size: 2100 bytes --]
diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index a415fe2..bec5c84 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -8,7 +8,7 @@ git-am - Apply a series of patches in a
SYNOPSIS
--------
-'git-am' [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>...
+'git-am' [--one] [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>...
'git-am' [--skip | --resolved]
DESCRIPTION
@@ -19,6 +19,10 @@ current branch.
OPTIONS
-------
+--one::
+ Indicates that <mbox> contains a single message in RFC 2822
+ format, without mbox-style separators.
+
--signoff::
Add `Signed-off-by:` line to the commit message, using
the committer identity of yourself.
diff --git a/git-am.sh b/git-am.sh
index 6ed527c..9628651 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -4,7 +4,7 @@
. git-sh-setup
usage () {
- echo >&2 "usage: $0 [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>"
+ echo >&2 "usage: $0 [--one] [--signoff] [--dotest=<dir>] [--utf8] [--binary] [--3way] <mbox>"
echo >&2 " or, when resuming"
echo >&2 " $0 [--skip | --resolved]"
exit 1;
@@ -98,11 +98,13 @@ fall_back_3way () {
}
prec=4
-dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary=
+dotest=.dotest sign= utf8= keep= skip= interactive= resolved= binary= one=
while case "$#" in 0) break;; esac
do
case "$1" in
+ -o|--o|--on|--one)
+ one=t; shift;;
-d=*|--d=*|--do=*|--dot=*|--dote=*|--dotes=*|--dotest=*)
dotest=`expr "$1" : '-[^=]*=\(.*\)'`; shift ;;
-d|--d|--do|--dot|--dote|--dotes|--dotest)
@@ -165,8 +167,16 @@ else
mkdir -p "$dotest" || exit
# cat does the right thing for us, including '-' to mean
- # standard input.
- cat "$@" |
+ # standard input. To prepend the header, we thus want a
+ # second cat, sigh...
+ if test "$one" = t
+ then
+ LANG=C date +'From - %a %b %d %T %Y' > "$dotest"/fakefrom
+ fakefrom="$dotest"/fakefrom
+ else
+ fakefrom=/dev/null
+ fi
+ cat "$@" | cat "$fakefrom" - |
git-mailsplit -d$prec "$dotest/" >"$dotest/last" || {
rm -fr "$dotest"
exit 1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] git-am --one
2005-12-14 1:10 [PATCH] git-am --one H. Peter Anvin
@ 2005-12-14 1:30 ` Junio C Hamano
2005-12-14 1:47 ` H. Peter Anvin
2005-12-14 2:06 ` Junio C Hamano
1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2005-12-14 1:30 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: git
"H. Peter Anvin" <hpa@zytor.com> writes:
> This patch adds the --one (-o) option to git-am, to apply a single
> message in RFC 2822 format, as opposed to an mbox. With some MUAs it's
> a lot easier to save individual messages than with mboxes, and either
> way the user may want to control the ordering if there are known
> interdependencies.
> + # standard input. To prepend the header, we thus want a
> + # second cat, sigh...
> + if test "$one" = t
> + then
> + LANG=C date +'From - %a %b %d %T %Y' > "$dotest"/fakefrom
> + fakefrom="$dotest"/fakefrom
> + else
> + fakefrom=/dev/null
> + fi
> + cat "$@" | cat "$fakefrom" - |
> git-mailsplit -d$prec "$dotest/" >"$dotest/last" || {
> rm -fr "$dotest"
> exit 1
I understand the motivation, but I suspect skipping mailsplit
might be simpler, like this untested code perhaps?
case "$one" in
'')
... original code ...
;;
*)
one=`printf "%${prec}d" 1`
cat "$@" >"$dotest/$one"
echo "$one" >"$dotest/last"
;;
esac
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] git-am --one
2005-12-14 1:30 ` Junio C Hamano
@ 2005-12-14 1:47 ` H. Peter Anvin
2005-12-14 1:54 ` Junio C Hamano
0 siblings, 1 reply; 6+ messages in thread
From: H. Peter Anvin @ 2005-12-14 1:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano wrote:
>
> I understand the motivation, but I suspect skipping mailsplit
> might be simpler, like this untested code perhaps?
>
> case "$one" in
> '')
> ... original code ...
> ;;
> *)
> one=`printf "%${prec}d" 1`
> cat "$@" >"$dotest/$one"
> echo "$one" >"$dotest/last"
> ;;
> esac
>
If that works, great. I just implemented it in the "most obviously
correct" way, meaning with as few changes as possible.
-hpa
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] git-am --one
2005-12-14 1:47 ` H. Peter Anvin
@ 2005-12-14 1:54 ` Junio C Hamano
2005-12-14 1:58 ` H. Peter Anvin
0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2005-12-14 1:54 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: git
"H. Peter Anvin" <hpa@zytor.com> writes:
> Junio C Hamano wrote:
>> I understand the motivation, but I suspect skipping mailsplit
>> might be simpler, like this untested code perhaps?
>> case "$one" in
>> '')
>> ... original code ...
>> ;;
>> *)
>> one=`printf "%${prec}d" 1`
>> cat "$@" >"$dotest/$one"
>> echo "$one" >"$dotest/last"
>> ;;
>> esac
>>
>
> If that works, great. I just implemented it in the "most obviously
> correct" way, meaning with as few changes as possible.
Another thing you may probably want is to loop over "$@", so
that the flag is not --one anymore, but --2822 (or --bare as
opposed to mbox format) and do something like this:
case "$series_of_2822_messages" in
'') ... original code ... ;;
*)
i=1
for input
do
this=`printf "%${prec}d" $i
cp "$input" "$dotest/$this"
i=$(($i+1))
done
printf "%${prec}d" $# >"$dotest/last"
;;
esac
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] git-am --one
2005-12-14 1:54 ` Junio C Hamano
@ 2005-12-14 1:58 ` H. Peter Anvin
0 siblings, 0 replies; 6+ messages in thread
From: H. Peter Anvin @ 2005-12-14 1:58 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano wrote:
>
> Another thing you may probably want is to loop over "$@", so
> that the flag is not --one anymore, but --2822 (or --bare as
> opposed to mbox format) and do something like this:
>
> case "$series_of_2822_messages" in
> '') ... original code ... ;;
> *)
> i=1
> for input
> do
> this=`printf "%${prec}d" $i
> cp "$input" "$dotest/$this"
> i=$(($i+1))
> done
> printf "%${prec}d" $# >"$dotest/last"
> ;;
> esac
>
That is definitely a good idea. I'll mess with it a bit.
-hpa
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] git-am --one
2005-12-14 1:10 [PATCH] git-am --one H. Peter Anvin
2005-12-14 1:30 ` Junio C Hamano
@ 2005-12-14 2:06 ` Junio C Hamano
1 sibling, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2005-12-14 2:06 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: git
"H. Peter Anvin" <hpa@zytor.com> writes:
> This is a multi-part message in MIME format.
> --------------080605010801030702080802
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> Content-Transfer-Encoding: 7bit
BTW, this is totally offtopic, but I find it somewhat puzzling
to see somebody like you, one of Linus' trusted lieutenants, is
sending a patch as an attachment.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-12-14 2:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-14 1:10 [PATCH] git-am --one H. Peter Anvin
2005-12-14 1:30 ` Junio C Hamano
2005-12-14 1:47 ` H. Peter Anvin
2005-12-14 1:54 ` Junio C Hamano
2005-12-14 1:58 ` H. Peter Anvin
2005-12-14 2:06 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).