Skip to content

Commit ac37cd3

Browse files
committed
style: update comments for consistency and clarity across multiple files
1 parent 1527b4d commit ac37cd3

11 files changed

Lines changed: 40 additions & 24 deletions

File tree

README.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ timetree status
3131

3232
## Installation
3333

34-
**Prerequisites:** Java JDK 11 or higher (Java 21 recommended - latest LTS version). Check with:
34+
**Prerequisites:** Java JDK 11 or higher (Java 21 recommended). Note: Java 25 does not work due to Gradle compatibility issues. Check with:
3535
```bash
3636
java -version
3737
```
@@ -59,6 +59,8 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
5959

6060
## Commands
6161

62+
### Core Version Control
63+
6264
| Command | Description |
6365
|---------|-------------|
6466
| `init` | Initialize a new repository |
@@ -72,6 +74,15 @@ Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
7274
| `branch -d <name>` | Delete a branch |
7375
| `checkout <branch>` | Switch branches |
7476

77+
### Low-Level Commands
78+
79+
| Command | Description |
80+
|---------|-------------|
81+
| `hash-object <path>` | Compute object hash for a file |
82+
| `sig <basis> [-o output] [-b block-size]` | Generate signature for delta compression |
83+
| `delta <signature> <target> [-o output]` | Create delta from signature and target |
84+
| `patch <basis> <delta> [-o output]` | Apply delta to reconstruct file |
85+
7586
**Alias**: Use `tt` instead of `timetree` for shorter commands.
7687

