empty-descriptions-and-dropped-worktrees #15

Merged
seb merged 10 commits from empty-descriptions-and-dropped-worktrees into main 2025-07-10 09:48:22 -06:00
Owner

Another disorganized grab-bag of fixes. This PR fixes these ent issues:

a26da230276d317e85f9fcca41c19d2e       `ent edit ${ISSUE}` with no change fails (👉 seb)
ae56208b6db64ccd9da31ce2bb1aad64  🗨️ 2  `ent sync`, ^C, now there's a stray worktree (👉 seb)
a5ac277614ea4d13f78031abb25ea7d6       `ent new` and `ent comment`: detect empty issue descriptions & comments (👉 seb)

The "edit with no change" and "empty descriptions" bugs are handled by being more careful in {Issue,Comment}::{edit,set}_description() about unchanged files and empty files, and handling those things better.

The "stray worktree" issue was just passing --force to git worktree remove so it remove the worktree even if it's dirty.

Another disorganized grab-bag of fixes. This PR fixes these ent issues: ``` a26da230276d317e85f9fcca41c19d2e `ent edit ${ISSUE}` with no change fails (👉 seb) ae56208b6db64ccd9da31ce2bb1aad64 🗨️ 2 `ent sync`, ^C, now there's a stray worktree (👉 seb) a5ac277614ea4d13f78031abb25ea7d6 `ent new` and `ent comment`: detect empty issue descriptions & comments (👉 seb) ``` The "edit with no change" and "empty descriptions" bugs are handled by being more careful in `{Issue,Comment}::{edit,set}_description()` about unchanged files and empty files, and handling those things better. The "stray worktree" issue was just passing `--force` to `git worktree remove` so it remove the worktree even if it's dirty.
seb added 10 commits 2025-07-09 22:48:18 -06:00
This avoids leaving prunable worktrees around if we dirtied the worktree
and didn't commit.

This can happen in the following situation:

1. User runs `ent new`.

2. ent creates a new directory for the issue.

3. ent opens an editor to let the user type in the description of the
   new issue.  The editor saves to `ISSUE/description`.

4. User changes their mind and no longer wants to make a new issue, so
   they save an empty buffer and exit the editor.

5. ent sees that the file is empty, and returns an error from
   Issue::edit_description().

6. ent propagates the error up through program exit, and eventually
   the git::Worktree struct is dropped.  Since the worktree is dirty
   (it has the new issue dir with an empty description file in it),
   `git worktree remove` fails.

But `git worktree remove --force` works!
This returns Ok(true) if the worktree has any modified files (staged or
unstaged), or any added (staged) files.  Ok(false) if not.

Ignores untracked files.
This restores a file from the index to the worktree.
This fixes issue a26da230276d317e85f9fcca41c19d2e.
The user saving an empty description file is a normal user-initiated
abort, not an error.
The user saving an empty description is a normal user-initiated abort,
not an error.
Author
Owner

Oops, this doesn't fix ent ae56208b6db64ccd9da31ce2bb1aad64, though it fixes many other kinds of stray worktree problems. ^C doesn't terminate the process cleanly, so it doesn't drop the Worktree object. :-(

Oops, this doesn't fix `ent ae56208b6db64ccd9da31ce2bb1aad64`, though it fixes many other kinds of stray worktree problems. ^C doesn't terminate the process cleanly, so it doesn't drop the Worktree object. :-(
seb merged commit 6cff355e4a into main 2025-07-10 09:48:22 -06:00
seb deleted branch empty-descriptions-and-dropped-worktrees 2025-07-10 09:48:23 -06:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: taproot-manufacturing/entomologist#15
No description provided.