diff options
Diffstat (limited to 'builtin/diff.c')
| -rw-r--r-- | builtin/diff.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/builtin/diff.c b/builtin/diff.c index fa963808c3..0b23c41456 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -35,7 +35,7 @@ static const char builtin_diff_usage[] = " or: git diff [<options>] [--merge-base] <commit> [<commit>...] <commit> [--] [<path>...]\n" " or: git diff [<options>] <commit>...<commit> [--] [<path>...]\n" " or: git diff [<options>] <blob> <blob>\n" -" or: git diff [<options>] --no-index [--] <path> <path>" +" or: git diff [<options>] --no-index [--] <path> <path> [<pathspec>...]" "\n" COMMON_DIFF_OPTIONS_HELP; @@ -483,10 +483,25 @@ int cmd_diff(int argc, * configurable via a command line option. */ if (nongit) - repo_set_hash_algo(the_repository, GIT_HASH_SHA1); + repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT); init_diff_ui_defaults(); - git_config(git_diff_ui_config, NULL); + repo_config(the_repository, git_diff_ui_config, NULL); + + /* + * If we are ignoring the fact that our current directory may + * be part of a working tree controlled by a Git repository to + * pretend to be a "better GNU diff", we should undo the + * effect of the setup code that did a chdir() to the top of + * the working tree. Where we came from is recorded in the + * prefix. + */ + if (no_index && prefix) { + if (chdir(prefix)) + die(_("cannot come back to cwd")); + prefix = NULL; + } + prefix = precompose_argv_prefix(argc, argv, prefix); repo_init_revisions(the_repository, &rev, prefix); |
