Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-06-30 00:20:45 +0400
committerRussell Belfer <rb@github.com>2013-07-10 23:14:13 +0400
commit2e3e273e33894bc1089cfc09d89bd2cb144b108d (patch)
tree832f6867648828164eae1bf3beb42cde4da88943 /src/diff.c
parent1aad6137d218830bc280c4327595182019164515 (diff)
Update diff to new internal submodule status API
Submodules now expose an internal status API that allows diff to get back the OID values from the submodule very easily and also to avoiding caching issues and to override the ignore setting for the submodule.
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/diff.c b/src/diff.c
index cc7be451f..2b018188e 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -13,6 +13,7 @@
#include "pathspec.h"
#include "index.h"
#include "odb.h"
+#include "submodule.h"
#define DIFF_FLAG_IS_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) != 0)
#define DIFF_FLAG_ISNT_SET(DIFF,FLAG) (((DIFF)->opts.flags & (FLAG)) == 0)
@@ -595,7 +596,6 @@ static int maybe_modified_submodule(
int error = 0;
git_submodule *sub;
unsigned int sm_status = 0;
- const git_oid *sm_oid;
*status = GIT_DELTA_UNMODIFIED;
@@ -603,7 +603,9 @@ static int maybe_modified_submodule(
!(error = git_submodule_lookup(
&sub, diff->repo, info->nitem->path)) &&
git_submodule_ignore(sub) != GIT_SUBMODULE_IGNORE_ALL &&
- !(error = git_submodule_status(&sm_status, sub)))
+ !(error = git_submodule__status(
+ &sm_status, NULL, NULL, found_oid, sub,
+ GIT_SUBMODULE_IGNORE_DEFAULT)))
{
/* check IS_WD_UNMODIFIED because this case is only used
* when the new side of the diff is the working directory
@@ -611,10 +613,10 @@ static int maybe_modified_submodule(
if (!GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED(sm_status))
*status = GIT_DELTA_MODIFIED;
- /* grab OID while we are here */
- if (git_oid_iszero(&info->nitem->oid) &&
- (sm_oid = git_submodule_wd_id(sub)) != NULL)
- git_oid_cpy(found_oid, sm_oid);
+ /* now that we have a HEAD OID, check if HEAD moved */
+ if ((sm_status & GIT_SUBMODULE_STATUS_IN_WD) != 0 &&
+ !git_oid_equal(&info->oitem->oid, found_oid))
+ *status = GIT_DELTA_MODIFIED;
}
/* GIT_EEXISTS means a dir with .git in it was found - ignore it */