Skip to content

Commit

Permalink
V2 notes
Browse files Browse the repository at this point in the history
  • Loading branch information
josephburnett committed Apr 30, 2023
1 parent 05d8574 commit 9ac8932
Showing 1 changed file with 118 additions and 0 deletions.
118 changes: 118 additions & 0 deletions doc/v2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# JD V2

## What should before and after context look like for nested lists?

- need context for producing minimal diffs
- so we can insert an element into the middle of a list
- patch must apply only once so we need to add enough context

A:

```json
[[1,2,3],[4,6],[7,8,9]]

```

B:

```json
[[1,2,3],[4,5,6],[7,8,9]]
```

D:

```diff
@ [1,1]
4
+ 5
6
```

- the `4` and `6` are compared for equality
- no context means "end of list" or "beginning of list"

A:

```json
[2,3]
```

B:

```json
[1,2,3]
```

D:

```diff
@ [0]
+ 1
2
```

- if a patch doesn't have enough context to prevent double application, more context is added

A:

```json
[1,2,2,3]
```

B:

```json
[1,2,2,2,3]
```

D:

```diff
@ [2]
2
+ 2
2
3
```

- the `3` prevents double application

## What should metadata look like?

- metadata applying to entire hunk (not just path) is a separate line
- version (2)
- merge patch behavior

```diff
^ {"version":"2"}
@ ["foo"]
- "bar"
+ "baz"
```

```diff
^ {"version":2,"merge":true}
@ ["foo"]
- "bar"
+ "baz"
```

## What about in-path metadata?

- no more metadata in a list (`[["multiset"],{}]`)
- still objects mean set
- object in list means multiset
- object with keys means object identity
- other use cases are now in the top-level `^` metadata object

Set:

```diff
@ ["foo",{"id":"bar"}]
```

Multiset:

```diff
@ ["foo",[{"id":"bar"}]]
```

0 comments on commit 9ac8932

Please sign in to comment.