summaryrefslogtreecommitdiff
path: root/diff-lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/diff-lib.c b/diff-lib.c
index e5a58c9..ca085a0 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -117,6 +117,10 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
if (!ce_path_match(istate, ce, &revs->prune_data, NULL))
continue;
+ if (revs->diffopt.prefix &&
+ strncmp(ce->name, revs->diffopt.prefix, revs->diffopt.prefix_length))
+ continue;
+
if (ce_stage(ce)) {
struct combine_diff_path *dpath;
struct diff_filepair *pair;
@@ -232,7 +236,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
ce_intent_to_add(ce)) {
newmode = ce_mode_from_stat(ce, st.st_mode);
diff_addremove(&revs->diffopt, '+', newmode,
- &null_oid, 0, ce->name, 0);
+ null_oid(), 0, ce->name, 0);
continue;
}
@@ -249,7 +253,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
}
oldmode = ce->ce_mode;
old_oid = &ce->oid;
- new_oid = changed ? &null_oid : &ce->oid;
+ new_oid = changed ? null_oid() : &ce->oid;
diff_change(&revs->diffopt, oldmode, newmode,
old_oid, new_oid,
!is_null_oid(old_oid),
@@ -307,7 +311,7 @@ static int get_stat_data(const struct index_state *istate,
0, dirty_submodule);
if (changed) {
mode = ce_mode_from_stat(ce, st.st_mode);
- oid = &null_oid;
+ oid = null_oid();
}
}
@@ -325,6 +329,11 @@ static void show_new_file(struct rev_info *revs,
unsigned dirty_submodule = 0;
struct index_state *istate = revs->diffopt.repo->index;
+ if (new_file && S_ISSPARSEDIR(new_file->ce_mode)) {
+ diff_tree_oid(NULL, &new_file->oid, new_file->name, &revs->diffopt);
+ return;
+ }
+
/*
* New file in the index: it might actually be different in
* the working tree.
@@ -347,6 +356,20 @@ static int show_modified(struct rev_info *revs,
unsigned dirty_submodule = 0;
struct index_state *istate = revs->diffopt.repo->index;
+ assert(S_ISSPARSEDIR(old_entry->ce_mode) ==
+ S_ISSPARSEDIR(new_entry->ce_mode));
+
+ /*
+ * If both are sparse directory entries, then expand the
+ * modifications to the file level. If only one was a sparse
+ * directory, then they appear as an add and delete instead of
+ * a modification.
+ */
+ if (S_ISSPARSEDIR(new_entry->ce_mode)) {
+ diff_tree_oid(&old_entry->oid, &new_entry->oid, new_entry->name, &revs->diffopt);
+ return 0;
+ }
+
if (get_stat_data(istate, new_entry, &oid, &mode, cached, match_missing,
&dirty_submodule, &revs->diffopt) < 0) {
if (report_missing)