mirror of
https://github.com/haiwen/seafile.git
synced 2025-01-08 11:57:44 +08:00
Don't create commit from index and don't write duplicate name cache t… (#2614)
* Don't create commit from index and don't write duplicate name cache to index * Modify name to prev_name Co-authored-by: heran yang <heran.yang@seafile.com>
This commit is contained in:
parent
187800c185
commit
7ae2d29b3d
@ -1974,6 +1974,7 @@ int write_index(struct index_state *istate, int newfd)
|
||||
struct cache_entry **cache = istate->cache;
|
||||
int entries = istate->cache_nr;
|
||||
SeafStat st;
|
||||
const char *prev_name;
|
||||
int ret = 0;
|
||||
|
||||
memset (&info, 0, sizeof(info));
|
||||
@ -2005,6 +2006,11 @@ int write_index(struct index_state *istate, int newfd)
|
||||
struct cache_entry *ce = cache[i];
|
||||
if (ce->ce_flags & CE_REMOVE)
|
||||
continue;
|
||||
// skip duplicate cache.
|
||||
if (prev_name && g_strcmp0 (ce->name, prev_name) ==0) {
|
||||
continue;
|
||||
}
|
||||
prev_name = ce->name;
|
||||
/* if (!ce_uptodate(ce) && is_racy_timestamp(istate, ce)) */
|
||||
/* ce_smudge_racily_clean_entry(ce); */
|
||||
if (ce_write_entry2(&info, newfd, ce) < 0) {
|
||||
|
@ -4165,30 +4165,12 @@ seaf_repo_index_commit (SeafRepo *repo,
|
||||
if (!istate.cache_changed)
|
||||
goto out;
|
||||
|
||||
if (!is_initial_commit && !is_force_commit) {
|
||||
new_root_id = commit_tree_from_changeset (changeset);
|
||||
if (!new_root_id) {
|
||||
seaf_warning ("Create commit tree failed for repo %s\n", repo->id);
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||
"Failed to generate commit");
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
char hex[41];
|
||||
struct cache_tree *it = cache_tree ();
|
||||
if (cache_tree_update (repo->id, repo->version,
|
||||
repo->worktree,
|
||||
it, istate.cache,
|
||||
istate.cache_nr, 0, 0, commit_trees_cb) < 0) {
|
||||
seaf_warning ("Failed to build cache tree");
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_INTERNAL,
|
||||
"Internal data structure error");
|
||||
cache_tree_free (&it);
|
||||
goto out;
|
||||
}
|
||||
rawdata_to_hex (it->sha1, hex, 20);
|
||||
new_root_id = g_strdup(hex);
|
||||
cache_tree_free (&it);
|
||||
new_root_id = commit_tree_from_changeset (changeset);
|
||||
if (!new_root_id) {
|
||||
seaf_warning ("Create commit tree failed for repo %s\n", repo->id);
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||
"Failed to generate commit");
|
||||
goto out;
|
||||
}
|
||||
|
||||
head = seaf_commit_manager_get_commit (seaf->commit_mgr,
|
||||
|
Loading…
Reference in New Issue
Block a user