Skip to content

Conversation

@helizaga
Copy link
Collaborator

@helizaga helizaga commented Dec 10, 2025

Pull Request

Description

Motivation

Fixes # (issue)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Other (please describe):

Testing

Manual Testing Checklist

Tested on:

  • macOS
  • Linux (specify distro: **_**)
  • Windows (Git Bash)

Core functionality tested:

  • git gtr new <branch> - Create worktree
  • git gtr go <branch> - Navigate to worktree
  • git gtr editor <branch> - Open in editor (if applicable)
  • git gtr ai <branch> - Start AI tool (if applicable)
  • git gtr rm <branch> - Remove worktree
  • git gtr list - List worktrees
  • git gtr config - Configuration commands (if applicable)
  • Other commands affected by this change: **__**

Test Steps

Expected behavior:

Actual behavior:

Breaking Changes

  • This PR introduces breaking changes
  • I have discussed this in an issue first
  • Migration guide is included in documentation

Checklist

Before submitting this PR, please check:

  • I have read CONTRIBUTING.md
  • My code follows the project's style guidelines
  • I have performed manual testing on at least one platform
  • I have updated documentation (README.md, CLAUDE.md, etc.) if needed
  • My changes work on multiple platforms (or I've noted platform-specific behavior)
  • I have added/updated shell completions (if adding new commands or flags)
  • I have tested with both git gtr (production) and ./bin/gtr (development)
  • No new external dependencies are introduced (Bash + git only)
  • All existing functionality still works

Additional Context


License Acknowledgment

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache License 2.0.

Summary by CodeRabbit

  • Bug Fixes
    • Configuration value retrieval now properly returns all values for a given key instead of limiting results to a single value, correctly handling cases with multiple values.
    • Configuration value removal now removes all instances of a key when unsetting instead of removing only one instance, ensuring complete cleanup of all configuration entries.

✏️ Tip: You can customize this high-level summary in your review settings.

@helizaga helizaga requested a review from NatoBoram as a code owner December 10, 2025 04:21
@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Walkthrough

The changes modify git configuration handling to support multi-value keys. The get subcommand now retrieves all values for a key instead of a single value, and the cfg_unset operation now clears all values instead of just one.

Changes

Cohort / File(s) Summary
Configuration retrieval
bin/gtr
Modified get subcommand to call cfg_get_all instead of cfg_get, enabling retrieval of all values for a configuration key
Configuration clearing
lib/config.sh
Changed cfg_unset operation from --unset to --unset-all, supporting removal of all values for a key in the specified scope

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Both changes are single-parameter modifications with no logic flow alterations
  • No error handling or structural changes introduced
  • Straightforward substitution of function calls and git config flags

Poem

🐰 A bunny hops through configs with glee,
Now get all the values, let them all be free!
And unset-all clears them, every single one,
Multi-value magic—configuration fun! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: modifying config get/unset to handle multi-value keys correctly, which matches the actual changes in bin/gtr and lib/config.sh.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/config-get-unset-multivalue

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7f37c33 and 48ef788.

📒 Files selected for processing (2)
  • bin/gtr (1 hunks)
  • lib/config.sh (1 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
lib/**/*.sh

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

lib/**/*.sh: Core libraries (lib/core.sh, lib/config.sh, lib/ui.sh, lib/copy.sh, lib/hooks.sh, lib/platform.sh) must be sourced at startup and implement specific functionality
Maintain backwards compatibility with Git <2.22 by using fallback rev-parse --abbrev-ref HEAD instead of branch --show-current

lib/**/*.sh: Maintain backwards compatibility with existing configs in shell scripts
Quote all paths to support spaces in directory names
Use log_error / log_info from lib/ui.sh for user messages
Implement Git version fallbacks (e.g., Git 2.22+ --show-current vs older rev-parse); check lib/core.sh:97-100 for example
Add new config keys with gtr.<name> prefix to avoid collisions
For performance-sensitive loops (e.g., directory scans), prefer built-ins (find, grep) with minimal subshells
For any new Git command, add fallback for older versions or guard with detection

Files:

  • lib/config.sh
**/*.sh

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

**/*.sh: Always quote paths to handle spaces and special characters; avoid unguarded globbing
Keep set -e active in shell scripts; ensure non-critical failures are guarded with command || true

**/*.sh: Use shebang #!/usr/bin/env bash (not /bin/bash or /bin/sh) for all shell scripts
Use snake_case naming for functions and local variables, UPPER_CASE for constants and environment variables
Use 2-space indentation (no tabs) for all shell scripts
Always quote all variables and paths (e.g., "$var") in shell scripts
Check return codes and use || exit 1 or || return 1 for error handling in shell scripts

Files:

  • lib/config.sh
lib/config.sh

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

For multi-value git config keys, use git config --add to merge and deduplicate values rather than overwriting the entire list

Files:

  • lib/config.sh
**/*.{bash,fish,sh}

📄 CodeRabbit inference engine (.github/instructions/sh.instructions.md)

**/*.{bash,fish,sh}: Bash 3.2+ compatible (macOS default), but 4.0+ features allowed where appropriate
Always quote variables: use "$var" not $var
Use function-scoped variables: local var="value"
Check return codes; functions return 1 on failure
Use snake_case for functions and variables, UPPER_CASE for constants
Prefer [ ] over [[ ]] for POSIX portability; use [[ only when needed
Always quote glob inputs; disable unintended globbing with set -f temporarily if required
Avoid associative arrays in shell scripts; use simple string/loop constructs for Bash 3.2+ compatibility
Avoid readarray and process substitution unsupported in older Bash
Debug with bash -x ./bin/gtr <cmd> or wrap suspicious blocks with set -x / set +x
Check function presence with declare -f create_worktree or declare -f resolve_target
Use stderr for variable inspection: echo "DEBUG var=$var" >&2 to keep stdout clean for command substitution
Keep dependencies minimal: only use git, sed, awk, find, grep; avoid jq/curl unless justified
Check availability of external commands before use when adding new tools
Use "${var}" for variable expansion; for line loops use while IFS= read -r line; do ... done to preserve spaces
Sanitize branch names via sanitize_branch_name function; do NOT duplicate logic elsewhere
Everything is sourced at startup with set -e enabled; functions call each other directly; no subshells except for hooks and AI tools

Files:

  • lib/config.sh
{bin/gtr,lib/**/*.sh,adapters/**/*.sh}

📄 CodeRabbit inference engine (.github/instructions/testing.instructions.md)

{bin/gtr,lib/**/*.sh,adapters/**/*.sh}: All commands must exit 0 (except intentional failures) and produce expected side-effects
No unquoted path errors; spaces must be handled in file paths
Hooks must run only once per creation/removal event

Files:

  • lib/config.sh
  • bin/gtr
lib/*.sh

📄 CodeRabbit inference engine (CLAUDE.md)

lib/*.sh: Maintain backwards compatibility with existing configurations when modifying core functionality files
Follow POSIX-compatible Bash patterns targeting Bash 3.2+ in core library files
Use local for function-scoped variables in library files to prevent variable scope leakage
Provide clear error messages via log_error and log_info from lib/ui.sh in library files

Files:

  • lib/config.sh
bin/gtr

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

bin/gtr: Dispatch commands through cmd_* functions in bin/gtr (case block lines 36‑77)
Update GTR_VERSION on line 8 of bin/gtr when releasing; this affects gtr version / --version output

Global set -e in bin/gtr: guard non-critical commands with || true

list --porcelain output must remain stable for scripting purposes

Update the version constant (line 8: GTR_VERSION="2.0.0") when releasing a new version

Files:

  • bin/gtr
🔇 Additional comments (2)
lib/config.sh (1)

111-125: cfg_unset now correctly clears multi-value config keys

Switching to git config $flag --unset-all "$key" ensures all entries for a key are removed, fixing multi-value behavior while keeping single-valued keys and set -e safety unchanged thanks to 2>/dev/null || true.

bin/gtr (1)

895-902: config get now returns all values for multi-valued keys

Using cfg_get_all "$key" "$scope" makes git gtr config get mirror git’s multi-value behavior (one line per value), which aligns the CLI with how gtr.copy.* and hook configs are consumed; only potential impact is on scripts that previously assumed a single line.


Comment @coderabbitai help to get the list of available commands and usage tips.

@helizaga helizaga merged commit 2446f30 into main Dec 10, 2025
1 check passed
@helizaga helizaga deleted the fix/config-get-unset-multivalue branch December 10, 2025 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants