# vibe-coding-git **Repository Path**: deng_haihui/vibe-coding-git ## Basic Information - **Project Name**: vibe-coding-git - **Description**: 使用vibe Coding,利用Claude Code CLI + GLM5重写git功能。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-07 - **Last Updated**: 2026-04-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # vibe-git A modern, clean Git implementation in pure C. ## Overview vibe-git is a lightweight Git library and command-line tool written in C99. It provides: - **Library (`libvibe-git`)**: A clean, well-documented API for embedding Git functionality in applications - **CLI Tool (`vibe`)**: A command-line interface that mimics standard git commands ## Features ### Core Features - Repository initialization and management - Object storage (loose and packed) - Reference handling (branches, tags, HEAD) - Index/staging area - Commit creation and history - Diff computation ### Network Features - Clone repositories - Push and pull - Fetch and remote management - Multiple protocols: git://, http(s), ssh, file:// ### CLI Commands - `vibe init` - Create a new repository - `vibe add` - Add files to staging - `vibe commit` - Record changes - `vibe status` - Show working tree status - `vibe log` - Show commit history - `vibe branch` - Manage branches - `vibe checkout` - Switch branches - `vibe merge` - Merge branches - `vibe clone` - Clone a repository - `vibe push` - Push to remote - `vibe pull` - Pull from remote - `vibe fetch` - Fetch from remote - `vibe diff` - Show differences - `vibe config` - Configure settings ## Building ### Prerequisites - C compiler (GCC, Clang, or MSVC) - CMake 3.16 or later - zlib development library - CMocka (for tests) ### Build Steps ```bash # Clone the repository git clone https://github.com/example/vibe-git.git cd vibe-git # Configure and build cmake -B build cmake --build build # Run tests (optional) cmake --build build --target test # Install cmake --install build ``` ### Build Options | Option | Default | Description | |--------|---------|-------------| | `VIBE_BUILD_TESTS` | ON | Build test suite | | `VIBE_BUILD_EXAMPLES` | ON | Build example programs | | `VIBE_ENABLE_COVERAGE` | OFF | Enable code coverage | | `VIBE_ENABLE_SANITIZERS` | OFF | Enable ASan/UBSan | ```bash # Debug build with sanitizers cmake -B build -DCMAKE_BUILD_TYPE=Debug -DVIBE_ENABLE_SANITIZERS=ON # Coverage build cmake -B build -DVIBE_ENABLE_COVERAGE=ON ``` ## Usage ### As a Library ```c #include int main(void) { git_repository *repo = NULL; git_commit *commit = NULL; git_oid commit_id; int error; // Initialize library git_lib_init(); // Open repository error = git_repository_open(&repo, "/path/to/repo"); if (error < 0) { fprintf(stderr, "Error: %s\n", git_error_message()); return 1; } // Get HEAD commit error = git_repository_head_commit(&commit, repo); if (error == GIT_OK) { printf("Last commit: %s\n", git_commit_message(commit)); git_commit_free(commit); } // Cleanup git_repository_free(repo); git_lib_shutdown(); return 0; } ``` ### As a CLI Tool ```bash # Create a new repository vibe init my-project # Add files cd my-project vibe add . # Commit changes vibe commit -m "Initial commit" # View status vibe status # View history vibe log # Clone a repository vibe clone https://github.com/user/repo.git ``` ## API Design ### Error Handling All functions return an integer error code: - `0` (`GIT_OK`) indicates success - Negative values indicate errors - `git_error_last()` provides detailed error information ### Memory Management - **Ownership**: Caller owns returned objects - **Freeing**: Use `git_type_free()` functions - **Borrowing**: Const pointers are borrowed (don't free) ```c git_commit *commit = NULL; git_commit_lookup(&commit, repo, &id); // ... use commit ... git_commit_free(commit); // Caller frees ``` ## Documentation - [Architecture](docs/ARCHITECTURE.md) - System design and components - [File Formats](docs/FORMATS.md) - Git file format specifications - [Protocols](docs/PROTOCOLS.md) - Network protocol details - [Development Guide](docs/DEVELOPMENT.md) - Contributing guide ## Project Structure ``` vibe-git/ ├── include/git/ # Public API headers ├── include/ # Internal headers ├── src/ # Implementation │ ├── core/ # Core utilities │ ├── object/ # Object handling │ ├── repository/ # Repository management │ ├── ref/ # Reference handling │ ├── index/ # Index/staging │ ├── diff/ # Diff computation │ ├── merge/ # Merge operations │ ├── transport/ # Network transport │ ├── commands/ # CLI commands │ └── cli/ # CLI interface ├── tests/ # Test suite ├── docs/ # Documentation ├── examples/ # Example programs └── scripts/ # Build scripts ``` ## Testing ```bash # Run all tests cmake --build build --target test # Run specific tests ctest --test-dir build -R hash # Run with coverage cmake -B build-coverage -DVIBE_ENABLE_COVERAGE=ON cmake --build build-coverage cmake --build build-coverage --target test cmake --build build-coverage --target coverage ``` ## Platform Support | Platform | Compiler | Status | |----------|----------|--------| | Linux | GCC, Clang | Full support | | macOS | Clang | Full support | | Windows | MSVC, MinGW | Full support | ## Dependencies - **zlib**: Required for compression - **OpenSSL**: Optional for SHA-256 support - **CMocka**: Optional for testing ## License MIT License - See LICENSE file for details. ## Contributing See [Development Guide](docs/DEVELOPMENT.md) for contribution guidelines. 1. Fork the repository 2. Create a feature branch 3. Make changes with tests 4. Submit pull request ## Acknowledgments Inspired by: - [libgit2](https://github.com/libgit2/libgit2) - Git library design patterns - [Git](https://git-scm.com/) - Original Git implementation - [Git documentation](https://git-scm.com/book/) - Reference materials ## Status Current version: 0.1.0 (initial development) Roadmap: 1. Phase 1: Core functionality (init, add, commit, status, log) 2. Phase 2: Branching (branch, checkout, merge) 3. Phase 3: Networking (clone, push, pull, fetch) 4. Phase 4: Advanced features (stash, rebase, worktrees)