All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Marco Costalba <mcostalba@gmail.com>, GIT list <git@vger.kernel.org>
Subject: [PATCH 1/2] run_diff_{files,index}(): update calling convention.
Date: Fri, 09 Feb 2007 18:51:40 -0800	[thread overview]
Message-ID: <7vy7n6ohc3.fsf_-_@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <7vejoyq330.fsf@assigned-by-dhcp.cox.net> (Junio C. Hamano's message of "Fri, 09 Feb 2007 16:16:35 -0800")

They used to open and read index themselves, but they now expect
their callers to do so.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 * This is preparatoin for the next one...

 builtin-diff-files.c |    4 ++++
 builtin-diff-index.c |    4 ++++
 builtin-diff.c       |    8 ++++++++
 diff-lib.c           |   10 +---------
 wt-status.c          |   12 ++++++++++--
 5 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/builtin-diff-files.c b/builtin-diff-files.c
index 5d4a5c5..3ee2605 100644
--- a/builtin-diff-files.c
+++ b/builtin-diff-files.c
@@ -47,5 +47,9 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 	if (rev.pending.nr ||
 	    rev.min_age != -1 || rev.max_age != -1)
 		usage(diff_files_usage);
+	if (read_cache() < 0) {
+		perror("read_cache");
+		return -1;
+	}
 	return run_diff_files(&rev, silent);
 }
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index 95a3db1..083599d 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -38,5 +38,9 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
 	if (rev.pending.nr != 1 ||
 	    rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
 		usage(diff_cache_usage);
+	if (read_cache() < 0) {
+		perror("read_cache");
+		return -1;
+	}
 	return run_diff_index(&rev, cached);
 }
diff --git a/builtin-diff.c b/builtin-diff.c
index a659020..12d11f0 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -56,6 +56,10 @@ static int builtin_diff_files(struct rev_info *revs,
 	if (revs->max_count < 0 &&
 	    (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
 		revs->combine_merges = revs->dense_combined_merges = 1;
+	if (read_cache() < 0) {
+		perror("read_cache");
+		return -1;
+	}
 	return run_diff_files(revs, silent);
 }
 
@@ -151,6 +155,10 @@ static int builtin_diff_index(struct rev_info *revs,
 	    revs->max_count != -1 || revs->min_age != -1 ||
 	    revs->max_age != -1)
 		usage(builtin_diff_usage);
+	if (read_cache() < 0) {
+		perror("read_cache");
+		return -1;
+	}
 	return run_diff_index(revs, cached);
 }
 
diff --git a/diff-lib.c b/diff-lib.c
index 91cd877..278ba79 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -20,11 +20,7 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
 
 	if (diff_unmerged_stage < 0)
 		diff_unmerged_stage = 2;
-	entries = read_cache();
-	if (entries < 0) {
-		perror("read_cache");
-		return -1;
-	}
+	entries = active_nr;
 	for (i = 0; i < entries; i++) {
 		struct stat st;
 		unsigned int oldmode, newmode;
@@ -354,10 +350,6 @@ int run_diff_index(struct rev_info *revs, int cached)
 	if (!revs->ignore_merges)
 		match_missing = 1;
 
-	if (read_cache() < 0) {
-		perror("read_cache");
-		return -1;
-	}
 	mark_merge_entries();
 
 	ent = revs->pending.objects[0].item;
diff --git a/wt-status.c b/wt-status.c
index 2879c3d..e346511 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -191,12 +191,18 @@ static void wt_status_print_changed_cb(struct diff_queue_struct *q,
 		wt_status_print_trailer();
 }
 
+static void wt_read_cache(struct wt_status *s)
+{
+	discard_cache();
+	read_cache();
+}
+
 void wt_status_print_initial(struct wt_status *s)
 {
 	int i;
 	char buf[PATH_MAX];
 
-	read_cache();
+	wt_read_cache(s);
 	if (active_nr) {
 		s->commitable = 1;
 		wt_status_print_cached_header(NULL);
@@ -220,6 +226,7 @@ static void wt_status_print_updated(struct wt_status *s)
 	rev.diffopt.format_callback = wt_status_print_updated_cb;
 	rev.diffopt.format_callback_data = s;
 	rev.diffopt.detect_rename = 1;
+	wt_read_cache(s);
 	run_diff_index(&rev, 1);
 }
 
@@ -231,6 +238,7 @@ static void wt_status_print_changed(struct wt_status *s)
 	rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 	rev.diffopt.format_callback = wt_status_print_changed_cb;
 	rev.diffopt.format_callback_data = s;
+	wt_read_cache(s);
 	run_diff_files(&rev, 0);
 }
 
@@ -287,6 +295,7 @@ static void wt_status_print_verbose(struct wt_status *s)
 	setup_revisions(0, NULL, &rev, s->reference);
 	rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
 	rev.diffopt.detect_rename = 1;
+	wt_read_cache(s);
 	run_diff_index(&rev, 1);
 }
 
@@ -316,7 +325,6 @@ void wt_status_print(struct wt_status *s)
 	}
 	else {
 		wt_status_print_updated(s);
-		discard_cache();
 	}
 
 	wt_status_print_changed(s);
