Guitar is a cross-platform graphical Git client built with Qt. It provides a comprehensive interface for managing Git repositories, visualizing commit history with branch graphs, viewing file diffs side-by-side, and performing common Git operations. The application integrates advanced features including AI-powered commit message generation, avatar loading from remote services, and direct Git object manipulation for performance optimization.
This page provides a high-level overview of Guitar's architecture and components. For detailed information about specific subsystems, see:
Guitar follows a layered architecture separating presentation, business logic, data access, and external integrations. The MainWindow class serves as the central orchestrator, coordinating between UI widgets, Git operations, and external services.
Sources: src/MainWindow.h1-712 src/ApplicationGlobal.h1-126 src/Git.h1-264 src/GitRunner.h
The MainWindow class (src/MainWindow.cpp216-342) is the primary entry point for user interactions. It manages the application lifecycle, coordinates between UI components, and delegates Git operations to the GitRunner.
Key Responsibilities:
Sources: src/MainWindow.h90-703 src/MainWindow.cpp216-358
ApplicationGlobal (src/ApplicationGlobal.cpp19-29) provides global access to shared resources, settings, and services throughout the application.
Managed Resources:
ApplicationSettings appsettings - user preferences (src/ApplicationGlobal.h74)WebContext webcx - HTTP client context (src/ApplicationGlobal.h76)AvatarLoader avatar_loader - background avatar fetching (src/ApplicationGlobal.h77)ThemePtr theme - UI theme (dark/light) (src/ApplicationGlobal.h53)FileType filetype - MIME type detection (src/ApplicationGlobal.h72)Sources: src/ApplicationGlobal.h38-125 src/ApplicationGlobal.cpp19-89
Git operations flow through a three-layer abstraction:
Sources: src/GitRunner.h src/Git.h17-243 src/Git.cpp18-163 src/AbstractGitSession.h
For performance, Guitar directly reads Git pack files instead of always invoking git cat-file:
.pack and .idx files with delta decompression (src/GitPack.cpp src/GitPackIdxV2.cpp)Sources: src/Git.cpp29-37 src/GitObjectManager.h src/GitPack.h src/GitPackIdxV2.h
The UI is organized into three primary panels:
| Component | Purpose | File |
|---|---|---|
RepositoryTreeWidget | Repository list with groups and filtering | src/RepositoryTreeWidget.h |
CommitLogTableWidget | Commit history with graph visualization | src/CommitLogTableWidget.h |
FileDiffWidget | Side-by-side diff viewer with syntax highlighting | src/FileDiffWidget.h |
ProgressWidget | Operation progress display | src/ProgressWidget.h |
StatusLabel | Status bar information | src/StatusLabel.h |
Sources: src/MainWindow.ui1-3000 src/RepositoryTreeWidget.h src/CommitLogTableWidget.h src/FileDiffWidget.h
guitar.ini (src/MainWindow.cpp310-312)Guitar supports standard Git operations through both UI and PTY processes:
Sources: src/Git.h122-243 src/Git.cpp147-230
The FileDiffWidget (src/FileDiffWidget.cpp) provides:
dtl library (src/dtl/)TextEditorView (src/texteditor/TextEditorView.h)FileDiffSliderWidget (src/FileDiffSliderWidget.h)Sources: src/FileDiffWidget.h1-200 src/texteditor/TextEditorView.h src/dtl/dtl.hpp
CommitMessageGenerator (src/CommitMessageGenerator.h) generates commit messages from diffs:
Sources: src/CommitMessageGenerator.h src/GenerativeAI.h src/GenerateCommitMessageThread.h
Sources: src/webclient.h src/AvatarLoader.h src/GitHubAPI.h
Platform-specific implementations handle:
winpty library (Guitar.pri49-50)openpt, grantpt, unlockpt (Guitar.pri36)Sources: src/AbstractProcess.h src/win32/Win32Process.h src/win32/Win32PtyProcess.h src/unix/UnixProcess.h src/unix/UnixPtyProcess.h
The project uses qmake with modular .pri files:
Guitar.pro - Main project file (Guitar.pro1-5)Guitar.pri - Core configuration, dependencies, source files (Guitar.pri1-595)migemo.pri - Japanese incremental search supportDependencies:
filetype library for MIME detection (Guitar.pri89-93)Sources: Guitar.pro1-5 Guitar.pri1-100
The application initializes in this order (src/main.cpp86-269):
Sources: src/main.cpp86-269
The MainWindow uses a custom event queue for delayed user events (src/MainWindow.cpp432-472):
postUserEvent() schedules events with millisecond precisiononInterval10ms() processes queued events at 10ms intervals (src/MainWindow.cpp504-543)Sources: src/MainWindow.cpp432-543 src/UserEvent.h
Settings are stored using Qt's QSettings wrapper (MySettings src/MySettings.h):
{AppConfigDir}/Guitar.ini (src/main.cpp142)Sources: src/MySettings.h src/ApplicationSettings.h src/main.cpp136-165
| Layer | Technologies |
|---|---|
| UI Framework | Qt 5/6 (Widgets, SVG, Network) |
| Programming Language | C++17 |
| Version Control | Direct Git command execution + pack file reading |
| Networking | OpenSSL (HTTPS), Qt Network |
| Text Editing | Custom character-based editor (AbstractCharacterBasedApplication) |
| Diff Algorithm | dtl library (Myers diff) |
| Process Management | Platform-specific (winpty on Windows, POSIX PTY on Unix) |
| File Type Detection | libmagic wrapper |
| Build System | qmake |
Sources: Guitar.pri1-100 src/texteditor/AbstractCharacterBasedApplication.h src/dtl/dtl.hpp
Refresh this wiki