Skip to content

Commit b62b0d9

Browse files
committed
docs: improve this doc a bit
1 parent 7fae72f commit b62b0d9

File tree

1 file changed

+91
-108
lines changed

1 file changed

+91
-108
lines changed

docs/troubleshooting.md

Lines changed: 91 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,52 @@
22

33
This guide will help you diagnose and fix common issues with git-mit.
44

5+
## Common Error Messages
6+
7+
Here are solutions for frequently encountered error messages:
8+
9+
### "failed to interact with git repository"
10+
11+
This usually means git-mit can't find or read the Git repository. Check:
12+
- You're in a Git repository (`git status` should work)
13+
- The `.git` directory has proper permissions
14+
- Your Git installation is working correctly
15+
16+
### "could not parse author configuration"
17+
18+
Your authors file has invalid TOML or YAML syntax. The error will show which format failed:
19+
- Check for missing quotes around strings
20+
- Ensure proper indentation (YAML is indent-sensitive)
21+
- Validate your file with a TOML/YAML validator
22+
- The error message will indicate whether it failed parsing as TOML or YAML
23+
24+
### "failed to install hook"
25+
26+
The hook installation failed because:
27+
- **ExistingHook**: A non-symlink hook already exists at that location
28+
- **ExistingSymlink**: A symlink exists but points to a different location
29+
- You don't have write permissions to the hooks directory
30+
31+
Remove the existing hook or check where the existing symlink points.
32+
33+
### "No authors set" (from pre-commit hook)
34+
35+
This error appears when:
36+
- You haven't run `git mit <initials>` to set the current authors
37+
- The author configuration has expired (check `git config mit.author.expires`)
38+
- The author configuration was never set in this repository
39+
40+
### "The details of the author of this commit are stale"
41+
42+
This error shows:
43+
- The exact time when the author configuration expired
44+
- You need to run `git mit <initials>` again to refresh the configuration
45+
546
## Authors and the `git mit` command
647

7-
Something is up with authors, author discovery or similar
48+
If you're having issues with author configuration:
849

9-
### Steps
50+
### Troubleshooting Steps
1051

1152
1. **View all configured authors**:
1253
```bash,skip()
@@ -39,44 +80,9 @@ Something is up with authors, author discovery or similar
3980
mit.author.expires=1747556921
4081
```
4182

42-
### Technical Details
43-
44-
git-mit loads authors from multiple sources and merges them together:
45-
46-
1. **From exec command** (highest priority):
47-
- Set via `--exec` flag or `GIT_MIT_AUTHORS_EXEC` environment variable
48-
- The command output must be valid TOML or YAML format
49-
- The command is executed using `shell_words::split()` for proper argument parsing
50-
51-
2. **From authors file**:
52-
- Default location: `$HOME/.config/git-mit/mit.toml`
53-
- Custom location via `--config` flag or `GIT_MIT_AUTHORS_CONFIG` environment variable
54-
- Special handling for `$HOME/.config/git-mit/mit.toml` path - it's expanded to the actual home directory
55-
- If the file doesn't exist, an empty string is used (no error)
56-
57-
3. **From Git config**:
58-
- Authors stored in `mit.author.config.<initial>.*` entries
59-
- These are set when you run `git mit-config mit set <initial> <name> <email>`
60-
- Stored at repository level (local) or user level (global) based on `--scope`
61-
62-
The authors from these sources are **merged together**, with later sources overriding earlier ones if there are conflicts.
63-
64-
For more information on configuring authors, see the [authors documentation](mit.md).
65-
6683
### Extending Author Configuration Timeout
6784

68-
By default, author configuration expires after 60 minutes, requiring you to run `git mit <initials>` again. If you find this timeout too short, you can extend it.
69-
70-
#### How the Timeout Works
71-
72-
- The timeout is stored as a Unix timestamp in `mit.author.expires`
73-
- When you run `git mit <initials>`, it sets the expiration to current time + timeout duration (in minutes)
74-
- The `pre-commit` hook checks if the current time is past this expiration
75-
- If expired, you'll see an error with the expiration time and need to run `git mit` again
76-
77-
Note: Setting very long timeouts reduces the benefit of the expiration feature, which ensures commit attribution stays current when developers change throughout the day.
78-
79-
#### Setting a Longer Timeout
85+
By default, author configuration expires after 60 minutes. If you find this timeout too short, you can extend it:
8086

