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

[PATCH 4/5] Make --raw option available for all diff commands

From
THTimo Hirvonen <tihirvon@gmail.com>
Date
Jun 23, 2006, 22:00 UTC
Message-ID
<20060624010034.a7355905.tihirvon@gmail.com>
In-Reply-To
<20060624003315.804a1796.tihirvon@gmail.com>
Makes --raw a global diff output format option.
Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
---
 builtin-diff.c |   48 ++++++++++++------------------------------------
 diff.c         |    2 ++
 2 files changed, 14 insertions(+), 36 deletions(-)
diff --git a/builtin-diff.c b/builtin-diff.c
index b6f7727..8fd91b8 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -39,8 +39,6 @@ static int builtin_diff_files(struct rev
 			revs->max_count = 3;
 		else if (!strcmp(arg, "-q"))
 			silent = 1;
-		else if (!strcmp(arg, "--raw"))
-			revs->diffopt.output_fmt |= OUTPUT_FMT_RAW;
 		else
 			usage(builtin_diff_usage);
 		argv++; argc--;
@@ -107,14 +105,9 @@ static int builtin_diff_b_f(struct rev_i
 	/* Blob vs file in the working tree*/
 	struct stat st;
 
-	while (1 < argc) {
-		const char *arg = argv[1];
-		if (!strcmp(arg, "--raw"))
-			revs->diffopt.output_fmt |= OUTPUT_FMT_RAW;
-		else
-			usage(builtin_diff_usage);
-		argv++; argc--;
-	}
+	if (argc > 1)
+		usage(builtin_diff_usage);
+
 	if (lstat(path, &st))
 		die("'%s': %s", path, strerror(errno));
 	if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode)))
@@ -137,14 +130,9 @@ static int builtin_diff_blobs(struct rev
 	 */
 	unsigned mode = canon_mode(S_IFREG | 0644);
 
-	while (1 < argc) {
-		const char *arg = argv[1];
-		if (!strcmp(arg, "--raw"))
-			revs->diffopt.output_fmt |= OUTPUT_FMT_RAW;
-		else
-			usage(builtin_diff_usage);
-		argv++; argc--;
-	}
+	if (argc > 1)
+		usage(builtin_diff_usage);
+
 	stuff_change(&revs->diffopt,
 		     mode, mode,
 		     blob[1].sha1, blob[0].sha1,
@@ -162,8 +150,6 @@ static int builtin_diff_index(struct rev
 		const char *arg = argv[1];
 		if (!strcmp(arg, "--cached"))
 			cached = 1;
-		else if (!strcmp(arg, "--raw"))
-			revs->diffopt.output_fmt |= OUTPUT_FMT_RAW;
 		else
 			usage(builtin_diff_usage);
 		argv++; argc--;
@@ -185,14 +171,9 @@ static int builtin_diff_tree(struct rev_
 {
 	const unsigned char *(sha1[2]);
 	int swap = 0;
-	while (1 < argc) {
-		const char *arg = argv[1];
-		if (!strcmp(arg, "--raw"))
-			revs->diffopt.output_fmt |= OUTPUT_FMT_RAW;
-		else
-			usage(builtin_diff_usage);
-		argv++; argc--;
-	}
+
+	if (argc > 1)
+		usage(builtin_diff_usage);
 
 	/* We saw two trees, ent[0] and ent[1].
 	 * if ent[1] is unintesting, they are swapped
@@ -214,14 +195,9 @@ static int builtin_diff_combined(struct 
 	const unsigned char (*parent)[20];
 	int i;
 
-	while (1 < argc) {
-		const char *arg = argv[1];
-		if (!strcmp(arg, "--raw"))
-			revs->diffopt.output_fmt |= OUTPUT_FMT_RAW;
-		else
-			usage(builtin_diff_usage);
-		argv++; argc--;
-	}
+	if (argc > 1)
+		usage(builtin_diff_usage);
+
 	if (!revs->dense_combined_merges && !revs->combine_merges)
 		revs->dense_combined_merges = revs->combine_merges = 1;
 	parent = xmalloc(ents * sizeof(*parent));
diff --git a/diff.c b/diff.c
index 45c93c9..ab8aed7 100644
--- a/diff.c
+++ b/diff.c
@@ -1464,6 +1464,8 @@ int diff_opt_parse(struct diff_options *
 		options->output_fmt |= OUTPUT_FMT_PATCH;
 	else if (opt_arg(arg, 'U', "unified", &options->context))
 		options->output_fmt |= OUTPUT_FMT_PATCH;
+	else if (!strcmp(arg, "--raw"))
+		options->output_fmt |= OUTPUT_FMT_RAW;
 	else if (!strcmp(arg, "--patch-with-raw")) {
 		options->output_fmt |= OUTPUT_FMT_PATCH | OUTPUT_FMT_RAW;
 	}
-- 
1.4.1.rc1.gf603-dirty
Previous: Timo HirvonenNext: Timo Hirvonen
Message 7 of 8 in “git-merge: Don't use -p when outputting summary”
  1. 1/5 git-merge: Don't use -p when outputting summaryTimo Hirvonen, Jun 23, 2006
  2. 2/5 Rework diff optionsTimo Hirvonen, Jun 23, 2006
  3. Timo HirvonenJun 23, 2006
  4. Junio C HamanoJun 24, 2006
  5. Timo HirvonenJun 24, 2006
  6. 3/5 Set default diff output format after parsing command lineTimo Hirvonen, Jun 23, 2006
  7. 4/5 Make --raw option available for all diff commandsTimo Hirvonen, Jun 23, 2006
  8. 5/5 Add --patch option for diff-*Timo Hirvonen, Jun 23, 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.