Skip to content

lib_git.sh: one internal helper relies on caller cwd instead of threading -C like the rest of the module #300

Description

@codeforester

Summary

__base_bash_libs_git_only_path_dirty__ (lib/bash/git/lib_git.sh:198-238) calls bare git status, relying on the caller having already cd'd/pushd'd into the target repo — unlike every other function in this module, which explicitly threads -C "$repo_dir" through its git invocations to stay cwd-independent.

Details

Every other public and internal function in lib_git.sh accepts or threads a repo directory explicitly and passes -C "$repo_dir" to git. This one helper is the exception, which means it silently depends on caller cwd state that the rest of the module is careful to avoid depending on.

Impact

A caller that uses this helper (directly or transitively) from a different cwd than the target repo gets wrong or empty results without any error — inconsistent with the cwd-independence the rest of the module guarantees, and a likely source of confusing bugs for anyone who assumes uniform behavior across lib_git.sh.

Suggested fix

Thread -C "$repo_dir" (or equivalent) through this helper's git status call to match the rest of the module.

Metadata

Metadata

Assignees

Labels

bugSomething is not working

Type

No type

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions