git-editor 2.1.0

A command-line tool to edit git commit timestamps, messages, and author information
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Git Editor - Comprehensive Technical Documentation</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            line-height: 1.6;
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
            background: #f8f9fa;
            color: #333;
        }

        .container {
            background: white;
            padding: 40px;
            border-radius: 12px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            position: relative;
        }

        h1 {
            color: #2c3e50;
            border-bottom: 3px solid #3498db;
            padding-bottom: 10px;
            margin-bottom: 30px;
            font-size: 2.5em;
        }

        h2 {
            color: #34495e;
            margin-top: 50px;
            margin-bottom: 25px;
            border-left: 4px solid #3498db;
            padding-left: 20px;
            font-size: 1.8em;
        }

        h3 {
            color: #2c3e50;
            margin-top: 35px;
            margin-bottom: 15px;
            font-size: 1.4em;
        }

        h4 {
            color: #34495e;
            margin-top: 25px;
            margin-bottom: 12px;
            font-size: 1.2em;
        }

        .toc {
            background: #ecf0f1;
            padding: 25px;
            border-radius: 8px;
            margin-bottom: 40px;
            border: 1px solid #bdc3c7;
        }

        .toc ul {
            list-style-type: none;
            padding-left: 0;
        }

        .toc li {
            margin: 10px 0;
        }

        .toc a {
            color: #2980b9;
            text-decoration: none;
            font-weight: 500;
            transition: color 0.3s ease;
        }

        .toc a:hover {
            color: #1f4e79;
            text-decoration: underline;
        }

        code {
            background: #f1f2f6;
            padding: 3px 6px;
            border-radius: 4px;
            font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
            color: #c7254e;
            font-size: 0.9em;
        }

        .code-block {
            position: relative;
            margin: 25px 0;
        }

        pre {
            background: #2c3e50;
            color: #ecf0f1;
            padding: 25px;
            border-radius: 8px;
            overflow-x: auto;
            position: relative;
            border: 1px solid #34495e;
        }

        pre code {
            background: none;
            color: inherit;
            padding: 0;
            font-size: 0.95em;
            line-height: 1.5;
        }

        .copy-btn {
            position: absolute;
            top: 10px;
            right: 10px;
            background: #3498db;
            color: white;
            border: none;
            padding: 6px 12px;
            border-radius: 4px;
            cursor: pointer;
            font-size: 0.8em;
            transition: all 0.3s ease;
            opacity: 0.8;
        }

        .copy-btn:hover {
            background: #2980b9;
            opacity: 1;
        }

        .copy-btn:active {
            transform: scale(0.95);
        }

        .copy-btn.copied {
            background: #27ae60;
        }

        .example {
            background: #e8f5e8;
            border-left: 4px solid #27ae60;
            padding: 20px;
            margin: 25px 0;
            border-radius: 0 8px 8px 0;
        }

        .warning {
            background: #fef9e7;
            border-left: 4px solid #f39c12;
            padding: 20px;
            margin: 25px 0;
            border-radius: 0 8px 8px 0;
        }

        .danger {
            background: #fdf2f2;
            border-left: 4px solid #e74c3c;
            padding: 20px;
            margin: 25px 0;
            border-radius: 0 8px 8px 0;
        }

        .info {
            background: #e3f2fd;
            border-left: 4px solid #2196f3;
            padding: 20px;
            margin: 25px 0;
            border-radius: 0 8px 8px 0;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin: 25px 0;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        th,
        td {
            border: 1px solid #ddd;
            padding: 15px;
            text-align: left;
        }

        th {
            background-color: #34495e;
            color: white;
            font-weight: bold;
        }

        tr:nth-child(even) {
            background-color: #f9f9f9;
        }

        .badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.8em;
            font-weight: bold;
            margin: 2px;
        }

        .badge-primary {
            background: #3498db;
            color: white;
        }

        .badge-success {
            background: #27ae60;
            color: white;
        }

        .badge-warning {
            background: #f39c12;
            color: white;
        }

        .badge-danger {
            background: #e74c3c;
            color: white;
        }

        .badge-info {
            background: #2196f3;
            color: white;
        }

        .feature-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
            gap: 20px;
            margin: 30px 0;
        }

        .feature-card {
            background: #f8f9fa;
            padding: 20px;
            border-radius: 8px;
            border: 1px solid #e9ecef;
        }

        .syntax-highlight {
            background: #2d3748;
            color: #e2e8f0;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
            position: relative;
        }

        .command-section {
            background: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 8px;
            padding: 20px;
            margin: 20px 0;
        }

        .flow-diagram {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            border-radius: 12px;
            margin: 30px 0;
            text-align: center;
        }

        .architecture-box {
            background: #fff;
            border: 2px solid #3498db;
            border-radius: 8px;
            padding: 15px;
            margin: 10px;
            text-align: center;
            color: #2c3e50;
        }

        @media (max-width: 768px) {
            .container {
                padding: 20px;
            }

            h1 {
                font-size: 2em;
            }

            .feature-grid {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>

<body>
    <div class="container">
        <h1>🛠️ Git Editor - Complete Technical Documentation</h1>

        <div class="toc">
            <h3>📋 Table of Contents</h3>
            <ul>
                <li><a href="#overview">Overview & Architecture</a></li>
                <li><a href="#installation">Installation & Setup</a></li>
                <li><a href="#operation-modes">Operation Modes</a></li>
                <li><a href="#command-reference">Complete Command Reference</a></li>
                <li><a href="#technical-details">Technical Implementation</a></li>
                <li><a href="#examples">Usage Examples & Workflows</a></li>
                <li><a href="#advanced-features">Advanced Features</a></li>
                <li><a href="#internals">Internal Architecture</a></li>
                <li><a href="#development">Development Guide</a></li>
                <li><a href="#troubleshooting">Troubleshooting & FAQ</a></li>
                <li><a href="#api-reference">API Reference</a></li>
            </ul>
        </div>

        <section id="overview">
            <h2>🎯 Overview & Architecture</h2>
            <p><strong>Git Editor</strong> is a sophisticated command-line tool written in Rust for comprehensive Git commit history manipulation. It provides surgical precision for rewriting timestamps, author information, and commit messages while maintaining repository integrity.</p>

            <div class="info">
                <strong>🔧 Core Capabilities:</strong>
                <ul>
                    <li><strong>Timestamp Rewriting:</strong> Intelligent date distribution with realistic patterns</li>
                    <li><strong>Author Management:</strong> Bulk update of author name and email</li>
                    <li><strong>Interactive Selection:</strong> Pick specific commits or ranges</li>
                    <li><strong>Simulation Mode:</strong> Preview changes before applying</li>
                    <li><strong>Git URL Cloning:</strong> Direct operation on remote repositories</li>
                </ul>
            </div>

            <div class="danger">
                <strong>⚠️ Critical Warning:</strong> This tool permanently rewrites Git history. Always backup your repository before use. Force pushes will be required after history rewriting.
            </div>

            <div class="flow-diagram">
                <h3>🔄 Git Editor Workflow</h3>
                <div style="display: flex; justify-content: space-around; flex-wrap: wrap; margin-top: 20px;">
                    <div class="architecture-box">Input Validation</div>
                    <div class="architecture-box">Repository Analysis</div>
                    <div class="architecture-box">History Rewriting</div>
                    <div class="architecture-box">Verification</div>
                </div>
            </div>
        </section>

        <section id="installation">
            <h2>💾 Installation & Setup</h2>

            <h3>📥 From Release Binaries</h3>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code># Download the latest release for your platform
wget https://github.com/rohansen856/git-editor/releases/latest/download/git-editor-linux-x86_64.tar.gz
tar -xzf git-editor-linux-x86_64.tar.gz
sudo mv git-editor-linux-x86_64 /usr/local/bin/git-editor

# Verify installation
git-editor --help</code></pre>
            </div>

            <h3>🔨 From Source</h3>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code># Prerequisites: Rust 1.87+ and a C compiler (libgit2 is built from source)
rustup update stable

# Clone and build
git clone https://github.com/rohansen856/git-editor.git
cd git-editor

# Build release binary
cargo build --release

# Install globally
sudo cp target/release/git-editor /usr/local/bin/

# Or use cargo install
cargo install --path .</code></pre>
            </div>

            <h3>🐳 Docker Usage</h3>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code># Build Docker image
docker build -t git-editor .

# Run with repository mounted (-it is required: every prompt needs a TTY).
# The image runs as root; on Linux with rootful Docker, pass your uid so that
# libgit2's repository-ownership check passes and no root-owned files are written:
docker run -it --user "$(id -u):$(id -g)" -e HOME=/tmp \
  -v /path/to/repo:/workspace git-editor --repo-path /workspace -s</code></pre>
            </div>

            <h3>📋 System Requirements</h3>
            <div class="command-section">
                <ul>
                    <li><strong>Operating System:</strong> Linux, macOS, Windows</li>
                    <li><strong>Memory:</strong> Minimum 100MB RAM</li>
                    <li><strong>Storage:</strong> 50MB for binary + temporary space for repository cloning</li>
                    <li><strong>Git:</strong> Not required at runtime: repositories, configuration and clones are handled by the bundled libgit2</li>
                    <li><strong>Network:</strong> Required only for Git URL cloning (docs are local HTML)</li>
                </ul>
            </div>
        </section>

        <section id="operation-modes">
            <h2>🚀 Operation Modes</h2>
            <p>Git Editor operates in distinct modes, each optimized for specific use cases:</p>

            <table>
                <thead>
                    <tr>
                        <th>Mode</th>
                        <th>Primary Flag</th>
                        <th>Description</th>
                        <th>Use Case</th>
                        <th>Required Args</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><span class="badge badge-primary">Full Rewrite</span></td>
                        <td><em>Default</em></td>
                        <td>Complete repository history rewriting</td>
                        <td>Bulk timestamp and author updates</td>
                        <td>name, email, begin, end</td>
                    </tr>
                    <tr>
                        <td><span class="badge badge-success">Show History</span></td>
                        <td><code>-s, --show-history</code></td>
                        <td>Display commit history without modifications</td>
                        <td>Repository analysis and planning</td>
                        <td>repo-path only</td>
                    </tr>
                    <tr>
                        <td><span class="badge badge-warning">Pick Specific</span></td>
                        <td><code>-p, --pick-specific-commits</code></td>
                        <td>Interactive individual commit selection</td>
                        <td>Targeted commit modifications</td>
                        <td>repo-path only</td>
                    </tr>
                    <tr>
                        <td><span class="badge badge-warning">Range Edit</span></td>
                        <td><code>-x, --range</code></td>
                        <td>Select and edit commit ranges</td>
                        <td>Batch editing of consecutive commits</td>
                        <td>repo-path only</td>
                    </tr>
                    <tr>
                        <td><span class="badge badge-danger">Simulation</span></td>
                        <td><code>--simulate</code></td>
                        <td>Preview changes without applying</td>
                        <td>Safe testing and validation</td>
                        <td>Modifier for full rewrite, <code>-p</code> and <code>-x</code></td>
                    </tr>
                    <tr>
                        <td><span class="badge badge-info">Documentation</span></td>
                        <td><code>--docs</code></td>
                        <td>Open comprehensive documentation</td>
                        <td>Help and reference</td>
                        <td>None</td>
                    </tr>
                </tbody>
            </table>

            <h3>🔄 Mode Priority System</h3>
            <div class="info">
                <p><strong>Precedence Order (highest to lowest):</strong></p>
                <ol>
                    <li><code>--docs</code> - Always takes precedence</li>
                    <li><code>--simulate</code> - Dry-run preview (full rewrite path)</li>
                    <li><code>--range</code> (<code>-x</code>) - Range-based editing</li>
                    <li><code>--pick-specific-commits</code> (<code>-p</code>) - Interactive single-commit selection</li>
                    <li><code>--show-history</code> (<code>-s</code>) - Read-only history display</li>
                    <li>Full Rewrite - Default mode</li>
                </ol>
            </div>
        </section>

        <section id="command-reference">
            <h2>📖 Complete Command Reference</h2>

            <h3>🔧 Core Arguments</h3>
            <table>
                <thead>
                    <tr>
                        <th>Argument</th>
                        <th>Short</th>
                        <th>Type</th>
                        <th>Description</th>
                        <th>Example</th>
                        <th>Required</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>--repo-path</code></td>
                        <td><code>-r</code></td>
                        <td>String</td>
                        <td>Local path or Git URL to repository</td>
                        <td><code>-r /path/to/repo</code><br><code>-r https://github.com/user/repo.git</code></td>
                        <td>❌ (defaults to ./)</td>
                    </tr>
                    <tr>
                        <td><code>--email</code></td>
                        <td>-</td>
                        <td>Email</td>
                        <td>New author email (full rewrite, <code>-p --commit</code>, <code>-x --select</code>)</td>
                        <td><code>--email user@example.com</code></td>
                        <td>Full rewrite (prompted if missing)</td>
                    </tr>
                    <tr>
                        <td><code>--name</code></td>
                        <td><code>-n</code></td>
                        <td>String</td>
                        <td>New author name</td>
                        <td><code>-n "John Doe"</code></td>
                        <td>Full rewrite (prompted if missing)</td>
                    </tr>
                    <tr>
                        <td><code>--begin</code></td>
                        <td><code>-b</code></td>
                        <td>DateTime</td>
                        <td>First new date: <code>YYYY-MM-DD HH:MM:SS</code> (UTC), optionally with an offset such as <code>+05:30</code>, or RFC 3339</td>
                        <td><code>-b "2023-01-01 09:00:00 +05:30"</code></td>
                        <td>Full rewrite unless <code>--keep-dates</code></td>
                    </tr>
                    <tr>
                        <td><code>--end</code></td>
                        <td><code>-e</code></td>
                        <td>DateTime</td>
                        <td>Last new date (same formats)</td>
                        <td><code>-e "2023-12-31 17:00:00"</code></td>
                        <td>Full rewrite unless <code>--keep-dates</code></td>
                    </tr>
                    <tr>
                        <td><code>--skip-range-check</code></td>
                        <td>-</td>
                        <td>Flag</td>
                        <td>Allow ranges shorter than 3h per commit: random gaps of at least 5 minutes, or even spacing when that does not fit (never duplicate seconds)</td>
                        <td><code>--skip-range-check</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--keep-dates</code></td>
                        <td>-</td>
                        <td>Flag</td>
                        <td>Full rewrite: keep every commit's original date and time zone</td>
                        <td><code>--keep-dates</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--committer</code></td>
                        <td>-</td>
                        <td>Enum</td>
                        <td><code>match-author</code> (default): committer follows the edited author fields; <code>keep</code>: committer unchanged</td>
                        <td><code>--committer keep</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--commit</code></td>
                        <td>-</td>
                        <td>String</td>
                        <td>With <code>-p</code>: commit number (1 = newest, as listed by <code>-s</code>) or hash prefix, no menu</td>
                        <td><code>-p --commit 3</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--set-date</code> / <code>--set-message</code></td>
                        <td>-</td>
                        <td>String</td>
                        <td>With <code>-p --commit</code>: new author date / new message</td>
                        <td><code>--set-message "Fix typo"</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--select</code></td>
                        <td>-</td>
                        <td>Range</td>
                        <td>With <code>-x</code>: <code>N-M</code>, <code>N</code> or <code>*</code>, no table; combine with <code>--name</code>, <code>--email</code>, <code>--begin</code>/<code>--end</code></td>
                        <td><code>-x --select 2-5</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--yes</code></td>
                        <td><code>-y</code></td>
                        <td>Flag</td>
                        <td>Confirm automatically (scripts and agents)</td>
                        <td><code>--yes</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--json</code></td>
                        <td>-</td>
                        <td>Flag</td>
                        <td>Print one JSON document on stdout (history, preview, result or error); progress goes to stderr</td>
                        <td><code>-s --json</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--clone-dir</code></td>
                        <td>-</td>
                        <td>Path</td>
                        <td>When <code>--repo-path</code> is a URL, keep the clone in this directory (required to rewrite a URL)</td>
                        <td><code>--clone-dir ./repo-copy</code></td>
                        <td>❌</td>
                    </tr>
                    <tr>
                        <td><code>--docs-out</code></td>
                        <td>-</td>
                        <td>Path</td>
                        <td>With <code>--docs</code>: write the HTML to this file</td>
                        <td><code>--docs --docs-out docs.html</code></td>
                        <td>❌</td>
                    </tr>
                </tbody>
            </table>

            <h3>🎛️ Mode Flags</h3>
            <table>
                <thead>
                    <tr>
                        <th>Flag</th>
                        <th>Short</th>
                        <th>Description</th>
                        <th>Conflicts With</th>
                        <th>Additional Options</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>--show-history</code></td>
                        <td><code>-s</code></td>
                        <td>Display repository commit history</td>
                        <td>Other mode flags (<code>-s</code>, <code>-p</code>, <code>-x</code>, <code>--docs</code>): rejected</td>
                        <td>None</td>
                    </tr>
                    <tr>
                        <td><code>--pick-specific-commits</code></td>
                        <td><code>-p</code></td>
                        <td>Interactive commit selection</td>
                        <td>Other mode flags (<code>-s</code>, <code>-p</code>, <code>-x</code>, <code>--docs</code>): rejected</td>
                        <td>None</td>
                    </tr>
                    <tr>
                        <td><code>--range</code></td>
                        <td><code>-x</code></td>
                        <td>Range-based commit editing</td>
                        <td>Other mode flags (<code>-s</code>, <code>-p</code>, <code>-x</code>, <code>--docs</code>): rejected</td>
                        <td><code>--message</code>, <code>--author</code>, <code>--time</code></td>
                    </tr>
                    <tr>
                        <td><code>--simulate</code></td>
                        <td>-</td>
                        <td>Dry-run mode (preview only)</td>
                        <td><code>-s</code>, <code>--docs</code></td>
                        <td><code>--show-diff</code></td>
                    </tr>
                    <tr>
                        <td><code>--docs</code></td>
                        <td>-</td>
                        <td>Open documentation in browser</td>
                        <td>Every other mode and <code>--simulate</code>: rejected</td>
                        <td>None</td>
                    </tr>
                </tbody>
            </table>

            <h3>⚙️ Range Mode Modifiers</h3>
            <div class="command-section">
                <p>These flags work exclusively with <code>--range</code> mode:</p>
                <table>
                    <thead>
                        <tr>
                            <th>Flag</th>
                            <th>Description</th>
                            <th>Effect</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><code>--message</code></td>
                            <td>Edit only commit messages</td>
                            <td>Author name/email and timestamp fields are not editable; author, committer and dates stay untouched</td>
                        </tr>
                        <tr>
                            <td><code>--author</code></td>
                            <td>Edit only author information</td>
                            <td>Message and timestamp fields are not editable</td>
                        </tr>
                        <tr>
                            <td><code>--time</code></td>
                            <td>Edit only timestamps</td>
                            <td>Message and author fields are not editable</td>
                        </tr>
                    </tbody>
                </table>
                <div class="info">
                    <strong>Note:</strong> If no modifier flags are specified with <code>--range</code>, all fields (message, author, timestamp) will be editable.
                </div>
            </div>

            <h3>🔍 Simulation Options</h3>
            <table>
                <thead>
                    <tr>
                        <th>Flag</th>
                        <th>Description</th>
                        <th>Output</th>
                        <th>Requires</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>--show-diff</code></td>
                        <td>Show detailed change preview</td>
                        <td>Before/after comparison for each commit</td>
                        <td>Any preview (dry run or before confirming)</td>
                    </tr>
                </tbody>
            </table>
        </section>

        <section id="technical-details">
            <h2>🔬 Technical Implementation</h2>

            <h3>📊 Date Distribution Algorithm</h3>
            <div class="info">
                <p>Git Editor distributes timestamps with random weighted gaps while preserving commit order:</p>
                <ul>
                    <li><strong>Chronological Preservation:</strong> the oldest commit gets <code>--begin</code>, the newest gets exactly <code>--end</code>, and dates strictly increase in between</li>
                    <li><strong>Minimum Gap:</strong> At least 3 hours between commits by default (validated against <code>--begin</code>/<code>--end</code>)</li>
                    <li><strong>Random Weights:</strong> Gaps are randomized across the available slack, in whole seconds</li>
                    <li><strong><code>--skip-range-check</code>:</strong> for ranges shorter than 3h × (commits − 1): gaps of at least 5 minutes, or even spacing (at least one second apart) if 5 minutes do not fit</li>
                    <li><strong>Time zone:</strong> dates without an offset are UTC; with an offset (e.g. <code>+05:30</code>) the generated dates are written in that zone</li>
                    <li><strong>Keep dates:</strong> <code>--keep-dates</code> (or pressing Enter on both prompted date defaults) keeps every commit's own date and offset and changes only the identity</li>
                </ul>
            </div>

            <h3>🔐 Git Operations & Safety</h3>
            <div class="command-section">
                <h4>Repository Validation</h4>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Git Editor performs these validations:
1. The path exists and is (inside) a Git repository; bare repositories work
2. Email / name / dates are valid; names and emails may not contain &lt; &gt; or newlines
3. Date range large enough for commit count (unless --skip-range-check)
4. HEAD is a branch with commits (detached or unborn HEAD is refused)
5. The branch did not move since the preview (otherwise nothing is written)</code></pre>
                </div>

                <h4>History Rewriting Process</h4>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Internal rewriting workflow:
1. Build a plan: edits keyed by commit id (previews render the same plan)
2. Walk HEAD history oldest-first
3. Reuse every commit that has no edit and unchanged parents (same id, signature kept)
4. Rebuild the others from their raw object: new parents, edited author fields,
   committer per --committer; encoding, mergetag, other headers, raw message
   bytes and time-zone offsets are kept; signatures are dropped (they would not verify)
5. Rewrite matching Signed-off-by / Co-authored-by / Authored-by lines in the trailer block
6. Save the old tip as refs/git-editor/backup/&lt;branch&gt;
7. Move refs/heads/&lt;branch&gt; with a compare-and-swap; report other refs still on the old history

# Undo:
git reset --keep refs/git-editor/backup/&lt;branch&gt;</code></pre>
                </div>
            </div>

            <h3>🤖 Automation &amp; Agents</h3>
            <div class="info">
                <ul>
                    <li><strong>Non-interactive:</strong> <code>-p --commit</code> and <code>-x --select</code> replace the menu and table; <code>--yes</code> confirms. Without a terminal, prompts read plain lines from stdin and fail (instead of hanging) when stdin is closed.</li>
                    <li><strong>JSON:</strong> <code>--json</code> prints one document on stdout: the history, the preview, the rewrite result (old/new ids, backup ref, stale refs) or the error.</li>
                    <li><strong>Workflow:</strong> <code>-s --json</code> → <code>--simulate --json</code> → <code>--yes --json</code>. See <code>AGENTS.md</code> in the repository.</li>
                    <li><strong>Colors</strong> are disabled automatically when output is not a terminal.</li>
                </ul>
            </div>

            <h3>⌨️ Interactive Controls</h3>
            <div class="command-section">
                <ul>
                    <li><strong>Prompts:</strong> Esc or Ctrl+C cancels (exit code 130); confirmations accept <code>y</code> or <code>yes</code>.</li>
                    <li><strong>Range table:</strong> arrow keys or h/j/k/l to move, Enter to edit a cell, Esc to save &amp; exit, <code>q</code> or Ctrl+C to cancel without saving. Long tables scroll; validation errors are shown below the table.</li>
                    <li><strong>Pick mode messages:</strong> finish a new message with a line containing only <code>.</code>; blank lines and indentation are kept.</li>
                    <li><strong>Dates in tables</strong> are shown in UTC; edits accept an offset such as <code>+05:30</code>.</li>
                </ul>
            </div>

            <h3>🌐 Git URL Support</h3>
            <div class="feature-grid">
                <div class="feature-card">
                    <h4>📡 Supported Protocols</h4>
                    <ul>
                        <li>HTTPS: <code>https://github.com/user/repo.git</code></li>
                        <li>SSH: <code>git@github.com:user/repo.git</code> (via ssh-agent)</li>
                        <li>HTTP: <code>http://example.com/repo.git</code></li>
                        <li>git: <code>git://example.com/repo.git</code></li>
                    </ul>
                </div>
                <div class="feature-card">
                    <h4>🔄 Clone Behavior</h4>
                    <ul>
                        <li>Read-only modes (<code>-s</code>, <code>--simulate</code>) use a temporary clone removed on exit</li>
                        <li>Rewriting a URL requires <code>--clone-dir &lt;DIR&gt;</code>; push from that directory afterwards</li>
                        <li>Authentication via ssh-agent and Git credential helpers</li>
                        <li>Credentials embedded in a URL are masked in all output</li>
                    </ul>
                </div>
            </div>

            <h3>⚡ Performance Characteristics</h3>
            <table>
                <thead>
                    <tr>
                        <th>Repository Size</th>
                        <th>Commit Count</th>
                        <th>Processing Time</th>
                        <th>Memory Usage</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Small (&lt;10MB)</td>
                        <td>&lt;1,000</td>
                        <td>&lt;10 seconds</td>
                        <td>&lt;50MB</td>
                    </tr>
                    <tr>
                        <td>Medium (10-100MB)</td>
                        <td>1,000-10,000</td>
                        <td>10-60 seconds</td>
                        <td>50-200MB</td>
                    </tr>
                    <tr>
                        <td>Large (100MB-1GB)</td>
                        <td>10,000-100,000</td>
                        <td>1-10 minutes</td>
                        <td>200MB-1GB</td>
                    </tr>
                    <tr>
                        <td>Enterprise (&gt;1GB)</td>
                        <td>&gt;100,000</td>
                        <td>&gt;10 minutes</td>
                        <td>&gt;1GB</td>
                    </tr>
                </tbody>
            </table>
        </section>

        <section id="examples">
            <h2>💡 Usage Examples & Workflows</h2>

            <h3>🎯 Basic Operations</h3>

            <h4>📚 Open Documentation</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code>git-editor --docs</code></pre>
                </div>
                <p>Opens this comprehensive documentation in your default browser.</p>
            </div>

            <h4>📖 Repository Analysis</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Show history of current directory
git-editor -s

# Analyze specific repository
git-editor --repo-path /path/to/repo --show-history

# Analyze remote repository
git-editor -r https://github.com/user/repo.git -s</code></pre>
                </div>
                <p>Displays comprehensive commit history without making any changes.</p>
            </div>

            <h3>🔄 Complete History Rewriting</h3>

            <h4>📝 Basic Full Rewrite</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code>git-editor \
  --name "John Doe" \
  --email john@example.com \
  --begin "2023-01-01 09:00:00" \
  --end "2023-12-31 17:00:00"</code></pre>
                </div>
                <p>Rewrites all commits reachable from <code>HEAD</code> with new author info and timestamps distributed between the specified dates, then moves the current branch to the new tip.</p>
            </div>

            <h4>🌍 Remote Repository Rewrite</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Clone into a directory you keep, rewrite it, then push from it
git-editor \
  --repo-path https://github.com/user/repo.git \
  --clone-dir ./repo-rewritten \
  --name "Corporate Identity" \
  --email corporate@company.com \
  --begin "2023-06-01 08:00:00" \
  --end "2023-06-30 18:00:00"
git -C ./repo-rewritten push --force-with-lease</code></pre>
                </div>
                <p>Without <code>--clone-dir</code>, a URL is cloned into a temporary directory that is removed on exit; that is fine for <code>-s</code> and <code>--simulate</code>, and write modes refuse to run so a rewrite is never silently lost.</p>
            </div>

            <h3>🎯 Targeted Editing</h3>

            <h4>🔍 Interactive Commit Selection</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Interactive commit picker
git-editor --pick-specific-commits

# With specific repository
git-editor -r /path/to/repo --pick-specific-commits</code></pre>
                </div>
                <p>Provides an interactive interface to select and edit individual commits.</p>
            </div>

            <h4>📊 Range-Based Editing</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Edit all fields in a range
git-editor --range

# Edit only commit messages
git-editor --range --message

# Edit only author information
git-editor --range --author

# Edit only timestamps
git-editor --range --time

# Multiple field editing
git-editor --range --message --author</code></pre>
                </div>
                <p>Select a range of commits (e.g., commits 5-11) and edit specific fields.</p>
            </div>

            <h3>🔍 Simulation & Preview</h3>

            <h4>🧪 Dry-Run Testing</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Basic simulation
git-editor --simulate \
  --name "Test User" \
  --email test@example.com \
  --begin "2023-01-01 09:00:00" \
  --end "2023-01-31 17:00:00"

# Detailed diff preview
git-editor --simulate --show-diff \
  --name "John Doe" \
  --email john@example.com \
  --begin "2023-06-01 08:00:00" \
  --end "2023-06-30 18:00:00"</code></pre>
                </div>
                <p>Previews all changes with detailed diffs without applying them.</p>
            </div>

            <h4>🔄 Simulation with Other Modes</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Preview a pick-mode edit (menu or flags)
git-editor --simulate -p --commit 2 --set-message "Reworded"

# Preview a range edit made in the table, or from flags
git-editor --simulate --range --message
git-editor --simulate --show-diff -x --select 1-3 --name "Jane"</code></pre>
                </div>
                <p>With <code>-p</code> and <code>-x</code>, simulation runs the normal selection and editing, shows exactly what would be written, and stops before writing.</p>
            </div>

            <h3>🔧 Advanced Workflows</h3>

            <h4>🎭 Privacy & Anonymization</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Anonymize commit history
git-editor \
  --name "Anonymous Contributor" \
  --email anonymous@privacy.local \
  --begin "2023-01-01 00:00:00" \
  --end "2023-12-31 23:59:59"

# Corporate identity standardization
git-editor \
  --name "Development Team" \
  --email dev-team@company.com \
  --begin "2023-04-01 09:00:00" \
  --end "2023-04-30 17:00:00"</code></pre>
                </div>
                <p>Standardize or anonymize commit authorship for privacy or corporate compliance.</p>
            </div>

            <h4>📅 Timeline Compression/Expansion</h4>
            <div class="example">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Compress 6 months of work into 1 month
git-editor \
  --name "Rapid Developer" \
  --email rapid@dev.com \
  --begin "2023-11-01 08:00:00" \
  --end "2023-11-30 20:00:00"

# Expand 1 week into 3 months
git-editor \
  --name "Consistent Contributor" \
  --email consistent@dev.com \
  --begin "2023-09-01 09:00:00" \
  --end "2023-11-30 17:00:00"</code></pre>
                </div>
                <p>Adjust project timelines for demos, portfolio presentation, or analysis.</p>
            </div>
        </section>

        <section id="advanced-features">
            <h2>🔧 Advanced Features</h2>

            <h3>🧠 Timestamp Distribution</h3>
            <div class="info">
                <p>Timestamps are generated with random weighted gaps inside <code>--begin</code>/<code>--end</code>, keeping commit order. Default rule: at least 3 hours between commits. Use <code>--skip-range-check</code> for tighter packing (5-minute minimum gap).</p>
            </div>

            <h3>🔄 Interactive Features</h3>

            <h4>🎮 Pick Specific Commits Interface</h4>
            <div class="command-section">
                <p>The interactive commit picker provides:</p>
                <ul>
                    <li><strong>Numbered Commit List:</strong> Index, short hash, date, author, message preview</li>
                    <li><strong>Single Selection:</strong> Enter a commit number to edit</li>
                    <li><strong>Field Prompts:</strong> Edit name, email, timestamp, and/or message for that commit</li>
                    <li><strong>Confirmation:</strong> Review changes before rewriting descendants as needed</li>
                </ul>
            </div>

            <h4>📊 Range Selection Interface</h4>
            <div class="command-section">
                <p>Range editing supports:</p>
                <ul>
                    <li><strong>Commit Numbering:</strong> Display commits with sequential numbers</li>
                    <li><strong>Range Syntax:</strong> <code>start-end</code> (e.g. <code>5-11</code>) or <code>*</code> for all commits</li>
                    <li><strong>Field Selection:</strong> Limit columns with <code>--message</code>, <code>--author</code>, and/or <code>--time</code></li>
                    <li><strong>Crossterm TUI:</strong> Spreadsheet-style editor (arrow keys, edit cells, confirm to apply)</li>
                </ul>
            </div>

            <h3>🔍 Simulation & Analysis</h3>
            <div class="info">
                <p><strong>Simulation Mode provides:</strong></p>
                <ul>
                    <li><strong>Change Summary:</strong> Shows how many commits would be affected</li>
                    <li><strong>Validation:</strong> Same email, name and date checks as a real rewrite</li>
                    <li><strong>Author Preview:</strong> Planned author/email updates</li>
                    <li><strong>Detailed Diff:</strong> Per-commit before/after with <code>--show-diff</code></li>
                    <li><strong>No Mutation:</strong> Repository is left unchanged</li>
                </ul>
            </div>

            <h3>🌐 Git URL Processing</h3>
            <div class="command-section">
                <h4>Automatic Repository Detection</h4>
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># Supported URL formats:
https://github.com/user/repo.git
https://github.com/user/repo
git@github.com:user/repo.git
https://gitlab.com/user/repo.git
https://bitbucket.org/user/repo.git

# URL normalization and validation
# Automatic .git suffix handling
# Repository name extraction for display (the temporary directory itself has a random name)</code></pre>
                </div>
            </div>
        </section>

        <section id="internals">
            <h2>🏗️ Internal Architecture</h2>

            <h3>📁 Project Structure</h3>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code>git-editor/
├── src/
│   ├── main.rs              # Entry point and mode dispatch
│   ├── lib.rs               # Library re-exports (args, rewrite, utils)
│   ├── args.rs              # CLI argument parsing (clap)
│   ├── docs.rs              # Documentation generation
│   ├── rewrite/
│   │   ├── mod.rs           # Rewrite module exports
│   │   ├── rewrite_all.rs   # Full history rewriting
│   │   ├── rewrite_specific.rs # Interactive commit selection
│   │   └── rewrite_range.rs # Range-based editing (crossterm TUI)
│   └── utils/
│       ├── mod.rs           # Utility module exports
│       ├── types.rs         # Common types and aliases
│       ├── validator.rs     # Input validation
│       ├── datetime.rs      # Timestamp generation
│       ├── commit_history.rs# Git operations
│       ├── prompt.rs        # User interaction
│       ├── git_clone.rs     # Repository cloning
│       ├── git_config.rs    # Git configuration
│       ├── message_trailers.rs # Signed-off-by / Co-authored-by rewrites
│       ├── simulation.rs    # Dry-run functionality
│       └── help.rs          # Custom help text (unused; clap --help is primary)
├── docs/
│   └── template.html        # Documentation template
├── tests/
│   └── integration_tests.rs # Integration test suite
├── Cargo.toml              # Dependencies and metadata
├── Dockerfile              # Container configuration
└── Makefile                # Build automation</code></pre>
            </div>

            <h3>🔗 Key Dependencies</h3>
            <table>
                <thead>
                    <tr>
                        <th>Crate</th>
                        <th>Version</th>
                        <th>Purpose</th>
                        <th>Features Used</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>git2</code></td>
                        <td>0.20+</td>
                        <td>Git repository operations</td>
                        <td>Repository access, commit manipulation</td>
                    </tr>
                    <tr>
                        <td><code>clap</code></td>
                        <td>4.5+</td>
                        <td>Command-line argument parsing</td>
                        <td>Derive API, help generation</td>
                    </tr>
                    <tr>
                        <td><code>chrono</code></td>
                        <td>0.4+</td>
                        <td>Date/time handling</td>
                        <td>DateTime parsing (naive UTC; no time-zone handling)</td>
                    </tr>
                    <tr>
                        <td><code>colored</code></td>
                        <td>3.0+</td>
                        <td>Terminal output coloring</td>
                        <td>ANSI color codes, cross-platform</td>
                    </tr>
                    <tr>
                        <td><code>tempfile</code></td>
                        <td>3.20+</td>
                        <td>Temporary directory management</td>
                        <td>Auto-cleanup, secure temp files</td>
                    </tr>
                    <tr>
                        <td><code>open</code></td>
                        <td>5.0+</td>
                        <td>Browser launching</td>
                        <td>Cross-platform file opening</td>
                    </tr>
                    <tr>
                        <td><code>url</code></td>
                        <td>2.5+</td>
                        <td>URL parsing and validation</td>
                        <td>Git URL parsing</td>
                    </tr>
                    <tr>
                        <td><code>regex</code></td>
                        <td>1.11+</td>
                        <td>Pattern matching</td>
                        <td>Email validation, date parsing</td>
                    </tr>
                </tbody>
            </table>

            <h3>🏛️ Architecture Patterns</h3>
            <div class="feature-grid">
                <div class="feature-card">
                    <h4>🎯 Error Handling</h4>
                    <ul>
                        <li>Custom Result type alias</li>
                        <li>Comprehensive error propagation</li>
                        <li>User-friendly error messages</li>
                        <li>Graceful degradation</li>
                    </ul>
                </div>
                <div class="feature-card">
                    <h4>🔧 Modularity</h4>
                    <ul>
                        <li>Separate modules by responsibility</li>
                        <li>Clear interface boundaries</li>
                        <li>Reusable utility functions</li>
                        <li>Testable components</li>
                    </ul>
                </div>
            </div>

            <h3>🧪 Testing Strategy</h3>
            <div class="command-section">
                <table>
                    <thead>
                        <tr>
                            <th>Test Type</th>
                            <th>Count</th>
                            <th>Coverage</th>
                            <th>Purpose</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td><strong>Unit Tests</strong></td>
                            <td>100</td>
                            <td>Core logic</td>
                            <td>Parsing, validation, dates, trailers, table editor, JSON</td>
                        </tr>
                        <tr>
                            <td><strong>Engine Tests</strong></td>
                            <td>12</td>
                            <td>Rewrite engine</td>
                            <td>Commit reuse, preserved headers/offsets, committer modes, merges, backup refs, git fsck</td>
                        </tr>
                        <tr>
                            <td><strong>End-to-End Tests</strong></td>
                            <td>11</td>
                            <td>CLI binary</td>
                            <td>Non-interactive runs with --yes/--json against throwaway repositories</td>
                        </tr>
                        <tr>
                            <td><strong>Integration Tests</strong></td>
                            <td>21</td>
                            <td>Library flows</td>
                            <td>History, timestamps, validation, docs, argument parsing</td>
                        </tr>
                        <tr>
                            <td><strong>Doc Tests</strong></td>
                            <td>0</td>
                            <td>Documentation</td>
                            <td>Code example validation</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </section>

        <section id="development">
            <h2>🛠️ Development Guide</h2>

            <h3>🚀 Build Commands</h3>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code># Development build (fast compilation)
cargo build

# Release build (optimized)
cargo build --release

# Run with arguments
cargo run -- --help
cargo run -- --repo-path . -s

# Watch mode for development
cargo watch -x "run -- --docs"</code></pre>
            </div>

            <h3>🧪 Testing</h3>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code># Run all tests (unit, engine, end-to-end, integration)
cargo test

# Run unit tests only
cargo test --lib

# Run the rewrite engine and end-to-end suites
cargo test --test engine
cargo test --test e2e

# Run integration tests only
cargo test --test integration_tests

# Run specific test with output
cargo test --test integration_tests test_show_history_mode_integration -- --nocapture

# Run tests without browser opening (for development)
GIT_EDITOR_NO_BROWSER=1 cargo test --all</code></pre>
            </div>

            <h3>✨ Code Quality</h3>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code># Format code
cargo fmt

# Check formatting without changes
cargo fmt --check

# Run linter
cargo clippy

# Run linter with strict warnings (CI requirement)
cargo clippy --all-targets --all-features -- -D warnings

# Security audit
cargo audit

# Check for outdated dependencies
cargo outdated</code></pre>
            </div>

            <h3>📦 Makefile Commands</h3>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code># Build release binary
make build

# Run all tests
make test

# Check code formatting
make fmt

# Run clippy linter
make lint

# Run with default parameters
make run

# Run with custom environment variables
make run-custom

# Clean build artifacts
make clean

# Build Docker image
make docker-build

# Run in Docker container
make docker-run

# Install binary to /usr/local/bin
make install

# Show all available commands
make help</code></pre>
            </div>

            <h3>🔄 Development Workflow</h3>
            <div class="command-section">
                <ol>
                    <li><strong>Setup:</strong> Clone repository and run <code>cargo build</code></li>
                    <li><strong>Development:</strong> Make changes and test with <code>cargo run</code></li>
                    <li><strong>Testing:</strong> Run <code>cargo test</code> to ensure no regressions</li>
                    <li><strong>Quality:</strong> Check with <code>cargo fmt</code> and <code>cargo clippy</code></li>
                    <li><strong>Integration:</strong> Test end-to-end with <code>make test</code></li>
                    <li><strong>Documentation:</strong> Update docs and test with <code>--docs</code></li>
                </ol>
            </div>

            <h3>🎯 Contribution Guidelines</h3>
            <div class="info">
                <ul>
                    <li><strong>Code Style:</strong> Follow Rust standard formatting (rustfmt)</li>
                    <li><strong>Testing:</strong> Add tests for all new functionality</li>
                    <li><strong>Documentation:</strong> Update inline docs and this template</li>
                    <li><strong>Error Handling:</strong> Use the custom Result type consistently</li>
                    <li><strong>Performance:</strong> Consider memory usage for large repositories</li>
                </ul>
            </div>
        </section>

        <section id="troubleshooting">
            <h2>🔧 Troubleshooting & FAQ</h2>

            <h3>❗ Common Issues</h3>

            <h4>🔍 Repository Not Found</h4>
            <div class="danger">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code>Error: Invalid repository path or URL: /invalid/path
Error: Repository path does not contain a valid Git repository: /path</code></pre>
                </div>
                <p><strong>Solutions:</strong></p>
                <ul>
                    <li>Verify the repository path exists: <code>ls -la /path/to/repo</code></li>
                    <li>Ensure .git directory is present: <code>ls -la /path/to/repo/.git</code></li>
                    <li>Check permissions: <code>ls -ld /path/to/repo</code></li>
                    <li>For Git URLs, verify network connectivity and authentication</li>
                </ul>
            </div>

            <h4>🗓️ Invalid Date Format</h4>
            <div class="danger">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code>Error: Invalid start date format (expected YYYY-MM-DD HH:MM:SS): 2023-1-1</code></pre>
                </div>
                <p><strong>Solutions:</strong></p>
                <ul>
                    <li>Use exact format: <code>YYYY-MM-DD HH:MM:SS</code></li>
                    <li>Zero-pad single digits: <code>2023-01-01 09:00:00</code></li>
                    <li>Use 24-hour time format</li>
                    <li>Ensure end date is after start date</li>
                </ul>
            </div>

            <h4>📧 Email Validation Errors</h4>
            <div class="danger">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code>Error: Invalid email format: user@domain</code></pre>
                </div>
                <p><strong>Solutions:</strong></p>
                <ul>
                    <li>Include top-level domain: <code>user@domain.com</code></li>
                    <li>The validator is a simple pattern (<code>letters, digits, . _ % + -</code> before <code>@</code>, a domain with a dot), not full RFC 5322</li>
                    <li>Quoted local parts and spaces are not accepted</li>
                </ul>
            </div>

            <h4>🌐 Git URL Authentication</h4>
            <div class="warning">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code>Error: Failed to clone repository '&lt;url&gt;': authentication failed: no usable credentials from ssh-agent or git credential helpers</code></pre>
                </div>
                <p><strong>Solutions:</strong></p>
                <ul>
                    <li>SSH URLs: make sure your key is loaded (<code>ssh-add -l</code>)</li>
                    <li>HTTPS URLs: configure a credential helper (<code>git config --global credential.helper ...</code>)</li>
                    <li>Test with <code>git clone</code> first; credentials embedded in URLs are masked in output</li>
                </ul>
            </div>

            <h3>🔧 Performance Issues</h3>

            <h4>⚡ Large Repository Optimization</h4>
            <div class="command-section">
                <div class="code-block">
                    <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                    <pre><code># For large repositories, consider:

# 1. Use simulation mode first
git-editor --simulate --show-diff [other-args]

# 2. Process in smaller ranges
git-editor --range --message  # Edit specific fields only

# 3. Monitor system resources
htop  # Watch memory and CPU usage

# 4. Ensure sufficient disk space
df -h  # Check available space</code></pre>
                </div>
            </div>

            <h4>💾 Memory Management</h4>
            <div class="info">
                <p><strong>Memory optimization tips:</strong></p>
                <ul>
                    <li>Close other applications before processing large repos</li>
                    <li>Use range mode for selective editing instead of full rewrite</li>
                    <li>Consider splitting very large repositories</li>
                    <li>Monitor swap usage during processing</li>
                </ul>
            </div>

            <h3>❓ Frequently Asked Questions</h3>

            <div class="command-section">
                <h4>🔄 Can I undo changes after rewriting history?</h4>
                <p><strong>Answer:</strong> History rewriting is permanent. However, you can:</p>
                <ul>
                    <li>Every rewrite saves the old tip: <code>git reset --keep refs/git-editor/backup/&lt;branch&gt;</code></li>
                    <li>Use Git reflog to find previous HEAD positions</li>
                    <li>Restore from backups if available</li>
                    <li>Use simulation mode to preview changes first</li>
                </ul>
            </div>

            <div class="command-section">
                <h4>🌍 Does this work with remote repositories?</h4>
                <p><strong>Answer:</strong> Yes, Git Editor can clone and process remote repositories:</p>
                <ul>
                    <li>Supports HTTPS, SSH, HTTP and git:// URLs</li>
                    <li>Authenticates with ssh-agent and Git credential helpers</li>
                    <li>Read-only modes use a temporary clone; rewrites need <code>--clone-dir</code></li>
                    <li>Push the rewritten clone yourself with <code>git push --force-with-lease</code></li>
                </ul>
            </div>

            <div class="command-section">
                <h4>🏢 Is this safe for production repositories?</h4>
                <p><strong>Answer:</strong> Use with extreme caution:</p>
                <ul>
                    <li>Always test on a backup first</li>
                    <li>Use simulation mode for validation</li>
                    <li>Coordinate with team members before rewriting shared history</li>
                    <li>Consider impact on CI/CD pipelines and deployment history</li>
                </ul>
            </div>

            <h3>🆘 Getting Help</h3>
            <div class="command-section">
                <p>If you encounter issues:</p>
                <ul>
                    <li>📖 Check this documentation first: <code>git-editor --docs</code></li>
                    <li>🐛 Search existing issues: <a href="https://github.com/rohansen856/git-editor/issues">GitHub Issues</a></li>
                    <li>📚 Review the project README: <a href="https://github.com/rohansen856/git-editor">Project Repository</a></li>
                    <li>🆕 Create a new issue with:
                        <ul>
                            <li>Exact command that failed</li>
                            <li>Complete error message</li>
                            <li>Operating system and Git version</li>
                            <li>Repository size and commit count (approximate)</li>
                        </ul>
                    </li>
                </ul>
            </div>
        </section>

        <section id="api-reference">
            <h2>📚 API Reference</h2>

            <h3>🔧 Core Library Surface</h3>

            <h4>📊 History</h4>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code>// Walk HEAD and optionally print history
pub fn get_commit_history(args: &Args, print: bool) -> Result&lt;Vec&lt;CommitInfo&gt;&gt;</code></pre>
            </div>

            <h4>⏰ Timestamp Generation</h4>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code>// Generate random-gap timestamps for full rewrite (mutates args if cloning)
pub fn generate_timestamps(args: &mut Args) -> Result&lt;Vec&lt;NaiveDateTime&gt;&gt;</code></pre>
            </div>

            <h4>🔄 History Rewriting</h4>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code>// Full repository history rewrite (timestamps from generate_timestamps)
pub fn rewrite_all_commits(args: &Args, timestamps: Vec&lt;NaiveDateTime&gt;) -> Result&lt;()&gt;

// Interactive single-commit selection and editing
pub fn rewrite_specific_commits(args: &Args) -> Result&lt;()&gt;

// Range-based commit editing (crossterm TUI)
pub fn rewrite_range_commits(args: &Args) -> Result&lt;()&gt;</code></pre>
            </div>

            <h3>📈 Data Structures</h3>

            <h4>💾 CommitInfo</h4>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code>pub struct CommitInfo {
    pub oid: git2::Oid,            // Full commit object id
    pub short_hash: String,        // Abbreviated hash
    pub timestamp: NaiveDateTime,  // Commit timestamp
    pub author_name: String,       // Author display name
    pub author_email: String,      // Author email address
    pub message: String,           // Commit message
    pub parent_count: usize,       // Number of parent commits
}</code></pre>
            </div>

            <h4>⚙️ EditOptions</h4>
            <div class="code-block">
                <button class="copy-btn" onclick="copyCode(this)">Copy</button>
                <pre><code>pub struct EditOptions {
    pub author_name: Option&lt;String&gt;,
    pub author_email: Option&lt;String&gt;,
    pub timestamp: Option&lt;NaiveDateTime&gt;,
    pub message: Option&lt;String&gt;,
}</code></pre>
            </div>

            <h3>🎛️ Configuration</h3>

            <h4>🔧 Environment Variables</h4>
            <table>
                <thead>
                    <tr>
                        <th>Variable</th>
                        <th>Purpose</th>
                        <th>Default</th>
                        <th>Example</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>GIT_EDITOR_NO_BROWSER</code></td>
                        <td>Disable browser opening for docs</td>
                        <td>Not set</td>
                        <td><code>GIT_EDITOR_NO_BROWSER=1</code></td>
                    </tr>
                    <tr>
                        <td><code>NO_BROWSER</code></td>
                        <td>Alternative browser disable flag</td>
                        <td>Not set</td>
                        <td><code>NO_BROWSER=1</code></td>
                    </tr>
                </tbody>
            </table>

            <h4>📋 Exit Codes</h4>
            <table>
                <thead>
                    <tr>
                        <th>Code</th>
                        <th>Meaning</th>
                        <th>Description</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td><code>0</code></td>
                        <td>Success</td>
                        <td>Operation completed (including "nothing to change")</td>
                    </tr>
                    <tr>
                        <td><code>1</code></td>
                        <td>Error</td>
                        <td>Any failure, printed as <code>Error: …</code> on stderr (or as a JSON error with <code>--json</code>)</td>
                    </tr>
                    <tr>
                        <td><code>2</code></td>
                        <td>Usage error</td>
                        <td>Invalid or conflicting arguments</td>
                    </tr>
                    <tr>
                        <td><code>130</code></td>
                        <td>Cancelled</td>
                        <td>Declined confirmation, Esc or Ctrl+C</td>
                    </tr>
                </tbody>
            </table>
        </section>

        <footer style="margin-top: 60px; padding-top: 40px; border-top: 2px solid #ddd; text-align: center; color: #666;">
            <div style="margin-bottom: 20px;">
                <h3 style="color: #34495e; margin-bottom: 15px;">🚀 Git Editor v{{VERSION}}</h3>
                <p style="font-size: 0.9em; margin-bottom: 10px;">Generated on {{DATE}}</p>
                <p style="font-size: 0.9em;">Made with ❤️ by <strong>Rohan Sen</strong></p>
            </div>
            <div style="font-size: 0.8em; color: #999;">
                <p>This documentation is embedded in the binary at build time and published to GitHub Pages on pushes to master.</p>
                <p>For the latest version, visit: <a href="https://github.com/rohansen856/git-editor">github.com/rohansen856/git-editor</a></p>
            </div>
        </footer>
    </div>

    <script>
        function copyCode(button) {
            const codeBlock = button.nextElementSibling.querySelector('code');
            const text = codeBlock.textContent;

            navigator.clipboard.writeText(text).then(() => {
                const originalText = button.textContent;
                button.textContent = 'Copied!';
                button.classList.add('copied');

                setTimeout(() => {
                    button.textContent = originalText;
                    button.classList.remove('copied');
                }, 2000);
            }).catch(err => {
                console.error('Failed to copy text: ', err);
                button.textContent = 'Copy Failed';
                setTimeout(() => {
                    button.textContent = 'Copy';
                }, 2000);
            });
        }

        // Add copy buttons to all code blocks that don't have them
        document.addEventListener('DOMContentLoaded', function() {
            const codeBlocks = document.querySelectorAll('pre:not(.code-block pre)');
            codeBlocks.forEach(pre => {
                if (!pre.parentElement.classList.contains('code-block')) {
                    const wrapper = document.createElement('div');
                    wrapper.className = 'code-block';
                    pre.parentNode.insertBefore(wrapper, pre);
                    wrapper.appendChild(pre);

                    const copyBtn = document.createElement('button');
                    copyBtn.className = 'copy-btn';
                    copyBtn.textContent = 'Copy';
                    copyBtn.onclick = function() { copyCode(this); };
                    wrapper.insertBefore(copyBtn, pre);
                }
            });
        });

        // Smooth scrolling for anchor links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                const target = document.querySelector(this.getAttribute('href'));
                if (target) {
                    target.scrollIntoView({
                        behavior: 'smooth',
                        block: 'start'
                    });
                }
            });
        });

        // Add section anchors for better navigation
        document.querySelectorAll('h2, h3').forEach(heading => {
            if (!heading.id) {
                heading.id = heading.textContent.toLowerCase()
                    .replace(/[^\w\s-]/g, '')
                    .replace(/\s+/g, '-');
            }
        });
    </script>
</body>

</html>