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

10 commits

Author SHA1 Message Date
e09e4b9cb7 simplify ent new 2025-07-09 22:36:24 -06:00
acf539c683 handle user abort in ent comment
The user saving an empty description is a normal user-initiated abort,
not an error.
2025-07-09 22:36:24 -06:00
a199fbc7f7 handle aborts in ent edit ISSUE
The user saving an empty description file is a normal user-initiated
abort, not an error.
2025-07-09 22:36:24 -06:00
fc658009f5 Comment: handle empty description 2025-07-09 22:34:55 -06:00
211bf92dde Issue: handle empty description from user
This fixes issue a26da230276d317e85f9fcca41c19d2e.
2025-07-09 22:33:58 -06:00
bfdf6178f4 add git::commit() 2025-07-09 22:33:58 -06:00
16de030b8e add git::add_file() 2025-07-09 22:33:58 -06:00
ac72251e0e add git::restore_file()
This restores a file from the index to the worktree.
2025-07-09 22:33:58 -06:00
1509c42734 add git::worktree_is_dirty()
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.
2025-07-09 22:33:58 -06:00
ca353352f8 git::Worktree::drop() now force-drops the worktree
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!
2025-07-09 22:31:07 -06:00