diff: avoid some nesting

Avoid some nesting in builtin/diff.c, to make the code easier to read. There are no functional changes. Helped-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Thomas Gummerer committed Dec 16, 2013 at 21:19 UTC aad90e85f8e6368533aa30c072b8e2bd7adafa53
1 file changed +17 -18
builtin/diff.c
+17 -18
@@ -319,27 +319,26 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
319
320 init_revisions(&rev, prefix);
321
322 - if (no_index) {
323 - if (argc != i + 2) {
324 - if (no_index == DIFF_NO_INDEX_IMPLICIT) {
325 - /*
326 - * There was no --no-index and there were not two
327 - * paths. It is possible that the user intended
328 - * to do an inside-repository operation.
329 - */
330 - fprintf(stderr, "Not a git repository\n");
331 - fprintf(stderr,
332 - "To compare two paths outside a working tree:\n");
333 - }
334 - /* Give the usage message for non-repository usage and exit. */
335 - usagef("git diff %s <path> <path>",
336 - no_index == DIFF_NO_INDEX_EXPLICIT ?
337 - "--no-index" : "[--no-index]");
338 -
322 + if (no_index && argc != i + 2) {
323 + if (no_index == DIFF_NO_INDEX_IMPLICIT) {
324 + /*
325 + * There was no --no-index and there were not two
326 + * paths. It is possible that the user intended
327 + * to do an inside-repository operation.
328 + */
329 + fprintf(stderr, "Not a git repository\n");
330 + fprintf(stderr,
331 + "To compare two paths outside a working tree:\n");
332 }
333 + /* Give the usage message for non-repository usage and exit. */
334 + usagef("git diff %s <path> <path>",
335 + no_index == DIFF_NO_INDEX_EXPLICIT ?
336 + "--no-index" : "[--no-index]");
337 +
338 + }
339 + if (no_index)
340 /* If this is a no-index diff, just run it and exit there. */
341 diff_no_index(&rev, argc, argv, prefix);
342 - }
342
343 /* Otherwise, we are doing the usual "git" diff */
344 rev.diffopt.skip_stat_unmatch = !!diff_auto_refresh_index;