commit - eb3df2c4aa176b3a0493d0656d2d093b4d4c7c9b
commit + 1ee397ad2d67e352b33dac85804e51ff3db9fc15
blob - 0261d5da76ebaa9841f1f8ccab91ff0f166ad3e9
blob + 0558151b8c74dfa9f172303d800a9d2f781724ca
--- got/got.c
+++ got/got.c
exit(1);
}
-static void
+static const struct got_error *
checkout_progress(void *arg, unsigned char status, const char *path)
{
char *worktree_path = arg;
/* Base commit bump happens silently. */
if (status == GOT_STATUS_BUMP_BASE)
- return;
+ return NULL;
while (path[0] == '/')
path++;
printf("%c %s/%s\n", status, worktree_path, path);
+ return NULL;
}
static const struct got_error *
exit(1);
}
-static void
+static const struct got_error *
update_progress(void *arg, unsigned char status, const char *path)
{
int *did_something = arg;
if (status == GOT_STATUS_EXISTS)
- return;
+ return NULL;
*did_something = 1;
/* Base commit bump happens silently. */
if (status == GOT_STATUS_BUMP_BASE)
- return;
+ return NULL;
while (path[0] == '/')
path++;
printf("%c %s\n", status, path);
+ return NULL;
}
static const struct got_error *
exit(1);
}
-static void
+static const struct got_error *
revert_progress(void *arg, unsigned char status, const char *path)
{
while (path[0] == '/')
path++;
printf("%c %s\n", status, path);
+ return NULL;
}
static const struct got_error *
return err;
}
-static void
+static const struct got_error *
rebase_progress(void *arg, unsigned char status, const char *path)
{
unsigned char *rebase_status = arg;
printf("%c %s\n", status, path);
if (*rebase_status == GOT_STATUS_CONFLICT)
- return;
+ return NULL;
if (status == GOT_STATUS_CONFLICT || status == GOT_STATUS_MERGE)
*rebase_status = status;
+ return NULL;
}
static const struct got_error *
blob - c61b327efec88778ab8c25f0964c86989d6075bb
blob + b0aaf621f9a8d691b1bfe54b820ab65b83ac1bf2
--- include/got_worktree.h
+++ include/got_worktree.h
struct got_repository *, struct got_object_id *);
/* A callback function which is invoked when a path is checked out. */
-typedef void (*got_worktree_checkout_cb)(void *, unsigned char, const char *);
+typedef const struct got_error *(*got_worktree_checkout_cb)(void *,
+ unsigned char, const char *);
/* A callback function which is invoked at cancellation points.
* May return GOT_ERR_CANCELLED to abort the runing operation. */
blob - 269d7bc470110479baf6a0f3edcea0d19310174e
blob + 373a13ee5d15c2f86b7a90a9b0b831d23dc261f2
--- lib/worktree.c
+++ lib/worktree.c
if (err)
goto done;
- (*progress_cb)(progress_arg,
+ err = (*progress_cb)(progress_arg,
overlapcnt > 0 ? GOT_STATUS_CONFLICT : GOT_STATUS_MERGE, path);
+ if (err)
+ goto done;
if (fsync(merged_fd) != 0) {
err = got_error_from_errno("fsync");
}
if (restoring_missing_file)
- (*progress_cb)(progress_arg, GOT_STATUS_MISSING, path);
+ err = (*progress_cb)(progress_arg, GOT_STATUS_MISSING, path);
else if (reverting_versioned_file)
- (*progress_cb)(progress_arg, GOT_STATUS_REVERT, path);
+ err = (*progress_cb)(progress_arg, GOT_STATUS_REVERT, path);
else
- (*progress_cb)(progress_arg,
+ err = (*progress_cb)(progress_arg,
update ? GOT_STATUS_UPDATE : GOT_STATUS_ADD, path);
+ if (err)
+ goto done;
hdrlen = got_object_blob_get_hdrlen(blob);
do {
goto done;
if (status == GOT_STATUS_OBSTRUCTED) {
- (*progress_cb)(progress_arg, status, path);
+ err = (*progress_cb)(progress_arg, status, path);
goto done;
}
if (got_fileindex_entry_has_commit(ie) &&
memcmp(ie->commit_sha1, worktree->base_commit_id->sha1,
SHA1_DIGEST_LENGTH) == 0) {
- (*progress_cb)(progress_arg, GOT_STATUS_EXISTS,
+ err = (*progress_cb)(progress_arg, GOT_STATUS_EXISTS,
path);
goto done;
}
blob->id.sha1, worktree->base_commit_id->sha1,
update_timestamps);
} else if (status == GOT_STATUS_DELETE) {
- (*progress_cb)(progress_arg, GOT_STATUS_MERGE, path);
+ err = (*progress_cb)(progress_arg, GOT_STATUS_MERGE, path);
+ if (err)
+ goto done;
err = update_blob_fileindex_entry(worktree, fileindex, ie,
ondisk_path, path, blob, 0);
if (err)
if (status == GOT_STATUS_MODIFY || status == GOT_STATUS_CONFLICT ||
status == GOT_STATUS_ADD) {
- (*progress_cb)(progress_arg, GOT_STATUS_MERGE, ie->path);
+ err = (*progress_cb)(progress_arg, GOT_STATUS_MERGE, ie->path);
+ if (err)
+ return err;
/*
* Preserve the working file and change the deleted blob's
* entry into a schedule-add entry.
if (err)
return err;
} else {
- (*progress_cb)(progress_arg, GOT_STATUS_DELETE, ie->path);
+ err = (*progress_cb)(progress_arg, GOT_STATUS_DELETE, ie->path);
+ if (err)
+ return err;
if (status == GOT_STATUS_NO_CHANGE) {
err = remove_ondisk_file(worktree->root_path, ie->path);
if (err)
static const struct got_error *
bump_base_commit_id(void *arg, struct got_fileindex_entry *ie)
{
+ const struct got_error *err;
struct bump_base_commit_id_arg *a = arg;
if (a->entry_name) {
SHA1_DIGEST_LENGTH) == 0)
return NULL;
- if (a->progress_cb)
- (*a->progress_cb)(a->progress_arg, GOT_STATUS_BUMP_BASE,
+ if (a->progress_cb) {
+ err = (*a->progress_cb)(a->progress_arg, GOT_STATUS_BUMP_BASE,
ie->path);
+ if (err)
+ return err;
+ }
memcpy(ie->commit_sha1, a->base_commit_id->sha1, SHA1_DIGEST_LENGTH);
return NULL;
}
if (blob1 && blob2) {
ie = got_fileindex_entry_get(a->fileindex, path2);
- if (ie == NULL) {
- (*a->progress_cb)(a->progress_arg, GOT_STATUS_MISSING,
- path2);
- return NULL;
- }
+ if (ie == NULL)
+ return (*a->progress_cb)(a->progress_arg,
+ GOT_STATUS_MISSING, path2);
if (asprintf(&ondisk_path, "%s/%s", a->worktree->root_path,
path2) == -1)
goto done;
if (status == GOT_STATUS_DELETE) {
- (*a->progress_cb)(a->progress_arg, GOT_STATUS_MERGE,
- path2);
+ err = (*a->progress_cb)(a->progress_arg,
+ GOT_STATUS_MERGE, path2);
goto done;
}
if (status != GOT_STATUS_NO_CHANGE &&
status != GOT_STATUS_MODIFY &&
status != GOT_STATUS_CONFLICT &&
status != GOT_STATUS_ADD) {
- (*a->progress_cb)(a->progress_arg, status, path2);
+ err = (*a->progress_cb)(a->progress_arg, status, path2);
goto done;
}
a->progress_cb, a->progress_arg);
} else if (blob1) {
ie = got_fileindex_entry_get(a->fileindex, path1);
- if (ie == NULL) {
- (*a->progress_cb)(a->progress_arg, GOT_STATUS_MISSING,
- path2);
- return NULL;
- }
+ if (ie == NULL)
+ return (*a->progress_cb)(a->progress_arg,
+ GOT_STATUS_MISSING, path2);
if (asprintf(&ondisk_path, "%s/%s", a->worktree->root_path,
path1) == -1)
switch (status) {
case GOT_STATUS_NO_CHANGE:
- (*a->progress_cb)(a->progress_arg, GOT_STATUS_DELETE,
- path1);
+ err = (*a->progress_cb)(a->progress_arg,
+ GOT_STATUS_DELETE, path1);
+ if (err)
+ goto done;
err = remove_ondisk_file(a->worktree->root_path, path1);
if (err)
goto done;
break;
case GOT_STATUS_DELETE:
case GOT_STATUS_MISSING:
- (*a->progress_cb)(a->progress_arg, GOT_STATUS_DELETE,
- path1);
+ err = (*a->progress_cb)(a->progress_arg,
+ GOT_STATUS_DELETE, path1);
+ if (err)
+ goto done;
if (ie)
got_fileindex_entry_mark_deleted_from_disk(ie);
break;
case GOT_STATUS_ADD:
case GOT_STATUS_MODIFY:
case GOT_STATUS_CONFLICT:
- (*a->progress_cb)(a->progress_arg,
+ err = (*a->progress_cb)(a->progress_arg,
GOT_STATUS_CANNOT_DELETE, path1);
+ if (err)
+ goto done;
break;
case GOT_STATUS_OBSTRUCTED:
- (*a->progress_cb)(a->progress_arg, status, path1);
+ err = (*a->progress_cb)(a->progress_arg, status, path1);
+ if (err)
+ goto done;
break;
default:
break;
status != GOT_STATUS_MODIFY &&
status != GOT_STATUS_CONFLICT &&
status != GOT_STATUS_ADD) {
- (*a->progress_cb)(a->progress_arg, status,
- path2);
+ err = (*a->progress_cb)(a->progress_arg,
+ status, path2);
goto done;
}
err = merge_blob(&local_changes_subsumed, a->worktree,
switch (status) {
case GOT_STATUS_ADD:
- (*progress_cb)(progress_arg, GOT_STATUS_REVERT, ie->path);
+ err = (*progress_cb)(progress_arg, GOT_STATUS_REVERT, ie->path);
+ if (err)
+ goto done;
got_fileindex_entry_remove(fileindex, ie);
break;
case GOT_STATUS_DELETE:
blob - a64a34999861277292e9a747c737efb3002af876
blob + 26f615388d6c11f50afdbdc448eda9bc500993f3
--- regress/worktree/worktree_test.c
+++ regress/worktree/worktree_test.c
return (ok == 7);
}
-static void
+static const struct got_error *
progress_cb(void *arg, unsigned char status, const char *path)
{
+ return NULL;
}
static int