summaryrefslogtreecommitdiff
path: root/builtin-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-02-27 11:55:28 -0800
committerJunio C Hamano <gitster@pobox.com>2008-02-27 11:55:28 -0800
commit860cc3a4f9c3ac21fcd37bbe30f40ab073f01299 (patch)
tree72954a742c39d14c6cc44e5524b215abab4dc7bd /builtin-diff.c
parentb82b096b8c3a29ad5115483cc8e8a433e26703ee (diff)
parentc0cb4a067972700f0682fbab13768bcc7dc7a3c3 (diff)
downloadgit-860cc3a4f9c3ac21fcd37bbe30f40ab073f01299.tar.gz
Merge branch 'jc/diff-relative'
* jc/diff-relative: diff --relative: help working in a bare repository diff --relative: output paths as relative to the current subdirectory
Diffstat (limited to 'builtin-diff.c')
-rw-r--r--builtin-diff.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/builtin-diff.c b/builtin-diff.c
index 8f53f52dcb..444ff2fd92 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -44,12 +44,17 @@ static void stuff_change(struct diff_options *opt,
tmp_u = old_sha1; old_sha1 = new_sha1; new_sha1 = tmp_u;
tmp_c = old_name; old_name = new_name; new_name = tmp_c;
}
+
+ if (opt->prefix &&
+ (strncmp(old_name, opt->prefix, opt->prefix_length) ||
+ strncmp(new_name, opt->prefix, opt->prefix_length)))
+ return;
+
one = alloc_filespec(old_name);
two = alloc_filespec(new_name);
fill_filespec(one, old_sha1, old_mode);
fill_filespec(two, new_sha1, new_mode);
- /* NEEDSWORK: shouldn't this part of diffopt??? */
diff_queue(&diff_queued_diff, one, two);
}
@@ -246,6 +251,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
if (diff_setup_done(&rev.diffopt) < 0)
die("diff_setup_done failed");
}
+ if (rev.diffopt.prefix && nongit) {
+ rev.diffopt.prefix = NULL;
+ rev.diffopt.prefix_length = 0;
+ }
DIFF_OPT_SET(&rev.diffopt, ALLOW_EXTERNAL);
DIFF_OPT_SET(&rev.diffopt, RECURSIVE);