7788
## Architecture
@@ -101,12 +112,6 @@ TimeTree stores project history in a `.timetree/` directory:
101112
.\scripts\powershell\uninstall.ps1
102113
```
103114

104-
## Building from Source
105-
106-
```bash
107-
./gradlew shadowJar
108-
```
109-
110115
The JAR will be in `build/libs/timetree.jar`
111116

112117
## Testing

src/main/kotlin/dev/kamisama/cli/commands/BranchCmd.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ class BranchCmd(
3333
delete && branchName != null -> {
3434
deleteBranch(repo, branchName!!)
3535
}
36+
3637
// Create branch
3738
branchName != null -> {
3839
createBranch(repo, branchName!!)
3940
}
41+
4042
// List branches
4143
else -> {
4244
listBranches(repo)

src/main/kotlin/dev/kamisama/cli/commands/HashObjectCmd.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import java.nio.file.Files
99
import java.nio.file.Paths
1010

1111
/**
12-
* Diagnostic command: prints the SHA-1 ids using
13-
* (a) git-style header and (b) TimeTree domain-separated header.
12+
* Computes the object hash for a file in both Git-style and TimeTree-style.
1413
*/
1514
class HashObjectCmd :
1615
CliktCommand(
@@ -25,11 +24,11 @@ class HashObjectCmd :
2524
require(Files.isRegularFile(p)) { "Not a regular file: $p" }
2625
val bytes = Files.readAllBytes(p)
2726

28-
// a) Git-style: "blob <size>\\0" + content
27+
// Git-style: "blob <size>\\0" + content
2928
val gitHeader = "blob ${bytes.size}\u0000".toByteArray()
3029
val gitId = HashAlgorithm.computeAll(gitHeader + bytes).toHex()
3130

32-
// b) TimeTree-style: "timetree:v1\\0blob <size>\\0" + content
31+
// TimeTree-style: "timetree:v1\\0blob <size>\\0" + content
3332
val ttHeader = ObjectHeaders.blobHeader(bytes.size.toLong())
3433
val ttId = HashAlgorithm.computeAll(ttHeader + bytes).toHex()
3534

src/main/kotlin/dev/kamisama/core/checkout/Checkout.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ object Checkout {
8080
if (path.startsWith(meta)) return@forEach
8181

8282
when {
83-
Files.isRegularFile(path) -> Files.delete(path)
83+
Files.isRegularFile(path) -> {
84+
Files.delete(path)
85+
}
86+
8487
Files.isDirectory(path) && path != root && path != meta -> {
8588
directoriesToRemove.add(path)
8689
}

src/main/kotlin/dev/kamisama/core/delta/RsyncDelta.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class RsyncDelta(
4747
return Signature(blockSize, blocks)
4848
}
4949

50+
// Creates a delta for a given signature.
5051
override fun makeDelta(
5152
target: InputStream,
5253
sig: Signature,
@@ -110,6 +111,7 @@ class RsyncDelta(
110111
return Delta(sig.blockSize, coalesceOps(ops))
111112
}
112113

114+
// Applies a delta to a basis file.
113115
override fun applyDelta(
114116
basisPath: Path,
115117
delta: Delta,
@@ -144,6 +146,7 @@ class RsyncDelta(
144146
}
145147
}
146148

149+
// Creates a delta for an empty signature.
147150
private fun makeDeltaForEmptySignature(
148151
target: InputStream,
149152
blockSize: Int,
@@ -241,6 +244,7 @@ class RsyncDelta(
241244
}
242245
}
243246

247+
// Initializes the rolling window with a single byte.
244248
private fun initWindowWithByte(
245249
byte: Byte,
246250
window: RingBuffer,
@@ -250,6 +254,7 @@ class RsyncDelta(
250254
roller.init(byteArrayOf(byte), 0, 1)
251255
}
252256

257+
// Fills the rolling window up to block size.
253258
private fun fillWindow(
254259
target: InputStream,
255260
window: RingBuffer,

src/main/kotlin/dev/kamisama/core/delta/io/BinaryIO.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.io.OutputStream
88
* Binary I/O utilities for delta serialization.
99
*/
1010
internal object BinaryIO {
11-
/** Writes 32-bit integer in big-endian format. */
11+
// Writes 32-bit integer in big-endian format.
1212
fun writeU32(
1313
out: OutputStream,
1414
value: Int,
@@ -19,7 +19,7 @@ internal object BinaryIO {
1919
out.write(value and 0xFF)
2020
}
2121

22-
/** Reads 32-bit integer in big-endian format. */
22+
// Reads 32-bit integer in big-endian format.
2323
fun readU32(input: InputStream): Int {
2424
val b0 = input.read()
2525
val b1 = input.read()
@@ -31,7 +31,7 @@ internal object BinaryIO {
3131
return (b0 shl 24) or (b1 shl 16) or (b2 shl 8) or b3
3232
}
3333

34-
/** Reads exact byte count from the stream. */
34+
// Reads exact byte count from the stream.
3535
fun readBytes(
3636
input: InputStream,
3737
count: Int,

src/main/kotlin/dev/kamisama/core/delta/io/DeltaIO.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object DeltaIO {
1717
private const val MAX_OPS = 10_000_000
1818
private const val MAX_INSERT_LENGTH = 100 * 1024 * 1024
1919

20-
/** Writes delta to the output stream in binary format. */
20+
// Writes delta to the output stream in binary format.
2121
fun write(
2222
delta: Delta,
2323
out: OutputStream,
@@ -43,7 +43,7 @@ object DeltaIO {
4343
}
4444
}
4545

46-
/** Reads delta from input stream. */
46+
// Reads delta from input stream.
4747
fun read(input: InputStream): Delta {
4848
val magic = BinaryIO.readBytes(input, 5)
4949
if (!magic.contentEquals(MAGIC)) {
@@ -86,7 +86,9 @@ object DeltaIO {
8686
ops.add(DeltaOp.Copy(offset, length.toInt()))
8787
}
8888

89-
else -> throw IllegalArgumentException("Unknown delta op tag: $tag")
89+
else -> {
90+
throw IllegalArgumentException("Unknown delta op tag: $tag")
91+
}
9092
}
9193
}
9294

src/main/kotlin/dev/kamisama/core/delta/io/SignatureIO.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import java.io.OutputStream
1212
object SignatureIO {
1313
private val MAGIC = byteArrayOf('T'.code.toByte(), 'T'.code.toByte(), 'S'.code.toByte(), 'G'.code.toByte(), 0x01)
1414

15-
/** Writes signature to the output stream. */
15+
// Writes signature to the output stream.
1616
fun write(
1717
sig: Signature,
1818
out: OutputStream,
@@ -28,7 +28,7 @@ object SignatureIO {
2828
}
2929
}
3030

31-
/** Reads signature from the input stream. */
31+
// Reads signature from the input stream.
3232
fun read(input: InputStream): Signature {
3333
val magic = BinaryIO.readBytes(input, 5)
3434
if (!magic.contentEquals(MAGIC)) {

src/main/kotlin/dev/kamisama/core/delta/io/VarInt.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import java.io.OutputStream
88
* Base-128 variable-length integer encoding for compact storage.
99
*/
1010
object VarInt {
11-
/** Encodes long value as base-128 varint. */
11+
// Encodes long value as base-128 varint.
1212
fun write(
1313
out: OutputStream,
1414
value: Long,
@@ -21,7 +21,7 @@ object VarInt {
2121
out.write((v and 0x7F).toInt())
2222
}
2323

24-
/** Decodes base-128 varint from input stream. */
24+
// Decodes base-128 varint from input stream.
2525
fun read(input: InputStream): Long {
2626
var result = 0L
2727
var shift = 0

src/main/kotlin/dev/kamisama/core/refs/Refs.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object Refs {
3232
}
3333
}
3434

35-
// Ensure HEAD points to the given branch ref (used on the first commit in fresh repo).
35+
// Ensure HEAD points to the given branch ref.
3636
fun ensureHeadOn(
3737
repo: RepoLayout,
3838
branchRef: String = "refs/heads/master",

0 commit comments

Comments
 (0)