Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c8a39f9

Browse files
committed
Merge pull request libgit2#1684 from libgit2/fix-dirty-submodule-diff
Dirty submodules do not correctly appear in diffs
2 parents b0401c6 + c67ff95 commit c8a39f9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/diff_patch.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "diff_driver.h"
1111
#include "diff_patch.h"
1212
#include "diff_xdiff.h"
13+
#include "fileops.h"
1314

1415
/* cached information about a single span in a diff */
1516
typedef struct diff_patch_line diff_patch_line;
@@ -175,9 +176,12 @@ static int diff_patch_load(git_diff_patch *patch, git_diff_output *output)
175176
goto cleanup;
176177
}
177178

178-
/* if we were previously missing an oid, update MODIFIED->UNMODIFIED */
179+
/* if previously missing an oid, and now that we have it the two sides
180+
* are the same (and not submodules), update MODIFIED -> UNMODIFIED
181+
*/
179182
if (incomplete_data &&
180183
patch->ofile.file->mode == patch->nfile.file->mode &&
184+
patch->ofile.file->mode != GIT_FILEMODE_COMMIT &&
181185
git_oid_equal(&patch->ofile.file->oid, &patch->nfile.file->oid) &&
182186
patch->delta->status == GIT_DELTA_MODIFIED) /* not RENAMED/COPIED! */
183187
patch->delta->status = GIT_DELTA_UNMODIFIED;

tests-clar/diff/submodules.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ static void check_diff_patches(git_diff_list *diff, const char **expected)
4747
for (d = 0; d < num_d; ++d, git_diff_patch_free(patch)) {
4848
cl_git_pass(git_diff_get_patch(&patch, &delta, diff, d));
4949

50-
if (delta->status == GIT_DELTA_UNMODIFIED)
50+
if (delta->status == GIT_DELTA_UNMODIFIED) {
51+
cl_assert(expected[d] == NULL);
5152
continue;
53+
}
5254

5355
if (expected[d] && !strcmp(expected[d], "<SKIP>"))
5456
continue;

0 commit comments

Comments
 (0)