summaryrefslogtreecommitdiff
path: root/diff-files.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2005-08-16 18:06:34 -0700
committerJunio C Hamano <junkio@cox.net>2005-08-16 18:47:22 -0700
commitd288a70030eaa5c205a72b4548635e17f8e523c0 (patch)
treee446e859256bd90a9eefd1cb2406707ea5b9d555 /diff-files.c
parent83db04ff878f40146952ee5d3d2d113568455f5b (diff)
downloadgit-d288a70030eaa5c205a72b4548635e17f8e523c0.tar.gz
[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-files.c')
-rw-r--r--diff-files.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/diff-files.c b/diff-files.c
index 2e6416e386..89eb29b3e2 100644
--- a/diff-files.c
+++ b/diff-files.c
@@ -41,12 +41,12 @@ static void show_modified(int oldmode, int mode,
diff_change(oldmode, mode, old_sha1, sha1, path, NULL);
}
-int main(int argc, const char **argv)
+int main(int argc, char **argv)
{
static const unsigned char null_sha1[20] = { 0, };
const char **pathspec;
- int entries = read_cache();
- int i;
+ const char *prefix = setup_git_directory();
+ int entries, i;
while (1 < argc && argv[1][0] == '-') {
if (!strcmp(argv[1], "-p") || !strcmp(argv[1], "-u"))
@@ -95,8 +95,9 @@ int main(int argc, const char **argv)
argv++; argc--;
}
- /* Do we have a pathspec? */
- pathspec = (argc > 1) ? argv + 1 : NULL;
+ /* Find the directory, and set up the pathspec */
+ pathspec = get_pathspec(prefix, argv + 1);
+ entries = read_cache();
if (find_copies_harder && detect_rename != DIFF_DETECT_COPY)
usage(diff_files_usage);