diff options
author | Linus Torvalds <torvalds@osdl.org> | 2005-08-17 03:06:34 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2005-08-17 03:47:22 +0200 |
commit | d288a70030eaa5c205a72b4548635e17f8e523c0 (patch) | |
tree | e446e859256bd90a9eefd1cb2406707ea5b9d555 /diff-cache.c | |
parent | [PATCH] Add a bit more links to the commands to the main git(7) page. (diff) | |
download | git-d288a70030eaa5c205a72b4548635e17f8e523c0.tar.xz git-d288a70030eaa5c205a72b4548635e17f8e523c0.zip |
[PATCH] Make "git diff" work inside relative subdirectories
We always show the diff as an absolute path, but pathnames to diff are
taken relative to the current working directory (and if no pathnames are
given, the default ends up being all of the current working directory).
Note that "../xyz" also works, so you can do
cd linux/drivers/char
git diff ../block
and it will generate a diff of the linux/drivers/block changes.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff-cache.c')
-rw-r--r-- | diff-cache.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/diff-cache.c b/diff-cache.c index 47a4e09ecc..400a4cb2ad 100644 --- a/diff-cache.c +++ b/diff-cache.c @@ -168,10 +168,11 @@ static const char diff_cache_usage[] = "[<common diff options>] <tree-ish> [<path>...]" COMMON_DIFF_OPTIONS_HELP; -int main(int argc, const char **argv) +int main(int argc, char **argv) { const char *tree_name = NULL; unsigned char sha1[20]; + const char *prefix = setup_git_directory(); const char **pathspec = NULL; void *tree; unsigned long size; @@ -179,15 +180,12 @@ int main(int argc, const char **argv) int allow_options = 1; int i; - read_cache(); for (i = 1; i < argc; i++) { const char *arg = argv[i]; if (!allow_options || *arg != '-') { - if (tree_name) { - pathspec = argv + i; + if (tree_name) break; - } tree_name = arg; continue; } @@ -265,12 +263,16 @@ int main(int argc, const char **argv) usage(diff_cache_usage); } + pathspec = get_pathspec(prefix, argv + i); + if (find_copies_harder && detect_rename != DIFF_DETECT_COPY) usage(diff_cache_usage); if (!tree_name || get_sha1(tree_name, sha1)) usage(diff_cache_usage); + read_cache(); + /* The rest is for paths restriction. */ diff_setup(diff_setup_opt); |