unstage: report new current status for deleted unstaged paths
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
diff --git a/lib/worktree.c b/lib/worktree.c
index 5c9c914..45b06f7 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -5250,11 +5250,16 @@ unstage_path(void *arg, unsigned char status,
struct got_blob_object *blob_base = NULL, *blob_staged = NULL;
char *ondisk_path = NULL;
int local_changes_subsumed;
+ struct stat sb;
ie = got_fileindex_entry_get(a->fileindex, relpath, strlen(relpath));
if (ie == NULL)
return got_error_path(relpath, GOT_ERR_BAD_PATH);
+ if (asprintf(&ondisk_path, "%s/%s", a->worktree->root_path, relpath)
+ == -1)
+ return got_error_from_errno("asprintf");
+
switch (staged_status) {
case GOT_STATUS_MODIFY:
err = got_object_open_as_blob(&blob_base, a->repo,
@@ -5268,11 +5273,6 @@ unstage_path(void *arg, unsigned char status,
if (err)
break;
- if (asprintf(&ondisk_path, "%s/%s", a->worktree->root_path,
- relpath) == -1) {
- err= got_error_from_errno("asprintf");
- break;
- }
err = merge_blob(&local_changes_subsumed, a->worktree,
blob_base, ondisk_path, relpath,
@@ -5285,8 +5285,10 @@ unstage_path(void *arg, unsigned char status,
break;
case GOT_STATUS_DELETE:
got_fileindex_entry_stage_set(ie, GOT_FILEIDX_STAGE_NONE);
- err = (*a->progress_cb)(a->progress_arg, GOT_STATUS_DELETE,
- relpath);
+ err = get_file_status(&status, &sb, ie, ondisk_path, a->repo);
+ if (err)
+ break;
+ err = (*a->progress_cb)(a->progress_arg, status, relpath);
break;
}