Commit Diff


commit - 831297da020634f03598418e375149da41098308
commit + 219482121213057d543880d13747cebe11895075
blob - a3ad82ba986e1bb5e246d67e517888bbe2ca5a83
blob + 3efdafd29862cdc59496aa5cf48bc7e5669c6ee7
--- lib/patch.c
+++ lib/patch.c
@@ -756,11 +756,12 @@ apply_patch(int *overlapcnt, struct got_worktree *work
 			return err;
 		else if (err == NULL)
 			do_merge = 1;
-		else if (reverse)
-			reverse_patch(p);
 		err = NULL;
 	}
 
+	if (reverse && !do_merge)
+		reverse_patch(p);
+
 	if (asprintf(&oldpath, "%s/%s", got_worktree_get_root_path(worktree),
 	    old) == -1) {
 		err = got_error_from_errno("asprintf");
@@ -1016,10 +1017,6 @@ got_patch(int fd, struct got_worktree *worktree, struc
 		if (err || done)
 			break;
 
-		/* reversal application with merge base is done differently */
-		if (reverse && *p.blob == '\0')
-			reverse_patch(&p);
-
 		err = got_worktree_patch_check_path(p.old, p.new, &oldpath,
 		    &newpath, worktree, repo, fileindex);
 		if (err == NULL)