Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .claude/agent-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ update or remove the stale line rather than leaving both.
- User-facing docs (README, CHANGELOG) must not mention features that never shipped; 1.0.0 is the first release, so there is no prior version to reference.
- CHANGELOG follows GitHub release-notes format (`## What's Changed` + PR URLs), listing shipped features only — not Keep a Changelog / Unreleased / pre-1.0 fix archaeology. PR URLs remain even after the git history wipe.
- Do not mention previous code, removed subcommands, or pre-v1.0 archaeology anywhere in the tree (docs, comments, tests). Forward-looking constraints and current git-behavior rationale are fine; unused merged-branch/`rev-list` guidance and a dedicated `clean` unknown-command test are not.
- Do not remove an `init` container on agent-seeding failure; return nonzero and leave the directory.
18 changes: 4 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ does, you could do with `git worktree` by hand.
`init` and `add` produce different things — the container first, working copies
after:

```
```text
After `git trees init`: After `git trees add feature-x`:

some-repo/ some-repo/
Expand Down Expand Up @@ -120,6 +120,7 @@ cd git-trees && ./install.sh # → ~/.local/bin
**Convenience — one-line curl.** Fetches only the script:

```bash
mkdir -p ~/.local/bin
curl -o ~/.local/bin/git-trees \
https://raw.githubusercontent.com/brightdigit/git-trees/v1.0.0/git-trees
chmod +x ~/.local/bin/git-trees
Expand All @@ -145,17 +146,6 @@ case ":$PATH:" in *":$HOME/.local/bin:"*) ;; *)
`install.sh` warns if it isn't; the curl path cannot. Anything on `PATH` named
`git-trees` becomes `git trees`.

### Uninstall

```bash
./install.sh --uninstall # clears ~/.local/bin and /usr/local/bin
./install.sh --uninstall /opt/bin # or the prefix you installed to
```

Pass the same directory you installed to — without it, a custom-prefix install is
left behind. Uninstall does **not** remove `~/.config/git-trees/AGENTS.md`; it
says so, and you can delete it yourself.

## Configuration

All three variables are optional. Add to `~/.zshrc` (or `~/.bashrc`):
Expand Down Expand Up @@ -220,8 +210,8 @@ Creates a worktree, handling three cases:
| Branch exists on `origin` | Fetch, create with `--track` |
| Branch is new | Create from `base` (default `origin/<default>`) with `--no-track` |

> **`add` writes to the remote.** Upstream is always set afterward via `track`.
> If the branch does not exist on `origin`, that runs
> **`add` writes to the remote by default.** When pushing is enabled, upstream is
> set afterward via `track`. If the branch does not exist on `origin`, that runs
> `git push -u origin HEAD` — **which creates the branch on the remote.** This
> is a reasonable default for parallel coding agents, which need an upstream to
> push to, but it means a local-feeling command fires CI, sends notifications,
Expand Down
32 changes: 0 additions & 32 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,12 @@
#
# ./install.sh install to ~/.local/bin
# ./install.sh /usr/local/bin install elsewhere
# ./install.sh --uninstall remove from the two default locations
# ./install.sh --uninstall /opt/bin remove from the prefix you installed to

set -uo pipefail

SRC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CFG="$HOME/.config/git-trees"

if [ "${1:-}" = "--uninstall" ]; then
# Honor the same DEST as install. Without an argument, sweep the two defaults;
# a custom-prefix install would otherwise be left behind silently.
if [ -n "${2:-}" ]; then
set -- "$2"
else
set -- "$HOME/.local/bin" /usr/local/bin
fi

removed=0
for d in "$@"; do
if [ -e "$d/git-trees" ]; then
if rm -f "$d/git-trees"; then
echo "removed $d/git-trees"
removed=1
fi
fi
done

if [ "$removed" -eq 0 ]; then
echo "install.sh: no git-trees found in $*" >&2
echo " if you installed elsewhere, pass it: ./install.sh --uninstall <dir>" >&2
fi

if [ -e "$CFG/AGENTS.md" ]; then
echo "left $CFG/AGENTS.md in place — remove it yourself if you want it gone"
fi
exit 0
fi

DEST="${1:-$HOME/.local/bin}"

[ -f "$SRC/git-trees" ] || { echo "install.sh: git-trees not found in $SRC" >&2; exit 1; }
Expand Down
14 changes: 11 additions & 3 deletions tests/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ assert_no_hang() { # assert_no_hang <label> <cmd...>

# --- fixtures ----------------------------------------------------------------

git config --global user.email >/dev/null 2>&1 || git config --global user.email smoke@example.com
git config --global user.name >/dev/null 2>&1 || git config --global user.name Smoke
# Isolate from the developer's ~/.gitconfig. Identity via env is enough for
# commits; GIT_CONFIG_GLOBAL keeps any incidental `git config --global` off disk
# outside $TMP.
export GIT_CONFIG_GLOBAL="$TMP/gitconfig"
export GIT_AUTHOR_NAME=Smoke GIT_AUTHOR_EMAIL=smoke@example.com
export GIT_COMMITTER_NAME=Smoke GIT_COMMITTER_EMAIL=smoke@example.com

# An upstream with `main`, `feature-x`, and a pre-existing slash branch (as a
# real repo has), served over file://.
Expand Down Expand Up @@ -358,7 +362,11 @@ NP=$(new_container nopush-c)
cd "$NP" || exit 1

out=$(bash "$T" add solo --no-push 2>&1)
assert_ok "add --no-push exits 0" bash "$T" add solo2 --no-push
assert_eq "add --no-push exits 0" "$?" "0"
assert_ok "--no-push created the worktree" test -d solo
assert_eq "--no-push checked out the branch" \
"$(git -C solo symbolic-ref --short HEAD 2>/dev/null)" "solo"
assert_ok "add solo2 --no-push exits 0" bash "$T" add solo2 --no-push
assert_fail "--no-push did not create the branch on origin" \
git ls-remote --exit-code --heads origin solo
assert_fail "--no-push left the upstream unset" \
Expand Down
Loading