- if (entries < 0) {
- perror("read_cache");
- exit(1);
- }
-
- diff_setup(reverse_diff);
-
- for (i = 0; i < entries; i++) {
- struct stat st;
- unsigned int oldmode, mode;
- struct cache_entry *ce = active_cache[i];
- int changed;
-
- if (ce_stage(ce)) {
- show_unmerge(ce->name);
- while (i < entries &&
- !strcmp(ce->name, active_cache[i]->name))
- i++;
- i--; /* compensate for loop control increments */
- continue;
- }
-
- if (lstat(ce->name, &st) < 0) {
- if (errno != ENOENT && errno != ENOTDIR) {
- perror(ce->name);
- continue;
- }
- if (silent)
- continue;
- show_file('-', ce);
- continue;
- }
- changed = ce_match_stat(ce, &st);
- if (!changed && detect_rename < DIFF_DETECT_COPY)
- continue;
-
- oldmode = ntohl(ce->ce_mode);
- mode = (S_ISLNK(st.st_mode) ? S_IFLNK :
- S_IFREG | ce_permissions(st.st_mode));
-
- show_modified(oldmode, mode, ce->sha1, null_sha1,
- ce->name);
- }
- if (detect_rename)
- diffcore_rename(detect_rename, diff_score_opt);
- diffcore_prune();
- if (pickaxe)
- diffcore_pickaxe(pickaxe);
- if (1 < argc)
- diffcore_pathspec(argv + 1);
- diff_flush(diff_output_format, 1);
- return 0;
+ if (rev.pending_objects ||
+ rev.min_age != -1 || rev.max_age != -1)
+ usage(diff_files_usage);
+ /*
+ * Backward compatibility wart - "diff-files -s" used to
+ * defeat the common diff option "-s" which asked for
+ * DIFF_FORMAT_NO_OUTPUT.
+ */
+ if (rev.diffopt.output_format == DIFF_FORMAT_NO_OUTPUT)
+ rev.diffopt.output_format = DIFF_FORMAT_RAW;
+ return run_diff_files(&rev, silent);