git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Timo Hirvonen <tihirvon@gmail.com>
To: junkio@cox.net
Cc: git@vger.kernel.org
Subject: [PATCH 3/5] Set default diff output format after parsing command line
Date: Sat, 24 Jun 2006 00:58:25 +0300	[thread overview]
Message-ID: <20060624005825.92b46022.tihirvon@gmail.com> (raw)
In-Reply-To: <20060624003315.804a1796.tihirvon@gmail.com>

Move code that sets default output format values after command line
argument parsing.  Only set defaults if output_fmt was not touched by
command line options.

This makes "git diff --raw" output only in raw format instead of -p --raw.

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
---
 builtin-diff-files.c  |    4 ++++
 builtin-diff-index.c  |    4 ++++
 builtin-diff-stages.c |    3 +++
 builtin-diff-tree.c   |    3 +++
 builtin-diff.c        |    4 +++-
 builtin-log.c         |    4 +++-
 diff.c                |    1 -
 7 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/builtin-diff-files.c b/builtin-diff-files.c
index 42ca07d..4cf2e2f 100644
--- a/builtin-diff-files.c
+++ b/builtin-diff-files.c
@@ -36,6 +36,10 @@ int cmd_diff_files(int argc, const char 
 			usage(diff_files_usage);
 		argv++; argc--;
 	}
+
+	if (!rev.diffopt.output_fmt)
+		rev.diffopt.output_fmt = OUTPUT_FMT_RAW;
+
 	/*
 	 * Make sure there are NO revision (i.e. pending object) parameter,
 	 * rev.max_count is reasonable (0 <= n <= 3),
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index c42ef9a..8e58308 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -28,6 +28,10 @@ int cmd_diff_index(int argc, const char 
 		else
 			usage(diff_cache_usage);
 	}
+
+	if (!rev.diffopt.output_fmt)
+		rev.diffopt.output_fmt = OUTPUT_FMT_RAW;
+
 	/*
 	 * Make sure there is one revision (i.e. pending object),
 	 * and there is no revision filtering parameters.
diff --git a/builtin-diff-stages.c b/builtin-diff-stages.c
index 7c157ca..c26a589 100644
--- a/builtin-diff-stages.c
+++ b/builtin-diff-stages.c
@@ -85,6 +85,9 @@ int cmd_diff_stages(int ac, const char *
 		ac--; av++;
 	}
 
+	if (!diff_options.output_fmt)
+		diff_options.output_fmt = OUTPUT_FMT_RAW;
+
 	if (ac < 3 ||
 	    sscanf(av[1], "%d", &stage1) != 1 ||
 	    ! (0 <= stage1 && stage1 <= 3) ||
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index 3409a39..29b3fe1 100644
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
@@ -84,6 +84,9 @@ int cmd_diff_tree(int argc, const char *
 		usage(diff_tree_usage);
 	}
 
+	if (!opt->diffopt.output_fmt)
+		opt->diffopt.output_fmt = OUTPUT_FMT_RAW;
+
 	/*
 	 * NOTE! We expect "a ^b" to be equal to "a..b", so we
 	 * reverse the order of the objects if the second one
diff --git a/builtin-diff.c b/builtin-diff.c
index 372894a..b6f7727 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -276,9 +276,11 @@ int cmd_diff(int argc, const char **argv
 
 	git_config(git_diff_config);
 	init_revisions(&rev);
-	rev.diffopt.output_fmt = OUTPUT_FMT_PATCH;
 
 	argc = setup_revisions(argc, argv, &rev, NULL);
+	if (!rev.diffopt.output_fmt)
+		rev.diffopt.output_fmt = OUTPUT_FMT_PATCH;
+
 	/* Do we have --cached and not have a pending object, then
 	 * default to HEAD by hand.  Eek.
 	 */
diff --git a/builtin-log.c b/builtin-log.c
index e4a6385..e72d7fe 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -178,7 +178,6 @@ int cmd_format_patch(int argc, const cha
 	rev.diff = 1;
 	rev.combine_merges = 0;
 	rev.ignore_merges = 1;
-	rev.diffopt.output_fmt = OUTPUT_FMT_DIFFSTAT | OUTPUT_FMT_PATCH;
 
 	git_config(git_format_config);
 	rev.extra_headers = extra_headers;
@@ -247,6 +246,9 @@ int cmd_format_patch(int argc, const cha
 	if (argc > 1)
 		die ("unrecognized argument: %s", argv[1]);
 
+	if (!rev.diffopt.output_fmt)
+		rev.diffopt.output_fmt = OUTPUT_FMT_DIFFSTAT | OUTPUT_FMT_PATCH;
+
 	if (output_directory) {
 		if (use_stdout)
 			die("standard output, or directory, which one?");
diff --git a/diff.c b/diff.c
index 6eb7db0..45c93c9 100644
--- a/diff.c
+++ b/diff.c
@@ -1354,7 +1354,6 @@ static void run_checkdiff(struct diff_fi
 void diff_setup(struct diff_options *options)
 {
 	memset(options, 0, sizeof(*options));
-	options->output_fmt = OUTPUT_FMT_RAW;
 	options->line_termination = '\n';
 	options->break_opt = -1;
 	options->rename_limit = -1;
-- 
1.4.1.rc1.gf603-dirty

  parent reply	other threads:[~2006-06-23 22:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20060624003315.804a1796.tihirvon@gmail.com>
2006-06-23 21:45 ` [PATCH 1/5] git-merge: Don't use -p when outputting summary Timo Hirvonen
2006-06-23 21:52 ` [PATCH 2/5] Rework diff options Timo Hirvonen
2006-06-23 22:40   ` Timo Hirvonen
2006-06-24  6:55   ` Junio C Hamano
2006-06-24 11:29     ` Timo Hirvonen
2006-06-23 21:58 ` Timo Hirvonen [this message]
2006-06-23 22:00 ` [PATCH 4/5] Make --raw option available for all diff commands Timo Hirvonen
2006-06-23 22:01 ` [PATCH 5/5] Add --patch option for diff-* Timo Hirvonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060624005825.92b46022.tihirvon@gmail.com \
    --to=tihirvon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).