summaryrefslogtreecommitdiff
path: root/src/index.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-04-28 14:34:55 -0700
committerRussell Belfer <rb@github.com>2014-05-02 09:21:33 -0700
commit0fc8e1f6bd9a5148d3a262142e9a70126f5c3a42 (patch)
tree7941140dacf3a0b820363280ecdca2790cf5cdf3 /src/index.c
parent8ef4e11a76599111b98682d235e7a4df921b2597 (diff)
downloadlibgit2-0fc8e1f6bd9a5148d3a262142e9a70126f5c3a42.tar.gz
Lay groundwork for updating stat cache in diff
This reorganized the diff OID calculation to make it easier to correctly update the stat cache during a diff once the flags to do so are enabled. This includes marking the path of a git_index_entry as const so we can make a "fake" git_index_entry with a "const char *" path and not get warnings. I was a little surprised at how unobtrusive this change was, but I think it's probably a good thing.
Diffstat (limited to 'src/index.c')
-rw-r--r--src/index.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/index.c b/src/index.c
index c044af402..8a7f29279 100644
--- a/src/index.c
+++ b/src/index.c
@@ -842,7 +842,7 @@ static int index_entry_reuc_init(git_index_reuc_entry **reuc_out,
static void index_entry_cpy(git_index_entry *tgt, const git_index_entry *src)
{
- char *tgt_path = tgt->path;
+ const char *tgt_path = tgt->path;
memcpy(tgt, src, sizeof(*tgt));
tgt->path = tgt_path; /* reset to existing path data */
}
@@ -2282,9 +2282,7 @@ static int read_tree_cb(
entry->mode == old_entry->mode &&
git_oid_equal(&entry->id, &old_entry->id))
{
- char *oldpath = entry->path;
- memcpy(entry, old_entry, sizeof(*entry));
- entry->path = oldpath;
+ index_entry_cpy(entry, old_entry);
entry->flags_extended = 0;
}