diff options
| author | Vicent Martà <vicent@github.com> | 2013-04-09 15:15:18 -0700 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2013-04-09 15:15:18 -0700 |
| commit | e9b7ff602b7f4b9a7de92eb241bc0578a520dda2 (patch) | |
| tree | ad5caff8bd3574a31040beaf1739f3ba3b6c8d9e /src | |
| parent | fc12a6b545e26e673640288418202ac802a82a3f (diff) | |
| parent | ad26434b3b8a5eafab8ec52b83aa99beaf48fb03 (diff) | |
| download | libgit2-e9b7ff602b7f4b9a7de92eb241bc0578a520dda2.tar.gz | |
Merge pull request #1460 from arrbee/fix-dirty-submodules-diff
Submodule diff tests and fixes
Diffstat (limited to 'src')
| -rw-r--r-- | src/date.c | 4 | ||||
| -rw-r--r-- | src/diff.c | 6 | ||||
| -rw-r--r-- | src/diff_output.c | 12 |
3 files changed, 17 insertions, 5 deletions
diff --git a/src/date.c b/src/date.c index bbf88eb44..ce1721a0b 100644 --- a/src/date.c +++ b/src/date.c @@ -681,8 +681,8 @@ static const char *approxidate_alpha(const char *date, struct tm *tm, struct tm const char *end = date; int i; - while (isalpha(*++end)); - ; + while (isalpha(*++end)) + /* scan to non-alpha */; for (i = 0; i < 12; i++) { size_t match = match_string(date, month_names[i]); diff --git a/src/diff.c b/src/diff.c index 7152683e7..37c89f3f1 100644 --- a/src/diff.c +++ b/src/diff.c @@ -542,7 +542,11 @@ static int maybe_modified( unsigned int sm_status = 0; if (git_submodule_status(&sm_status, sub) < 0) return -1; - status = GIT_SUBMODULE_STATUS_IS_UNMODIFIED(sm_status) + + /* check IS_WD_UNMODIFIED because this case is only used + * when the new side of the diff is the working directory + */ + status = GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(sm_status) ? GIT_DELTA_UNMODIFIED : GIT_DELTA_MODIFIED; /* grab OID while we are here */ diff --git a/src/diff_output.c b/src/diff_output.c index e8dd5b317..34a3e506c 100644 --- a/src/diff_output.c +++ b/src/diff_output.c @@ -675,10 +675,14 @@ cleanup: if (!error) { patch->flags |= GIT_DIFF_PATCH_LOADED; + /* patch is diffable only for non-binary, modified files where at + * least one side has data and there is actual change in the data + */ if ((delta->flags & GIT_DIFF_FLAG_BINARY) == 0 && delta->status != GIT_DELTA_UNMODIFIED && (patch->old_data.len || patch->new_data.len) && - !git_oid_equal(&delta->old_file.oid, &delta->new_file.oid)) + (patch->old_data.len != patch->new_data.len || + !git_oid_equal(&delta->old_file.oid, &delta->new_file.oid))) patch->flags |= GIT_DIFF_PATCH_DIFFABLE; } @@ -1149,7 +1153,11 @@ static int print_patch_file( GIT_UNUSED(progress); - if (S_ISDIR(delta->new_file.mode)) + if (S_ISDIR(delta->new_file.mode) || + delta->status == GIT_DELTA_UNMODIFIED || + delta->status == GIT_DELTA_IGNORED || + (delta->status == GIT_DELTA_UNTRACKED && + (pi->diff->opts.flags & GIT_DIFF_INCLUDE_UNTRACKED_CONTENT) == 0)) return 0; if (!oldpfx) |
