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

[RFC PATCH] diff --no-index: test for pager after option parsing

From
Thomas Rast <trast@student.ethz.ch>
Date
Jan 6, 2009, 23:56 UTC
Message-ID
<1231286163-9422-1-git-send-email-trast@student.ethz.ch>

We need to parse options before we can see if --exit-code was provided.

Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

I noticed this while working on the earlier patch for diff --no-index. It seems like the right thing to do (and passes tests), but I don't have a clue about git's normal setup sequences, so I'm flagging it RFC.

 diff-no-index.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/diff-no-index.c b/diff-no-index.c
index b60d345..f655f64 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -198,13 +198,6 @@ void diff_no_index(struct rev_info *revs,
 		die("git diff %s takes two paths",
 		    no_index ? "--no-index" : "[--no-index]");
 
-	/*
-	 * If the user asked for our exit code then don't start a
-	 * pager or we would end up reporting its exit code instead.
-	 */
-	if (!DIFF_OPT_TST(&revs->diffopt, EXIT_WITH_STATUS))
-		setup_pager();
-
 	diff_setup(&revs->diffopt);
 	if (!revs->diffopt.output_format)
 		revs->diffopt.output_format = DIFF_FORMAT_PATCH;
@@ -222,6 +215,13 @@ void diff_no_index(struct rev_info *revs,
 		}
 	}
 
+	/*
+	 * If the user asked for our exit code then don't start a
+	 * pager or we would end up reporting its exit code instead.
+	 */
+	if (!DIFF_OPT_TST(&revs->diffopt, EXIT_WITH_STATUS))
+		setup_pager();
+
 	if (prefix) {
 		int len = strlen(prefix);
 
-- 
tg: (e9b8523..) t/diff-no-index-status (depends on: origin/master)
Next: Thomas Rast
Message 1 of 8 in “diff --no-index: test for pager after option parsing”
  1. diff --no-index: test for pager after option parsingThomas Rast, Jan 6, 2009
  2. Thomas RastJan 7, 2009
  3. Junio C HamanoJan 7, 2009
  4. Miklos VajnaJan 7, 2009
  5. Jeff KingJan 7, 2009
  6. Junio C HamanoJan 7, 2009
  7. diff --no-index -q: fix endless loopThomas Rast, Jan 7, 2009
  8. Junio C HamanoJan 7, 2009

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.