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

Skip to content

Commit c67ff95

Browse files
committed
Fix bug marking submodule diffs as unmodified
There was a bug where submodules whose HEAD had not been moved were being marked as having an UNMODIFIED delta record instead of being left MODIFIED. This fixes that and fixes the tests to notice if a submodule has been incorrectly marked as UNMODIFIED.
1 parent c7974b4 commit c67ff95

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 && expected[d] == NULL)
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)