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

[PATCH] run_diff_files(): add option to prevent --no-index

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 22, 2007, 18:54 UTC
Message-ID
<Pine.LNX.4.63.0702221952140.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<Pine.LNX.4.63.0702221926390.22628@wbgn013.biozentrum.uni-wuerzburg.de>

An important user, wt-status, does not want no-index. So add a parameter to run_diff_files() which says if it is allowed or not.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	> How about adding "int always_use_index" to the signature of 
	> run_diff_files()?
	I called the parameter "allow_no_index", since it is a little 
	friendlier. I have been accused of being not friendly enough.
 builtin-diff-files.c |    2 +-
 builtin-diff.c       |    2 +-
 diff-lib.c           |    5 +++--
 diff.h               |    2 +-
 wt-status.c          |    2 +-
 5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/builtin-diff-files.c b/builtin-diff-files.c
index 8d78dfa..05a81b1 100644
--- a/builtin-diff-files.c
+++ b/builtin-diff-files.c
@@ -26,5 +26,5 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
 	argc = setup_revisions(argc, argv, &rev, NULL);
 	if (!rev.diffopt.output_format)
 		rev.diffopt.output_format = DIFF_FORMAT_RAW;
-	return run_diff_files(&rev, argc, argv);
+	return run_diff_files(&rev, argc, argv, 1);
 }
diff --git a/builtin-diff.c b/builtin-diff.c
index 9334589..7f1ad60 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -282,7 +282,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 	if (!ents) {
 		switch (blobs) {
 		case 0:
-			return run_diff_files(&rev, argc, argv);
+			return run_diff_files(&rev, argc, argv, 1);
 			break;
 		case 1:
 			if (paths != 1)
diff --git a/diff-lib.c b/diff-lib.c
index 83d6682..7877f5c 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -200,7 +200,8 @@ static int handle_diff_files_args(struct rev_info *revs,
 	return 0;
 }
 
-int run_diff_files(struct rev_info *revs, int argc, const char **argv)
+int run_diff_files(struct rev_info *revs, int argc, const char **argv,
+		int allow_no_index)
 {
 	int entries, i;
 	int diff_unmerged_stage;
@@ -211,7 +212,7 @@ int run_diff_files(struct rev_info *revs, int argc, const char **argv)
 
 	diff_unmerged_stage = revs->max_count;
 
-	if (revs->max_count == -2) {
+	if (allow_no_index && revs->max_count == -2) {
 		if (revs->diffopt.nr_paths != 2)
 			return error("need two files/directories with --no-index");
 		queue_diff(&revs->diffopt, revs->diffopt.paths[0],
diff --git a/diff.h b/diff.h
index cc28418..bf2d3c9 100644
--- a/diff.h
+++ b/diff.h
@@ -218,7 +218,7 @@ extern void diff_flush(struct diff_options*);
 
 extern const char *diff_unique_abbrev(const unsigned char *, int);
 
-extern int run_diff_files(struct rev_info *revs, int argc, const char **argv);
+extern int run_diff_files(struct rev_info *revs, int argc, const char **argv, int allow_no_index);
 
 extern int run_diff_index(struct rev_info *revs, int cached);
 
diff --git a/wt-status.c b/wt-status.c
index b68eea3..4e8904d 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -231,7 +231,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;
-	run_diff_files(&rev, 0, NULL);
+	run_diff_files(&rev, 0, NULL, 0);
 }
 
 static void wt_status_print_untracked(struct wt_status *s)
-- 
1.5.0.51.ge5582-dirty
Previous: Johannes SchindelinNext: Junio C Hamano
Message 6 of 13 in “Teach git-diff{,-files} the new option `--no-index`”
  1. Teach git-diff{,-files} the new option `--no-index`Johannes Schindelin, Feb 20, 2007
  2. Junio C HamanoFeb 22, 2007
  3. Johannes SchindelinFeb 22, 2007
  4. Junio C HamanoFeb 22, 2007
  5. Johannes SchindelinFeb 22, 2007
  6. run_diff_files(): add option to prevent --no-indexJohannes Schindelin, Feb 22, 2007
  7. Junio C HamanoFeb 22, 2007
  8. Johannes SchindelinFeb 22, 2007
  9. Junio C HamanoFeb 22, 2007
  10. Johannes SchindelinFeb 22, 2007
  11. Teach git-diff-files the new option `--no-index`Johannes Schindelin, Feb 22, 2007
  12. Junio C HamanoFeb 23, 2007
  13. Johannes SchindelinFeb 23, 2007

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.