signal existing files in checkout progress output
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
diff --git a/got/got.c b/got/got.c
index 1041ba9..b873e79 100644
--- a/got/got.c
+++ b/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 *
diff --git a/include/got_worktree.h b/include/got_worktree.h
index 06af45d..3d89816 100644
--- a/include/got_worktree.h
+++ b/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. */
diff --git a/lib/worktree.c b/lib/worktree.c
index 70d2944..4579ebe 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -403,7 +403,9 @@ apply_path_prefix(struct got_worktree *worktree, const char *path)
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 got_fileindex *fileindex,
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);
diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index 9740973..61265ac 100644
--- a/regress/worktree/worktree_test.c
+++ b/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;