aboutsummaryrefslogtreecommitdiffstats
path: root/diff-lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'diff-lib.c')
-rw-r--r--diff-lib.c29
1 files changed, 6 insertions, 23 deletions
diff --git a/diff-lib.c b/diff-lib.c
index 85b8f1fa59..471ef99614 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -153,7 +153,6 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
struct diff_filepair *pair;
unsigned int wt_mode = 0;
int num_compare_stages = 0;
- size_t path_len;
struct stat st;
changed = check_removed(ce, &st);
@@ -167,18 +166,8 @@ void run_diff_files(struct rev_info *revs, unsigned int option)
wt_mode = 0;
}
- path_len = ce_namelen(ce);
-
- dpath = xmalloc(combine_diff_path_size(5, path_len));
- dpath->path = (char *) &(dpath->parent[5]);
-
- dpath->next = NULL;
- memcpy(dpath->path, ce->name, path_len);
- dpath->path[path_len] = '\0';
- oidclr(&dpath->oid, the_repository->hash_algo);
- dpath->mode = wt_mode;
- memset(&(dpath->parent[0]), 0,
- sizeof(struct combine_diff_parent)*5);
+ dpath = combine_diff_path_new(ce->name, ce_namelen(ce),
+ wt_mode, null_oid(), 5);
while (i < entries) {
struct cache_entry *nce = istate->cache[i];
@@ -405,16 +394,10 @@ static int show_modified(struct rev_info *revs,
if (revs->combine_merges && !cached &&
(!oideq(oid, &old_entry->oid) || !oideq(&old_entry->oid, &new_entry->oid))) {
struct combine_diff_path *p;
- int pathlen = ce_namelen(new_entry);
-
- p = xmalloc(combine_diff_path_size(2, pathlen));
- p->path = (char *) &p->parent[2];
- p->next = NULL;
- memcpy(p->path, new_entry->name, pathlen);
- p->path[pathlen] = 0;
- p->mode = mode;
- oidclr(&p->oid, the_repository->hash_algo);
- memset(p->parent, 0, 2 * sizeof(struct combine_diff_parent));
+
+ p = combine_diff_path_new(new_entry->name,
+ ce_namelen(new_entry),
+ mode, null_oid(), 2);
p->parent[0].status = DIFF_STATUS_MODIFIED;
p->parent[0].mode = new_entry->ce_mode;
oidcpy(&p->parent[0].oid, &new_entry->oid);