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

[PATCH] diff-* --with-raw

From
Junio C Hamano <junkio@cox.net>
Date
Apr 11, 2006, 00:00 UTC
Message-ID
<7v7j5x7zh3.fsf@assigned-by-dhcp.cox.net>

Pasky wanted to have an option to get both diff-raw output and diff-patch output. This implements "git-diff-* --with-raw" (which obviously implies -p as well) to do so.

Because all the necessary information is already on extended header lines such as "index xxxxxx..yyyyyy" and "rename from" lines, this is not strictly necessary, but if it helps Porcelains...

--
diff --git a/diff.c b/diff.c
index 2fa285a..1a9fdab 100644
--- a/diff.c
+++ b/diff.c
@@ -862,6 +862,10 @@ int diff_opt_parse(struct diff_options *
 	const char *arg = av[0];
 	if (!strcmp(arg, "-p") || !strcmp(arg, "-u"))
 		options->output_format = DIFF_FORMAT_PATCH;
+	else if (!strcmp(arg, "--with-raw")) {
+		options->output_format = DIFF_FORMAT_PATCH;
+		options->with_raw = 1;
+	}
 	else if (!strcmp(arg, "-z"))
 		options->line_termination = 0;
 	else if (!strncmp(arg, "-l", 2))
@@ -1293,6 +1297,10 @@ void diff_flush(struct diff_options *opt
 		default:
 			switch (diff_output_format) {
 			case DIFF_FORMAT_PATCH:
+				if (options->with_raw)
+					diff_flush_raw(p, line_termination,
+						       inter_name_termination,
+						       options);
 				diff_flush_patch(p, options);
 				break;
 			case DIFF_FORMAT_RAW:
diff --git a/diff.h b/diff.h
index a02ef28..07b153b 100644
--- a/diff.h
+++ b/diff.h
@@ -24,6 +24,7 @@ struct diff_options {
 	const char *orderfile;
 	const char *pickaxe;
 	unsigned recursive:1,
+		 with_raw:1,
 		 tree_in_recursive:1,
 		 full_index:1;
 	int break_opt;
Next: Junio C Hamano
Message 1 of 6 in “diff-* --with-raw”
  1. diff-* --with-rawJunio C Hamano, Apr 11, 2006
  2. Junio C HamanoApr 11, 2006
  3. Petr BaudisApr 11, 2006
  4. Junio C HamanoApr 11, 2006
  5. Rename --with-raw to --patch-with-raw and document itPetr Baudis, Apr 11, 2006
  6. Separate the raw diff and patch with a newlinePetr Baudis, Apr 11, 2006

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.