-- 
1.5.0.rc4.26.gcc46

  reply	other threads:[~2007-02-10  2:51 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-09 19:25 'git status' is not read-only fs friendly Marco Costalba
2007-02-09 19:56 ` Linus Torvalds
2007-02-09 20:19   ` Marco Costalba
2007-02-09 20:27     ` Junio C Hamano
2007-02-09 20:22   ` Junio C Hamano
2007-02-09 20:29     ` Morten Welinder
2007-02-09 23:27       ` Theodore Tso
2007-02-09 20:35     ` Marco Costalba
2007-02-09 20:59       ` Linus Torvalds
2007-02-10  0:12         ` Junio C Hamano
2007-02-10  0:16           ` Junio C Hamano
2007-02-10  2:51             ` Junio C Hamano [this message]
2007-02-10  8:02               ` [PATCH 1/2] run_diff_{files,index}(): update calling convention Marco Costalba
2007-02-10  8:20                 ` Junio C Hamano
2007-02-10  8:29                   ` Marco Costalba
2007-02-10  8:46                     ` Marco Costalba
2007-02-10 10:40                       ` Junio C Hamano
2007-02-10 11:25                         ` Marco Costalba
2007-02-10 15:13                           ` Junio C Hamano
2007-02-10 15:51                             ` Marco Costalba
2007-02-10  2:51             ` [PATCH 2/2] git-runstatus --refresh Junio C Hamano
2007-02-10 14:19 ` 'git status' is not read-only fs friendly Johannes Schindelin
2007-02-10 14:31   ` Marco Costalba
2007-02-10 14:41     ` Johannes Schindelin
2007-02-10 14:48       ` Marco Costalba
2007-02-10 14:51         ` Marco Costalba
2007-02-10 16:25           ` Junio C Hamano
2007-02-10 20:36             ` Johannes Schindelin
2007-02-11 21:57               ` Junio C Hamano
2007-02-11 22:09                 ` Johannes Schindelin
2007-02-11 22:28                   ` Johannes Schindelin
2007-02-11 22:30                   ` Junio C Hamano
2007-02-11 23:24                     ` Johannes Schindelin
2007-02-10 14:59         ` Johannes Schindelin
2007-02-10 15:45           ` Marco Costalba
2007-02-10 15:54           ` Nicolas Pitre
2007-02-10 16:27             ` Junio C Hamano
2007-02-10 16:40               ` Nicolas Pitre
2007-02-10 16:46                 ` Junio C Hamano
2007-02-10 17:03                   ` Nicolas Pitre
2007-02-10 18:00                     ` Junio C Hamano
2007-02-10 18:43                       ` Theodore Tso
2007-02-10 18:53                       ` Nicolas Pitre
2007-02-10 18:56                         ` Theodore Tso
2007-02-10 19:08                         ` Marco Costalba
2007-02-10 17:37                 ` Linus Torvalds
2007-02-10 18:51                   ` Nicolas Pitre
2007-02-11  6:33                   ` Junio C Hamano
2007-02-11  7:23                   ` Shawn O. Pearce
2007-02-10 20:40             ` Johannes Schindelin
2007-02-10 16:25           ` Junio C Hamano
2007-02-10 16:35             ` Marco Costalba

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=7vy7n6ohc3.fsf_-_@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=mcostalba@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.