Commit Diff


commit - d70b8e30048dfb40e323d6998034d9033152a0f7
commit + d7b62c98bea6955d39e6c792a38961da070c0da8
blob - 1041ba9f746d2e50dbc3151ae17cbe88466e5719
blob + b873e79cc3da19bd57a91eab724157a33e7ff7d7
--- got/got.c
+++ got/got.c
@@ -178,14 +178,14 @@ usage_checkout(void)
 }
 
 static void
-checkout_progress(void *arg, const char *path)
+checkout_progress(void *arg, char status, const char *path)
 {
 	char *worktree_path = arg;
 
 	while (path[0] == '/')
 		path++;
 
-	printf("A  %s/%s\n", worktree_path, path);
+	printf("%c  %s/%s\n", status, worktree_path, path);
 }
 
 static const struct got_error *
blob - 06af45d140806cd9cccbab4aa32668e5689f53cf
blob + 3d89816d3b79f1c29be0b67f8881627e9705a5c6
--- include/got_worktree.h
+++ include/got_worktree.h
@@ -49,7 +49,7 @@ char *got_worktree_get_repo_path(struct got_worktree *
 char  *got_worktree_get_head_ref_name(struct got_worktree *);
 
 /* A callback function which is invoked when a path is checked out. */
-typedef void (*got_worktree_checkout_cb)(void *, const char *);
+typedef void (*got_worktree_checkout_cb)(void *, char, const char *);
 
 /* A callback function which is invoked at cancellation points.
  * May return GOT_ERR_CANCELLED to abort the runing operation. */
blob - 70d2944f783fc2d8612eab23dfb9e6774ce204ac
blob + 4579ebe2bced0be65b47adb6f0011bf7a564283f
--- lib/worktree.c
+++ lib/worktree.c
@@ -403,7 +403,9 @@ apply_path_prefix(struct got_worktree *worktree, const
 
 static const struct got_error *
 add_file_on_disk(struct got_worktree *worktree, struct got_fileindex *fileindex,
-   const char *path, struct got_blob_object *blob, struct got_repository *repo)
+   const char *path, struct got_blob_object *blob, struct got_repository *repo,
+   got_worktree_checkout_cb progress_cb, void *progress_arg,
+   const char *progress_path)
 {
 	const struct got_error *err = NULL;
 	char *ondisk_path;
@@ -428,12 +430,16 @@ add_file_on_disk(struct got_worktree *worktree, struct
 				err = got_error(GOT_ERR_FILE_OBSTRUCTED);
 			} else {
 				/* TODO: Merge the file! */
+				(*progress_cb)(progress_arg, 'E',
+				    progress_path);
 				return NULL;
 			}
 		}
 		return err;
 	}
 
+	(*progress_cb)(progress_arg, 'A', progress_path);
+
 	hdrlen = got_object_blob_get_hdrlen(blob);
 	do {
 		const uint8_t *buf = got_object_blob_get_read_buf(blob);
@@ -552,7 +558,6 @@ tree_checkout_entry(struct got_worktree *worktree,
 	progress_path = path;
 	if (strncmp(progress_path, worktree->path_prefix, len) == 0)
 		progress_path += len;
-	(*progress_cb)(progress_arg, progress_path);
 
 	switch (obj->type) {
 	case GOT_OBJ_TYPE_BLOB:
@@ -561,7 +566,8 @@ tree_checkout_entry(struct got_worktree *worktree,
 		err = got_object_blob_open(&blob, repo, obj, 8192);
 		if (err)
 			goto done;
-		err = add_file_on_disk(worktree, fileindex, path, blob, repo);
+		err = add_file_on_disk(worktree, fileindex, path, blob, repo,
+		    progress_cb, progress_arg, progress_path);
 		break;
 	case GOT_OBJ_TYPE_TREE:
 		err = got_object_tree_open(&tree, repo, obj);
blob - 97409738a5031f53ff0820057c3f280dde8010e6
blob + 61265ac973108c2b312070aa06ca414559e8f8da
--- regress/worktree/worktree_test.c
+++ regress/worktree/worktree_test.c
@@ -305,7 +305,7 @@ done:
 }
 
 static void
-process_cb(void *arg, const char *path)
+progress_cb(void *arg, char status, const char *path)
 {
 }
 
@@ -341,7 +341,7 @@ worktree_checkout(const char *repo_path)
 	if (err != NULL)
 		goto done;
 
-	err = got_worktree_checkout_files(worktree, repo, process_cb, NULL,
+	err = got_worktree_checkout_files(worktree, repo, progress_cb, NULL,
 	    NULL, NULL);
 	if (err != NULL)
 		goto done;