threads / patch / 13400

patchgit-format-patch: add --no-binary to omit binary changes in the patch.

Subject: [PATCH] git-format-patch: add --no-binary to omit binary changes in the patch.

## tl;dr

4 messages between May 6, 2008 and May 9, 2008. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Caio Marcelo de Oliveira Filho· May 6, 2008, 17:47 UTC · lore

Add a new option --no-binary to git-format-patch so that no binary changes are included in the generated patches, only notices that those files changed. This generate patches that cannot be applied, but still is useful for generating mails for code review purposes.

See also: commit e47f306d4bf964def1a0b29e8f7cea419471dffd, where --binary option was turned on by default.

Signed-off-by: Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com>
---

This is a first try on the patch. The extra option affects only git-format-patch, since the special case (activating --binary if --text wasn't set) is only there.

 Documentation/git-format-patch.txt |    6 ++++++
 builtin-log.c                      |    5 ++++-
 2 files changed, 10 insertions(+), 1 deletions(-)
Show changes to 2 files +10 −1

Documentation/git-format-patch.txt, builtin-log.c

diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index b5207b7..81c930a 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -150,6 +150,12 @@ include::diff-options.txt[]
 	Instead of using `.patch` as the suffix for generated
 	filenames, use specified suffix.  A common alternative is
 	`--suffix=.txt`.
+
+--no-binary::
+	Don't output contents of changes in binary files, just take note
+	that they differ.  Note that this disable the patch to be properly
+	applied.  By default the contents of changes in those files are
+	encoded in the patch.
 +
 Note that you would need to include the leading dot `.` if you
 want a filename like `0001-description-of-my-change.patch`, and
diff --git a/builtin-log.c b/builtin-log.c
index 256bbac..80a01f8 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -757,6 +757,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	int thread = 0;
 	int cover_letter = 0;
 	int boundary_count = 0;
+	int no_binary_diff = 0;
 	struct commit *origin = NULL, *head = NULL;
 	const char *in_reply_to = NULL;
 	struct patch_ids ids;
@@ -862,6 +863,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 			fmt_patch_suffix = argv[i] + 9;
 		else if (!strcmp(argv[i], "--cover-letter"))
 			cover_letter = 1;
+		else if (!strcmp(argv[i], "--no-binary"))
+			no_binary_diff = 1;
 		else
 			argv[j++] = argv[i];
 	}
@@ -914,7 +917,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	if (!rev.diffopt.output_format)
 		rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;
 
-	if (!DIFF_OPT_TST(&rev.diffopt, TEXT))
+	if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
 		DIFF_OPT_SET(&rev.diffopt, BINARY);
 
 	if (!output_directory && !use_stdout)
-- 
1.5.5.1.147.g867f.dirty
Robin Rosenberg· May 9, 2008, 17:24 UTC · re: Caio Marcelo de Oliveira Filho · lore

Re: [PATCH] git-format-patch: add --no-binary to omit binary changes in the patch.

tisdagen den 6 maj 2008 19.47.59 skrev Caio Marcelo de Oliveira Filho:
Show 14 quoted lines
> Add a new option --no-binary to git-format-patch so that no binary
> changes are included in the generated patches, only notices that those
> files changed.  This generate patches that cannot be applied, but still
> is useful for generating mails for code review purposes.
>
> See also: commit e47f306d4bf964def1a0b29e8f7cea419471dffd, where --binary
> option was turned on by default.
>
> Signed-off-by: Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com>
> ---
>
> This is a first try on the patch.  The extra option affects only
> git-format-patch, since the special case (activating --binary if
> --text wasn't set) is only there.
Fine with me.
-- robin
Jonas Fonseca· May 9, 2008, 21:08 UTC · re: Caio Marcelo de Oliveira Filho · lore

Re: [PATCH] git-format-patch: add --no-binary to omit binary changes in the patch.

On Tue, May 6, 2008 at 7:47 PM, Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com> wrote:

Show 18 quoted lines
> diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
> index b5207b7..81c930a 100644
> --- a/Documentation/git-format-patch.txt
> +++ b/Documentation/git-format-patch.txt
> @@ -150,6 +150,12 @@ include::diff-options.txt[]
>        Instead of using `.patch` as the suffix for generated
>        filenames, use specified suffix.  A common alternative is
>        `--suffix=.txt`.
> +
> +--no-binary::
> +       Don't output contents of changes in binary files, just take note
> +       that they differ.  Note that this disable the patch to be properly
> +       applied.  By default the contents of changes in those files are
> +       encoded in the patch.
>  +
>  Note that you would need to include the leading dot `.` if you
>  want a filename like `0001-description-of-my-change.patch`, and
> diff --git a/builtin-log.c b/builtin-log.c

The '+' on the start of a line means continue last list item. In other words, your update to the manpage will result in the --no-binary option having a second paragraph that was really intended for the --suffix option.

-- 
Jonas Fonseca
Caio Marcelo de Oliveira Filho· May 9, 2008, 22:55 UTC · re: Jonas Fonseca · lore

Add a new option --no-binary to git-format-patch so that no binary changes are included in the generated patches, only notices that those files changed. This generate patches that cannot be applied, but still is useful for generating mails for code review purposes.

See also: commit e47f306d4bf964def1a0b29e8f7cea419471dffd, where --binary option was turned on by default.

Signed-off-by: Caio Marcelo de Oliveira Filho <cmarcelo@gmail.com>
---
Fixed the manpage, thanks Jonas Fonseca.
 Documentation/git-format-patch.txt |    6 ++++++
 builtin-log.c                      |    5 ++++-
 2 files changed, 10 insertions(+), 1 deletions(-)
Show changes to 2 files +10 −1

Documentation/git-format-patch.txt, builtin-log.c

diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt
index 87e491b..7548a21 100644
--- a/Documentation/git-format-patch.txt
+++ b/Documentation/git-format-patch.txt
@@ -156,6 +156,12 @@ want a filename like `0001-description-of-my-change.patch`, and
 the first letter does not have to be a dot.  Leaving it empty would
 not add any suffix.
 
+--no-binary::
+	Don't output contents of changes in binary files, just take note
+	that they differ.  Note that this disable the patch to be properly
+	applied.  By default the contents of changes in those files are
+	encoded in the patch.
+
 CONFIGURATION
 -------------
 You can specify extra mail header lines to be added to each message
diff --git a/builtin-log.c b/builtin-log.c
index 256bbac..80a01f8 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -757,6 +757,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	int thread = 0;
 	int cover_letter = 0;
 	int boundary_count = 0;
+	int no_binary_diff = 0;
 	struct commit *origin = NULL, *head = NULL;
 	const char *in_reply_to = NULL;
 	struct patch_ids ids;
@@ -862,6 +863,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 			fmt_patch_suffix = argv[i] + 9;
 		else if (!strcmp(argv[i], "--cover-letter"))
 			cover_letter = 1;
+		else if (!strcmp(argv[i], "--no-binary"))
+			no_binary_diff = 1;
 		else
 			argv[j++] = argv[i];
 	}
@@ -914,7 +917,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
 	if (!rev.diffopt.output_format)
 		rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;
 
-	if (!DIFF_OPT_TST(&rev.diffopt, TEXT))
+	if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
 		DIFF_OPT_SET(&rev.diffopt, BINARY);
 
 	if (!output_directory && !use_stdout)
-- 
1.5.5.1.147.g867f.dirty

← back to recent threads