Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix #5302: Create .git/info directory before writing exclude file#5325

Open
cobyfrombrooklyn-bot wants to merge 1 commit intojesseduffield:masterfrom
cobyfrombrooklyn-bot:fix-issue-5302
Open

Fix #5302: Create .git/info directory before writing exclude file#5325
cobyfrombrooklyn-bot wants to merge 1 commit intojesseduffield:masterfrom
cobyfrombrooklyn-bot:fix-issue-5302

Conversation

@cobyfrombrooklyn-bot
Copy link

Fixes #5302

Problem

When .git/info directory does not exist (can happen with bare clones, manual deletion, or certain Git configurations), selecting "Add to .git/info/exclude" fails with:

open <repo-path>/.git/info/exclude: no such file or directory

The Exclude function used os.OpenFile with os.O_CREATE which creates the file but not its parent directory.

Fix

Added os.MkdirAll to create the .git/info directory (with 0755 permissions) before attempting to open the exclude file. MkdirAll is a no-op if the directory already exists, so existing behavior is unchanged.

Test

Added integration test file/exclude_without_info_dir that:

  1. Removes .git/info directory during repo setup
  2. Attempts to exclude a file via the menu
  3. Verifies .git/info/exclude is created with the correct content

Test fails without the fix, passes with it.

Tested locally on macOS ARM (Apple Silicon). Unit tests and integration test pass.

…lude file

When .git/info directory does not exist (can happen with bare clones
or manual deletion), the Exclude function failed with 'no such file
or directory'. Added os.MkdirAll to create the directory before
opening the exclude file.

Added integration test exclude_without_info_dir that removes .git/info
before attempting to exclude a file.
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.

Fails to add to .git/info/exclude when .git/info directory is missing

1 participant