summaryrefslogtreecommitdiffstats
path: root/src/makepatch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/makepatch.c')
-rw-r--r--src/makepatch.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/makepatch.c b/src/makepatch.c
index 8bf1ee5..6e350f5 100644
--- a/src/makepatch.c
+++ b/src/makepatch.c
@@ -47,6 +47,8 @@ static int cb(DB *ddb, struct syrep_name *name, struct diff_entry *de, void *p)
if (de->action != DIFF_COPY && de->action != DIFF_CONFLICT)
return 0;
+ /* Check whether file exists in c1. If not, exit */
+
if ((f = get_nrecno_by_name(cb_info->c1, name, &nrecno, 0)) < 0)
return -1;
@@ -57,19 +59,33 @@ static int cb(DB *ddb, struct syrep_name *name, struct diff_entry *de, void *p)
if (!f)
return 0;
+ /* Omit if the file exists in c2 under a different name */
+
+ if (!args.include_all_flag) {
+
+ if ((f = get_current_nrecno_by_md(cb_info->c2, &md, NULL)) < 0)
+ return -1;
+
+ if (f)
+ return 0;
+ }
+
+ /* Ok, we add this file to the patch */
+
fhex(md.digest, SYREP_DIGESTLENGTH, d);
d[SYREP_DIGESTLENGTH*2] = 0;
snprintf(path, sizeof(path), "%s/%s", cb_info->root, name->path);
- fprintf(stderr, "Adding %s (%s) to patch.\n", name->path, d);
+ if (!package_get_item(cb_info->c1->package, d, 0)) {
- /*** MISSING: DO NOT ADD FILES ALREADY EXISTING BY MD5 ***/
-
- if (!package_get_item(cb_info->c1->package, d, 0))
+ fprintf(stderr, "Adding %s (%s) to patch.\n", name->path, d);
+
if (package_add_file(cb_info->c1->package, d, path) < 0)
return -1;
+ }
+
return 0;
}