blob: 6ba5077a2be6619f110280622cf46a7f4cfb8b01 [file] [log] [blame]
Linus Torvalds8bc9a0c2005-04-07 15:16:10 -07001/*
2 * GIT - The information manager from hell
3 *
4 * Copyright (C) Linus Torvalds, 2005
5 */
Linus Torvaldse83c5162005-04-07 15:13:13 -07006#include "cache.h"
Junio C Hamano4a6bf9e2005-04-27 09:21:00 -07007#include "diff.h"
Linus Torvalds91539832006-04-17 11:59:32 -07008#include "commit.h"
9#include "revision.h"
Peter Eriksene8cc9cd2006-05-23 14:15:36 +020010#include "builtin.h"
Christopher Lic0fb9762005-04-12 02:04:44 -070011
Petr Baudis4d1f1192005-07-29 11:01:26 +020012static const char diff_files_usage[] =
Johannes Schindelind516c2d2007-02-22 21:50:10 +010013"git-diff-files [-q] [-0/-1/2/3 |-c|--cc|-n|--no-index] [<common diff options>] [<path>...]"
Junio C Hamanodda2d792005-07-13 12:52:35 -070014COMMON_DIFF_OPTIONS_HELP;
Junio C Hamanob8f80922005-04-16 21:29:45 -070015
Linus Torvaldsa633fca2006-07-28 22:44:25 -070016int cmd_diff_files(int argc, const char **argv, const char *prefix)
Linus Torvaldse83c5162005-04-07 15:13:13 -070017{
Junio C Hamano6973dca2006-04-21 23:57:45 -070018 struct rev_info rev;
Johannes Schindelind516c2d2007-02-22 21:50:10 +010019 int nongit = 0;
Alex Riesen41bbf9d2007-03-14 01:17:04 +010020 int result;
Linus Torvaldse83c5162005-04-07 15:13:13 -070021
Johannes Schindelind516c2d2007-02-22 21:50:10 +010022 prefix = setup_git_directory_gently(&nongit);
Linus Torvaldsa633fca2006-07-28 22:44:25 -070023 init_revisions(&rev, prefix);
Junio C Hamanoef1d9c52006-07-27 22:55:44 -070024 git_config(git_default_config); /* no "diff" UI options */
Junio C Hamano6973dca2006-04-21 23:57:45 -070025 rev.abbrev = 0;
26
Johannes Schindelinfcfa33e2007-02-25 23:35:27 +010027 if (!setup_diff_no_index(&rev, argc, argv, nongit, prefix))
28 argc = 0;
29 else
30 argc = setup_revisions(argc, argv, &rev, NULL);
Timo Hirvonenc9b5ef92006-06-24 20:24:14 +030031 if (!rev.diffopt.output_format)
32 rev.diffopt.output_format = DIFF_FORMAT_RAW;
Alex Riesen41bbf9d2007-03-14 01:17:04 +010033 result = run_diff_files_cmd(&rev, argc, argv);
34 return rev.diffopt.exit_with_status ? rev.diffopt.has_changes: result;
Linus Torvaldse83c5162005-04-07 15:13:13 -070035}