"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
patch.c: pass the callbacks data instead of hardcoding NULLs
To:
gameoftrees@openbsd.org
Date:
Tue, 08 Mar 2022 14:08:42 +0100

Download raw body.

Thread
Hello,

This fixes another bit of sloppiness of my initial diff.  Instead of
propagating the callbacks arguments from got.c i just hardcoded NULL;
let's get rid of them.

OK?

P.S. i'd like to get rid of the printf marked with XXX too in a future
diff; after this i have another diff queued.

commit 26e64c7024dcd10f62d2dc54a0b0f628c53c09de
from: Omar Polo <op@omarpolo.com>
date: Tue Mar  8 12:59:23 2022 UTC
 
 pass the callback data instead of hardcoding NULL
 
diff f69a1b4827a2ffcff36a4f54310ea5bd714951fb b8cf2be7da9c9f452f20fe79af92916a05abf904
blob - 3e66e251220b096cd82830703d4481ddfc399307
blob + 5939e9366900091eb56fe2aa3cdbe21f4f7a63eb
--- got/got.c
+++ got/got.c
@@ -7220,7 +7220,7 @@ cmd_patch(int argc, char *argv[])
 #endif
 
 	error = got_patch(patchfd, worktree, repo, &print_remove_status,
-	    &add_progress);
+	    NULL, &add_progress, NULL);
 
 done:
 	if (repo) {
blob - 3f56d45c54c3ff202d4e7db59288e3ec6717ed78
blob + 04a23fc7f7da83078d23e8ec24820ce98aa43702
--- include/got_patch.h
+++ include/got_patch.h
@@ -22,4 +22,4 @@
  */
 const struct got_error *
 got_patch(int, struct got_worktree *, struct got_repository *,
-    got_worktree_delete_cb, got_worktree_checkout_cb);
+    got_worktree_delete_cb, void *, got_worktree_checkout_cb, void *);
blob - 672f8dac069d4fdcde1088037bbf462287cd0264
blob + 9bfe37463cbe64005617a3395ea55e551360f8d1
--- lib/patch.c
+++ lib/patch.c
@@ -377,8 +377,8 @@ apply_hunk(FILE *tmp, struct got_patch_hunk *h, long *
 
 static const struct got_error *
 apply_patch(struct got_worktree *worktree, struct got_repository *repo,
-    struct got_patch *p, got_worktree_delete_cb delete_cb,
-    got_worktree_checkout_cb add_cb)
+    struct got_patch *p, got_worktree_delete_cb delete_cb, void *delete_arg,
+    got_worktree_checkout_cb add_cb, void *add_arg)
 {
 	const struct got_error *err = NULL;
 	struct got_pathlist_head paths;
@@ -412,7 +412,7 @@ apply_patch(struct got_worktree *worktree, struct got_
 		 * the lines but just schedule the removal.
 		 */
 		err = got_worktree_schedule_delete(worktree, &paths,
-		    0, NULL, delete_cb, NULL, repo, 0, 0);
+		    0, NULL, delete_cb, delete_arg, repo, 0, 0);
 		goto done;
 	} else if (p->old != NULL && strcmp(p->old, p->new)) {
 		err = got_error(GOT_ERR_PATCH_PATHS_DIFFER);
@@ -510,7 +510,7 @@ rename:
 
 	if (p->old == NULL)
 		err = got_worktree_schedule_add(worktree, &paths,
-		    add_cb, NULL, repo, 1);
+		    add_cb, add_arg, repo, 1);
 	else
 		printf("M  %s\n", path); /* XXX */
 done:
@@ -535,7 +535,8 @@ done:
 
 const struct got_error *
 got_patch(int fd, struct got_worktree *worktree, struct got_repository *repo,
-    got_worktree_delete_cb delete_cb, got_worktree_checkout_cb add_cb)
+    got_worktree_delete_cb delete_cb, void *delete_arg,
+    got_worktree_checkout_cb add_cb, void *add_arg)
 {
 	const struct got_error *err = NULL;
 	struct imsgbuf *ibuf;
@@ -583,7 +584,8 @@ got_patch(int fd, struct got_worktree *worktree, struc
 		if (err || done)
 			break;
 
-		err = apply_patch(worktree, repo, &p, delete_cb, add_cb);
+		err = apply_patch(worktree, repo, &p, delete_cb, delete_arg,
+		    add_cb, add_arg);
 		patch_free(&p);
 		if (err)
 			break;