Skip to content

cfg_default doesn't read from .gtrconfig (missing file_key auto-mapping) #85

@pkohei

Description

@pkohei

Summary

The cfg_default function doesn't read settings from .gtrconfig because it lacks the auto-mapping feature that cfg_get_all has. This affects gtr.worktrees.dir and gtr.defaultBranch settings.

Steps to Reproduce

  1. Create a .gtrconfig file:
[worktrees]
    dir = /worktrees
  1. Run git gtr new test

  2. Expected: Worktree created in /worktrees/test

  3. Actual: Worktree created in default location (<repo>-worktrees/test)

Root Cause

In lib/config.sh, cfg_get_all has auto-mapping (lines 115-117):

# Auto-map file_key if not provided and key is a gtr.* key
if [ -z "$file_key" ] && [[ "$key" == gtr.* ]]; then
  file_key=$(cfg_map_to_file_key "$key")
fi

But cfg_default doesn't have this, so when called without file_key:

# lib/core.sh line 51
base_dir=$(cfg_default "gtr.worktrees.dir" "GTR_WORKTREES_DIR" "")

The .gtrconfig is never checked.

Suggested Fix

Add auto-mapping to cfg_default:

cfg_default() {
  local key="$1"
  local env_name="$2"
  local fallback="$3"
  local file_key="${4:-}"

  # Auto-map file_key if not provided and key is a gtr.* key
  if [ -z "$file_key" ] && [[ "$key" == gtr.* ]]; then
    file_key=$(cfg_map_to_file_key "$key")
  fi
  # ... rest of function

Workaround

Use git config --local instead:

git config --local gtr.worktrees.dir /worktrees

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions