Syntax
Description
The--list flag displays all branches that have stashes managed by gitsw. This helps you track which branches have saved changes and whether those stashes still exist in Git.
Implementation
Thelist_stashes function (src/main.rs:154-204) performs the following:
1. Load state and stashes
- Reads gitsw state from
.git/git-switch.json - Retrieves all Git stashes in the repository
- Filters for branches that have stash IDs in gitsw state
2. Validate stashes
For each branch with a stash ID:- Verifies the stash OID still exists in Git’s stash list
- Marks stash as “present” (yellow) or “missing” (red)
3. Display format
- Current branch marked with
*and displayed in green/bold - Other branches shown with 2-space indent
- Shows stash status and last visited time
Output Format
marker:*for current branch,(two spaces) for othersbranch_name: Green/bold if current, normal otherwisestash_status: “stash present” (yellow) or “stash missing” (red)time: Human-readable time format (see Time Format below)
Example Output
With stashed branches
No stashed branches
Time Format
Theformat_time_ago function (src/main.rs:569-586) converts timestamps to human-readable format:
| Duration | Format |
|---|---|
| < 1 minute | ”just now” |
| 1-59 minutes | ” min ago” |
| 1-23 hours | ” hour(s) ago” |
| 1 day | ”yesterday” |
| 2+ days | ” days ago” |
Stash Status
The stash OID from gitsw state exists in Git’s stash list. Changes can be restored.
The stash OID is in gitsw state but no longer exists in Git (manually dropped or repository issue). Changes are lost.