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

Skip to content

Dirty submodules do not correctly appear in diffs #1684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/diff_patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "diff_driver.h"
#include "diff_patch.h"
#include "diff_xdiff.h"
#include "fileops.h"

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

/* if we were previously missing an oid, update MODIFIED->UNMODIFIED */
/* if previously missing an oid, and now that we have it the two sides
* are the same (and not submodules), update MODIFIED -> UNMODIFIED
*/
if (incomplete_data &&
patch->ofile.file->mode == patch->nfile.file->mode &&
patch->ofile.file->mode != GIT_FILEMODE_COMMIT &&
git_oid_equal(&patch->ofile.file->oid, &patch->nfile.file->oid) &&
patch->delta->status == GIT_DELTA_MODIFIED) /* not RENAMED/COPIED! */
patch->delta->status = GIT_DELTA_UNMODIFIED;
Expand Down
4 changes: 3 additions & 1 deletion tests-clar/diff/submodules.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ static void check_diff_patches(git_diff_list *diff, const char **expected)
for (d = 0; d < num_d; ++d, git_diff_patch_free(patch)) {
cl_git_pass(git_diff_get_patch(&patch, &delta, diff, d));

if (delta->status == GIT_DELTA_UNMODIFIED)
if (delta->status == GIT_DELTA_UNMODIFIED) {
cl_assert(expected[d] == NULL);
continue;
}

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