8187
1. **Using command-line flag**:
8288
```bash,skip()
@@ -127,15 +133,6 @@ If co-authors aren't being added to commits or commit message validation isn't w
127133
```
128134
Look for `x` in the permissions (e.g., `-rwxr-xr-x`)
129135

130-
### Hook Installation Details
131-
132-
The installation process creates symbolic links to the git-mit binaries:
133-
134-
- **Windows**: Creates file symbolic links with `.exe` extension
135-
- **Unix/Linux/macOS**: Creates standard symbolic links
136-
- **Existing hooks**: Installation will fail if hooks already exist (unless they're already symlinks to git-mit)
137-
- **Symlink validation**: If a symlink exists but points to the correct binary, installation succeeds silently
138-
139136
### Reinstall Hooks
140137

141138
If hooks are missing or not working:
@@ -177,27 +174,6 @@ See the [installation documentation](binaries/git-mit-install.md) for more detai
177174

178175
If lints aren't being applied as expected:
179176

180-
### Understanding Lint Configuration Precedence
181-
182-
Lints are loaded from multiple sources with TOML files taking precedence:
183-
184-
1. **TOML configuration files** (highest priority):
185-
- `.git-mit.toml` (takes precedence if exists)
186-
- `.git-mit.toml.dist` (used if `.git-mit.toml` doesn't exist)
187-
- Located by discovering the Git repository and checking the parent of `.git` directory
188-
- For bare repositories, checks the repository directory itself
189-
190-
2. **VCS configuration** (Git config - used if no TOML config exists):
191-
- Read from `mit.lint.<lint-name>` entries
192-
- Can be set with `git mit-config lint enable/disable <lint-name>`
193-
- Uses the lint's default enabled state if not explicitly configured
194-
195-
The TOML configuration uses this format:
196-
```toml,skip()
197-
[mit.lint]
198-
"lint-name" = true # or false
199-
```
200-
201177
### Debugging Lint Configuration
202178

203179
1. **Check current lint status**:
@@ -232,7 +208,9 @@ The TOML configuration uses this format:
232208

233209
Understanding where git-mit stores its data can help with troubleshooting:
234210

235-
### Author Configurations
211+
### Configuration Storage Locations
212+
213+
#### Author Configurations
236214

237215
1. **Authors file** (permanent storage):
238216
- Default location: `$HOME/.config/git-mit/mit.toml` (Linux/macOS) or `%APPDATA%\git-mit\mit.toml` (Windows)
@@ -251,7 +229,7 @@ Understanding where git-mit stores its data can help with troubleshooting:
251229
- Expires: Controlled by `mit.author.expires` timestamp
252230
- Set by: Running `git mit <initials>`
253231

254-
### Lint Configuration
232+
#### Lint Configuration
255233

256234
1. **Repository level**:
257235
- File: `.git/config`
@@ -263,15 +241,15 @@ Understanding where git-mit stores its data can help with troubleshooting:
263241
- Example: Setting `not-conventional-commit = true` in `[mit.lint]` section
264242
- See [lint configuration documentation](lints/configuring.md)
265243

266-
### Relates-to Configuration
244+
#### Relates-to Configuration
267245

268246
- Stored in: `.git/config`
269247
- Keys: `mit.relate.to` and `mit.relate.expires`
270248
- Template: `mit.relate.template` (for formatting the trailer)
271249
- Set by: `git mit-relates-to`
272250
- See [relates-to documentation](mit-relates-to.md)
273251

274-
### Hook Installation Locations
252+
#### Hook Installation Locations
275253

276254
1. **Local installation** (`git mit-install` or `git mit-install --scope=local`):
277255
- Location: `.git/hooks/` in current repository
@@ -282,62 +260,67 @@ Understanding where git-mit stores its data can help with troubleshooting:
282260
- Location: Template directory (e.g., `~/.config/git/init-template/hooks/`)
283261
- Applied to: New repositories when running `git init` or `git clone`
284262

285-
### git's Precedence of config files
263+
### Configuration Loading Precedence
264+
265+
#### git's Precedence of config files
286266

287267
git-mit uses libgit2 for Git interactions, which follows standard Git configuration precedence:
288268

289269
1. Repository config (`.git/config`) - highest priority
290270
2. User config (`~/.gitconfig`)
291271
3. System config (`/etc/gitconfig`) - lowest priority
292272

293-
### How git-mit Discovers git Configuration
294-
295-
The configuration discovery process:
273+
#### Lint Configuration Precedence
296274

297-
1. **Repository discovery**: Uses `Repository::discover()` to find the Git repository
298-
2. **Config loading**: Opens the repository's config or falls back to [default config](https://libgit2.org/docs/reference/v0.22.1/config/git_config_open_default.html)
299-
3. **Author loading**: Reads from `mit.author.config.*` entries in Git config
300-
4. **Lint settings**: Reads from `mit.lint.*` entries and `.git-mit.toml` files
301-
5. **TOML file discovery**: Looks for `.git-mit.toml` first, then `.git-mit.toml.dist` in repository root
275+
Lints are loaded from multiple sources with TOML files taking precedence:
302276

303-
## Common Error Messages
277+
1. **TOML configuration files** (highest priority):
278+
- `.git-mit.toml` (takes precedence if exists)
279+
- `.git-mit.toml.dist` (used if `.git-mit.toml` doesn't exist)
280+
- Located by discovering the Git repository and checking the parent of `.git` directory
281+
- For bare repositories, checks the repository directory itself
304282

305-
### "failed to interact with git repository"
283+
2. **VCS configuration** (Git config - used if no TOML config exists):
284+
- Read from `mit.lint.<lint-name>` entries
285+
- Can be set with `git mit-config lint enable/disable <lint-name>`
286+
- Uses the lint's default enabled state if not explicitly configured
306287

307-
This usually means git-mit can't find or read the Git repository. Check:
308-
- You're in a Git repository (`git status` should work)
309-
- The `.git` directory has proper permissions
310-
- Your Git installation is working correctly
288+
The TOML configuration uses this format:
289+
```toml,skip()
290+
[mit.lint]
291+
"lint-name" = true # or false
292+
```
311293

312-
### "could not parse author configuration"
294+
#### Author Configuration Precedence
313295

314-
Your authors file has invalid TOML or YAML syntax. The error will show which format failed:
315-
- Check for missing quotes around strings
316-
- Ensure proper indentation (YAML is indent-sensitive)
317-
- Validate your file with a TOML/YAML validator
318-
- The error message will indicate whether it failed parsing as TOML or YAML
296+
git-mit loads authors from multiple sources and merges them together:
319297

320-
### "failed to install hook"
298+
1. **From exec command** (highest priority):
299+
- Set via `--exec` flag or `GIT_MIT_AUTHORS_EXEC` environment variable
300+
- The command output must be valid TOML or YAML format
301+
- The command is executed using `shell_words::split()` for proper argument parsing
321302

322-
The hook installation failed because:
323-
- **ExistingHook**: A non-symlink hook already exists at that location
324-
- **ExistingSymlink**: A symlink exists but points to a different location
325-
- You don't have write permissions to the hooks directory
303+
2. **From authors file**:
304+
- Default location: `$HOME/.config/git-mit/mit.toml`
305+
- Custom location via `--config` flag or `GIT_MIT_AUTHORS_CONFIG` environment variable
306+
- Special handling for `$HOME/.config/git-mit/mit.toml` path - it's expanded to the actual home directory
307+
- If the file doesn't exist, an empty string is used (no error)
326308

327-
Remove the existing hook or check where the existing symlink points.
309+
3. **From Git config**:
310+
- Authors stored in `mit.author.config.<initial>.*` entries
311+
- These are set when you run `git mit-config mit set <initial> <name> <email>`
312+
- Stored at repository level (local) or user level (global) based on `--scope`
328313

329-
### "No authors set" (from pre-commit hook)
314+
The authors from these sources are **merged**, with later sources overriding earlier ones if there are conflicts.
330315

331-
This error appears when:
332-
- You haven't run `git mit <initials>` to set the current authors
333-
- The author configuration has expired (check `git config mit.author.expires`)
334-
- The author configuration was never set in this repository
316+
### Hook Installation Details
335317

336-
### "The details of the author of this commit are stale"
318+
The installation process creates symbolic links to the git-mit binaries:
337319

338-
This error shows:
339-
- The exact time when the author configuration expired
340-
- You need to run `git mit <initials>` again to refresh the configuration
320+
- **Windows**: Creates file symbolic links with `.exe` extension
321+
- **Unix/Linux/macOS**: Creates standard symbolic links
322+
- **Existing hooks**: Installation will fail if hooks already exist (unless they're already symlinks to git-mit)
323+
- **Symlink validation**: If a symlink exists but points to the correct binary, installation succeeds silently
341324

342325
## Still Having Issues?
343326

0 commit comments

Comments
 (0)