-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05d8574
commit 9ac8932
Showing
1 changed file
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}]] | ||
``` |