Skip to content

Commit 612878d

Browse files
add info comment mapping out git-chain
1 parent 728d121 commit 612878d

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

code/logic/myshell.c

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,105 @@
2424
*/
2525
#include "fossil/crabdb/myshell.h"
2626

27+
/**
28+
* @brief Implements the core logic for the Fossil BlueCrab .myshell file database.
29+
*
30+
* This file provides functions for managing a simple versioned key-value store
31+
* using the ".myshell" file format. It supports operations such as open, create,
32+
* close, put, get, delete, commit, branch, checkout, merge, revert, stage, unstage,
33+
* tag, log, backup, restore, error string conversion, and integrity checking.
34+
*
35+
* ## .myshell File Format Overview
36+
* - Each .myshell file is a plain text file with lines representing key-value pairs,
37+
* commit history, branches, tags, and staged changes.
38+
* - Key-value pairs are stored as: `key=value #hash=KEYHASH`
39+
* - `KEYHASH` is a 64-bit hash of the key for integrity verification.
40+
* - Commits are recorded as: `#commit HASH MESSAGE TIMESTAMP`
41+
* - Branches are recorded as: `#branch HASH BRANCHNAME`
42+
* - Tags are recorded as: `#tag HASH TAGNAME`
43+
* - Staged changes are recorded as: `#stage key=value #hash=KEYHASH`
44+
* - Merges are recorded as: `#merge HASH SOURCEBRANCH MESSAGE TIMESTAMP`
45+
* - Backups include a header: `#backup_hash=HASH`
46+
*
47+
* ## Sample .myshell File Contents
48+
* ```
49+
* key1=value1 #hash=0123456789abcdef
50+
* key2=value2 #hash=abcdef0123456789
51+
* #commit 0123456789abcdef Initial commit 1712345678
52+
* #branch 89abcdef01234567 main
53+
* #tag 0123456789abcdef v1.0
54+
* #stage key3=value3 #hash=123456789abcdef0
55+
* #merge 89abcdef01234567 feature "Merge feature branch" 1712345680
56+
* ```
57+
*
58+
* ## More Sample .myshell File Contents
59+
* ```
60+
* username=alice #hash=1a2b3c4d5e6f7890
61+
* password=secret #hash=0f1e2d3c4b5a6978
62+
* #commit 1a2b3c4d5e6f7890 Added user 1712345700
63+
* #branch 0f1e2d3c4b5a6978 dev
64+
* #tag 1a2b3c4d5e6f7890 v2.0
65+
* ```
66+
*
67+
* ## Another Example
68+
* ```
69+
* config=enabled #hash=deadbeefcafebabe
70+
* mode=fast #hash=beefdeadbabecafe
71+
* #commit deadbeefcafebabe Config enabled 1712345800
72+
* #branch beefdeadbabecafe test
73+
* #tag deadbeefcafebabe test-tag
74+
* ```
75+
*
76+
* ## Fourth Example
77+
* ```
78+
* foo=bar #hash=1111222233334444
79+
* baz=qux #hash=5555666677778888
80+
* #commit 1111222233334444 FooBar commit 1712345900
81+
* #branch 5555666677778888 feature-x
82+
* #tag 1111222233334444 release-x
83+
* ```
84+
*
85+
* ## Fifth Example
86+
* ```
87+
* alpha=beta #hash=9999aaaabbbbcccc
88+
* gamma=delta #hash=ddddccccbbbbaaaa
89+
* #commit 9999aaaabbbbcccc AlphaBeta commit 1712346000
90+
* #branch ddddccccbbbbaaaa hotfix
91+
* #tag 9999aaaabbbbcccc hotfix-1
92+
* ```
93+
*
94+
* ## Main Functions
95+
* - `myshell_hash64`: Computes a 64-bit hash for strings (MurmurHash3 variant).
96+
* - `fossil_myshell_open`: Opens an existing .myshell database file.
97+
* - `fossil_myshell_create`: Creates a new .myshell database file.
98+
* - `fossil_myshell_close`: Closes and frees resources for a database.
99+
* - `fossil_myshell_put`: Inserts or updates a key-value pair.
100+
* - `fossil_myshell_get`: Retrieves the value for a given key.
101+
* - `fossil_myshell_del`: Deletes a key-value pair.
102+
* - `fossil_myshell_commit`: Records a commit with a message.
103+
* - `fossil_myshell_branch`: Creates or switches to a branch.
104+
* - `fossil_myshell_checkout`: Checks out a branch or commit.
105+
* - `fossil_myshell_merge`: Merges a branch with a commit message.
106+
* - `fossil_myshell_revert`: Reverts to a specific commit.
107+
* - `fossil_myshell_stage`: Stages a key-value change.
108+
* - `fossil_myshell_unstage`: Removes a staged change.
109+
* - `fossil_myshell_tag`: Tags a commit.
110+
* - `fossil_myshell_log`: Iterates commit history.
111+
* - `fossil_myshell_backup`: Creates a backup of the database.
112+
* - `fossil_myshell_restore`: Restores a database from backup.
113+
* - `fossil_myshell_errstr`: Converts error codes to strings.
114+
* - `fossil_myshell_check_integrity`: Verifies file and commit integrity.
115+
*
116+
* ## Error Handling
117+
* All functions return a `fossil_bluecrab_myshell_error_t` code indicating success or the type of error.
118+
*
119+
* ## Usage Notes
120+
* - Only files with the ".myshell" extension are supported.
121+
* - All operations are performed directly on the file; there is no in-memory caching.
122+
* - Integrity of data is ensured via hashes for keys and commits.
123+
* - The API is designed for simple versioned key-value storage with basic VCS-like features.
124+
*/
125+
27126
/**
28127
* Custom strdup implementation.
29128
*/

0 commit comments

Comments
 (0)