Skip to content

fix: correct add logic for all vs specific files and add tests (#2373) #2379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tajbaba999
Copy link

Description

This PR updates the git_add function to correctly differentiate between staging all files (["."]) and specific files. Previously, using ["."] could unintentionally include the .git/ directory, potentially corrupting the repository. This fix ensures only appropriate files are staged.

It also includes two additional test cases:

  • One for adding all files using ["."]
  • One for adding specific files only

Server Details

  • Server: github
  • Changes to: tools

Motivation and Context

Fixes #2373

The issue identified that git_add(files=["."]) was tracking files inside the .git/ directory. This caused repository integrity issues. This PR corrects the logic to avoid touching internal Git files and ensures safe staging behavior.

How Has This Been Tested?

  • Verified manually that .git/ is excluded when staging all files
  • Added and ran unit tests for both general and specific file staging
  • Confirmed behavior works correctly with an LLM client environment

Breaking Changes

None

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Protocol Documentation
  • My changes follow MCP security best practices
  • I have updated the server's README accordingly
  • I have tested this with an LLM client
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have documented all environment variables and configuration options

Additional context

Let me know if there are any changes or improvements you'd like to see. Happy to revise as needed.

@tajbaba999
Copy link
Author

Hello @olaservo,
Please let me know if any changes or improvements are needed. I’ll be happy to make the necessary updates.

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.

git_add with files: ["."] parameter incorrectly tracks .git/ directory files causing repository corruption
1 participant