@@ -173,8 +173,10 @@ void diff_no_index(struct rev_info *revs,
173173
174174 /* Were we asked to do --no-index explicitly? */
175175 for (i = 1 ; i < argc ; i ++ ) {
176- if (!strcmp (argv [i ], "--" ))
177- return ;
176+ if (!strcmp (argv [i ], "--" )) {
177+ i ++ ;
178+ break ;
179+ }
178180 if (!strcmp (argv [i ], "--no-index" ))
179181 no_index = 1 ;
180182 if (argv [i ][0 ] != '-' )
@@ -198,22 +200,19 @@ void diff_no_index(struct rev_info *revs,
198200 die ("git diff %s takes two paths" ,
199201 no_index ? "--no-index" : "[--no-index]" );
200202
201- /*
202- * If the user asked for our exit code then don't start a
203- * pager or we would end up reporting its exit code instead.
204- */
205- if (!DIFF_OPT_TST (& revs -> diffopt , EXIT_WITH_STATUS ))
206- setup_pager ();
207-
208203 diff_setup (& revs -> diffopt );
209204 if (!revs -> diffopt .output_format )
210205 revs -> diffopt .output_format = DIFF_FORMAT_PATCH ;
211206 for (i = 1 ; i < argc - 2 ; ) {
212207 int j ;
213208 if (!strcmp (argv [i ], "--no-index" ))
214209 i ++ ;
215- else if (!strcmp (argv [1 ], "-q" ))
210+ else if (!strcmp (argv [i ], "-q" )) {
216211 options |= DIFF_SILENT_ON_REMOVED ;
212+ i ++ ;
213+ }
214+ else if (!strcmp (argv [i ], "--" ))
215+ i ++ ;
217216 else {
218217 j = diff_opt_parse (& revs -> diffopt , argv + i , argc - i );
219218 if (!j )
@@ -222,6 +221,13 @@ void diff_no_index(struct rev_info *revs,
222221 }
223222 }
224223
224+ /*
225+ * If the user asked for our exit code then don't start a
226+ * pager or we would end up reporting its exit code instead.
227+ */
228+ if (!DIFF_OPT_TST (& revs -> diffopt , EXIT_WITH_STATUS ))
229+ setup_pager ();
230+
225231 if (prefix ) {
226232 int len = strlen (prefix );
227233
0 commit comments