git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Creating attachments using git-format-patch

From
Panagiotis Issaris <takis@issaris.org>
Date
Mar 4, 2007, 19:48 UTC
Message-ID
<45EB2294.9040702@issaris.org>
In-Reply-To
<7vmz2t7i1x.fsf@assigned-by-dhcp.cox.net>
Hi,
Junio C Hamano schreef:
Show 8 quoted lines
> The existing --attach option did not create a true "attachment"
> but multipart/mixed with Content-Disposition: inline.  It should
> have been with Content-Disposition: attachment.
>
> Introduce --inline to add multipart/mixed that is inlined, and
> make --attach to create an attachement.
>
> [...]

The patch did not work for me until I modified it a bit. I've added a modified full patch and an incremental one.

The patch did not work for me in the sense that the patches still appeared as inline text in both Mutt (1.5.13) and Thunderbird (2 beta 2).

The email show up as being threaded in Mutt, but in Thunderbird they still do not show up threaded. (Others do show up threaded, such as this thread about git-format-patch attachments, so Thunderbird appears to work alright).

 Documentation/git-format-patch.txt |   14 +++++++++++---
 builtin-log.c                      |   16 ++++++++++++++--
 log-tree.c                         |   10 ++++++----
 revision.h                         |    1 +
 4 files changed, 32 insertions(+), 9 deletions(-)
 log-tree.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signed-off-by: Panagiotis Issaris <takis@issaris.org>
Thanks for the quick response and help! :-)
With friendly regards,
Takis
diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 59f34b9..dfdb652 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -9,7 +9,8 @@ git-format-patch - Prepare patches for e-mail submission
 SYNOPSIS
 --------
 [verse]
-'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--attach] [--thread]
+'git-format-patch' [-n | -k] [-o <dir> | --stdout] [--thread]
+	           [--attach[=<boundary>] | --inline[=<boundary>]]
 	           [-s | --signoff] [--diff-options] [--start-number <n>]
 		   [--in-reply-to=Message-Id] [--suffix=.<sfx>]
 		   [--ignore-if-in-upstream]
@@ -68,8 +69,15 @@ OPTIONS
 	Print all commits to the standard output in mbox format,
 	instead of creating a file for each one.
 
---attach::
-	Create attachments instead of inlining patches.
+--attach[=<boundary>]::
+	Create multipart/mixed attachment, the first part of
+	which is the commit message and the patch itself in the
+	second part, with "Content-Disposition: attachment".
+
+--inline[=<boundary>]::
+	Create multipart/mixed attachment, the first part of
+	which is the commit message and the patch itself in the
+	second part, with "Content-Disposition: inline".
 
 --thread::
 	Add In-Reply-To and References headers to make the second and
diff --git a/builtin-log.c b/builtin-log.c
index 1c9f7d0..865832c 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -482,10 +482,22 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 			memcpy(add_signoff, committer, endpos - committer + 1);
 			add_signoff[endpos - committer + 1] = 0;
 		}
-		else if (!strcmp(argv[i], "--attach"))
+		else if (!strcmp(argv[i], "--attach")) {
 			rev.mime_boundary = git_version_string;
-		else if (!prefixcmp(argv[i], "--attach="))
+			rev.no_inline = 1;
+		}
+		else if (!prefixcmp(argv[i], "--attach=")) {
+			rev.mime_boundary = argv[i] + 9;
+			rev.no_inline = 1;
+		}
+		else if (!strcmp(argv[i], "--inline")) {
+			rev.mime_boundary = git_version_string;
+			rev.no_inline = 0;
+		}
+		else if (!prefixcmp(argv[i], "--inline=")) {
 			rev.mime_boundary = argv[i] + 9;
+			rev.no_inline = 0;
+		}
 		else if (!strcmp(argv[i], "--ignore-if-in-upstream"))
 			ignore_if_in_upstream = 1;
 		else if (!strcmp(argv[i], "--thread"))
diff --git a/log-tree.c b/log-tree.c
index 6ce239d..8797aa1 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -186,7 +186,7 @@ void show_log(struct rev_info *opt, const char *sep)
 			snprintf(subject_buffer, sizeof(subject_buffer) - 1,
 				 "%s"
 				 "MIME-Version: 1.0\n"
-				 "Content-Type: multipart/mixed;\n"
+				 "Content-Type: multipart/mixed;"
 				 " boundary=\"%s%s\"\n"
 				 "\n"
 				 "This is a multi-part message in MIME "
@@ -202,13 +202,15 @@ void show_log(struct rev_info *opt, const char *sep)
 
 			snprintf(buffer, sizeof(buffer) - 1,
 				 "--%s%s\n"
-				 "Content-Type: text/x-patch;\n"
+				 "Content-Type: text/x-patch;"
 				 " name=\"%s.diff\"\n"
 				 "Content-Transfer-Encoding: 8bit\n"
-				 "Content-Disposition: inline;\n"
+				 "Content-Disposition: %s;"
 				 " filename=\"%s.diff\"\n\n",
 				 mime_boundary_leader, opt->mime_boundary,
-				 sha1, sha1);
+				 sha1,
+				 opt->no_inline ? "attachment" : "inline",
+				 sha1);
 			opt->diffopt.stat_sep = buffer;
 		}
 	} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
diff --git a/revision.h b/revision.h
index 5fec184..cf33713 100644
--- a/revision.h
+++ b/revision.h
@@ -74,6 +74,7 @@ struct rev_info {
 	const char	*add_signoff;
 	const char	*extra_headers;
 	const char	*log_reencode;
+	int		no_inline;
 
 	/* Filter by commit log message */
 	struct grep_opt	*grep_filter;


diff -u b/log-tree.c b/log-tree.c
--- b/log-tree.c
+++ b/log-tree.c
@@ -186,7 +186,7 @@
 			snprintf(subject_buffer, sizeof(subject_buffer) - 1,
 				 "%s"
 				 "MIME-Version: 1.0\n"
-				 "Content-Type: multipart/mixed;\n"
+				 "Content-Type: multipart/mixed;"
 				 " boundary=\"%s%s\"\n"
 				 "\n"
 				 "This is a multi-part message in MIME "
@@ -202,10 +202,10 @@
 
 			snprintf(buffer, sizeof(buffer) - 1,
 				 "--%s%s\n"
-				 "Content-Type: text/x-patch;\n"
+				 "Content-Type: text/x-patch;"
 				 " name=\"%s.diff\"\n"
 				 "Content-Transfer-Encoding: 8bit\n"
-				 "Content-Disposition: %s;\n"
+				 "Content-Disposition: %s;"
 				 " filename=\"%s.diff\"\n\n",
 				 mime_boundary_leader, opt->mime_boundary,
 				 sha1,
Previous: Johannes SchindelinNext: Panagiotis Issaris
Message 8 of 12 in “Creating attachments using git-format-patch”
  1. Panagiotis IssarisMar 3, 2007
  2. Junio C HamanoMar 3, 2007
  3. Johannes SchindelinMar 3, 2007
  4. format-patch: add --no-inline optionJohannes Schindelin, Mar 3, 2007
  5. Junio C HamanoMar 4, 2007
  6. Junio C HamanoMar 4, 2007
  7. Johannes SchindelinMar 4, 2007
  8. Panagiotis IssarisMar 4, 2007
  9. Panagiotis IssarisMar 4, 2007
  10. Junio C HamanoMar 4, 2007
  11. Panagiotis IssarisMar 4, 2007
  12. Junio C HamanoMar 5, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.