Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Diff] Organize contexts, add tests, support Git patch emails #4111

Open
wants to merge 124 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
06e3966
[Diff] Support alt mode for Git's "patch email"
michaelblyons Dec 7, 2024
b4d9e96
[Diff] Add special Git email headers
michaelblyons Dec 7, 2024
3cf1c25
[Diff] Add a Git --stat block
michaelblyons Dec 7, 2024
108b072
[Diff] Add binary files to --stat block
michaelblyons Dec 7, 2024
c2b04b3
[Diff] Add a Git --shortstat block
michaelblyons Dec 7, 2024
2aa8ec9
[Diff] Add create/delete files to --shortstat
michaelblyons Dec 7, 2024
a365452
[Diff] Add/Move test files
michaelblyons Dec 7, 2024
c6b3af1
[Diff] Add context for email body with formatting
michaelblyons Dec 7, 2024
b06d2d3
[Diff] Split to Git, other, and common contexts
michaelblyons Dec 7, 2024
ad29849
[Diff] Add Git binary patch format
michaelblyons Dec 7, 2024
bb16650
[Diff] Git file headings
michaelblyons Dec 7, 2024
d0e546b
[Diff] Fully split Git-special vs generic diffs
michaelblyons Dec 7, 2024
e65528c
[Diff] Tweak commit hash scope
michaelblyons Dec 7, 2024
6c10828
[Diff] Git diff end block
michaelblyons Dec 7, 2024
ee7ffbf
[Diff] Consolidate some variables
michaelblyons Dec 7, 2024
388d3f6
[Diff] File mode stuff
michaelblyons Dec 7, 2024
e5cd833
[Diff] Filename in git diff headers
michaelblyons Dec 7, 2024
7731589
[Diff] Refactor Git file header
michaelblyons Dec 7, 2024
1e88e63
[Diff] Move Git Diff to its own file !!!!!
michaelblyons Dec 7, 2024
1eca9ec
[Diff] Add more Git email headers
michaelblyons Dec 7, 2024
8780272
[Diff] Rename hash variables
michaelblyons Dec 7, 2024
5610274
[Diff] Bailout for no-stat Git diff
michaelblyons Dec 7, 2024
f9960f6
[Diff] Refactor Git deltas
michaelblyons Dec 7, 2024
50ed8bc
[Diff] Git diff signature. More file headers.
michaelblyons Dec 7, 2024
11292ec
[Diff] Modify file header first line detection
michaelblyons Dec 7, 2024
8902243
[Diff] Refactor pre-EOL pops
michaelblyons Dec 7, 2024
72d8215
[Diff] Block contexts for diff header and content
michaelblyons Dec 7, 2024
938ef14
fixup executable file mode scope
michaelblyons Dec 7, 2024
660fb2e
[Diff] Drop unnecessary context
michaelblyons Dec 7, 2024
32326aa
[Diff] WIP skippable stat
michaelblyons Dec 7, 2024
aa9a634
fixup Add context for pre-file header pop
michaelblyons Dec 7, 2024
32a8cd6
fixup Binary patch content
michaelblyons Dec 7, 2024
8bfa539
[Diff] Expand/comment Git index file header
michaelblyons Dec 7, 2024
ad57682
[Diff] Split traditional diff into more contexts
michaelblyons Dec 7, 2024
3002e53
[Diff] Escape chars in Git filenames
michaelblyons Dec 7, 2024
fc7b192
[Diff] Link GNU diff documentation
michaelblyons Dec 7, 2024
c2c11d5
[Diff] Try circular extends
michaelblyons Dec 7, 2024
029e22d
[Diff] Extended syntax consolidation
michaelblyons Dec 7, 2024
58ec9a1
[Diff] Split unified headers off to new contexts
michaelblyons Dec 7, 2024
28ccfdf
[Diff] Add optional date modified in file header
michaelblyons Dec 7, 2024
208a40a
[Diff] Simplify date scopes
michaelblyons Dec 7, 2024
381380d
[Diff] Consolidate Git stat line matches
michaelblyons Dec 7, 2024
15ef595
[Diff] Change GNU links to anchors on full doc
michaelblyons Dec 7, 2024
c6e73b7
[Diff] Organize Git Diff with section headings
michaelblyons Dec 7, 2024
c0750e4
[Diff] Fix and Reformat first line matches
michaelblyons Dec 7, 2024
5a03cf4
[Diff] Change test file comment character
michaelblyons Dec 7, 2024
bcaa079
[Diff] Add blockquote and scissors to Git email
michaelblyons Dec 7, 2024
fad1e98
[Diff] Support Diff3 Normal mode
michaelblyons Dec 7, 2024
7c58155
[Diff] Modify punctuation scopes
michaelblyons Dec 7, 2024
4c0fa55
[Diff] Add Git email subject RFC flag
michaelblyons Dec 7, 2024
151888a
[Diff] Split delta types for traditional Diff
michaelblyons Dec 7, 2024
6e749f4
[Diff] Heavily refactor traditional Diff
michaelblyons Dec 7, 2024
0b78d37
[Diff] Scope ranges in hunk headers
michaelblyons Dec 7, 2024
1818219
[Diff] Path constants
michaelblyons Dec 7, 2024
5f14a7e
[Diff] Diff3 edit mode
michaelblyons Dec 7, 2024
b6a37ba
[Diff] Sort syntax headers
michaelblyons Dec 7, 2024
7473575
[Diff] Create a conflict syntax
michaelblyons Dec 7, 2024
5f499ce
[Diff] Rename `00000` hash to constant
michaelblyons Dec 7, 2024
aa52002
[Diff] Experiment with combined diff
michaelblyons Dec 7, 2024
e17ecd2
[Diff] Support combined diff out to 5 parents
michaelblyons Dec 7, 2024
8ce2398
[Diff] Push into context for `index` file header
michaelblyons Dec 7, 2024
030c9a9
[Diff] Add more combined diff file headers
michaelblyons Dec 7, 2024
4e838d0
[Diff] Centralize components section
michaelblyons Dec 7, 2024
23fd62c
[Diff] More accurate trailing whitespace
michaelblyons Dec 7, 2024
9ce9e89
[Diff] Tweak date separator scope
michaelblyons Dec 7, 2024
fdad09d
[Diff] Prepare for SHA-256 Git
michaelblyons Dec 7, 2024
2be2f6b
[Diff] Arabic numbers only in Git
michaelblyons Dec 7, 2024
cd733ba
[Diff] Fix backrefs incompatible with sregex
michaelblyons Dec 7, 2024
8f61146
[Diff] Tweak conflict scopes
michaelblyons Dec 7, 2024
d7e29fd
[Diff] First-line syntax for git-send-email
michaelblyons Dec 7, 2024
2eb4f8f
[Diff] Move Git Diff to Git Formats
michaelblyons Dec 7, 2024
472ec3a
[Diff] PHP embedding to v2
michaelblyons Dec 9, 2024
92051bb
[Diff] Move variables to the bottom
michaelblyons Dec 10, 2024
8e9fafc
[Diff] Move prototypes to the bottom
michaelblyons Dec 10, 2024
cd4c8da
[Diff] Add whitespace
michaelblyons Dec 10, 2024
f7a8a3b
[Diff] Categorize diff context separator
michaelblyons Dec 10, 2024
c339b0b
[Diff] Prefer named contexts to push into
michaelblyons Dec 10, 2024
f05aae8
[Diff] Assume carriage return is normalized away
michaelblyons Dec 10, 2024
8650e78
[Diff] ASCII-only in Base85
michaelblyons Dec 10, 2024
078f65c
[Diff] Split email header context
michaelblyons Dec 10, 2024
83a89f8
[Diff] More explicit variable name for hash
michaelblyons Dec 10, 2024
a53b9fb
[Diff] More comments
michaelblyons Dec 10, 2024
2f49b80
[Diff] Add more variables to Conflict
michaelblyons Dec 10, 2024
6b85490
[Diff] Conflict contexts
michaelblyons Dec 10, 2024
193c171
[Diff] Nested conflicts
michaelblyons Dec 10, 2024
97e8e48
[Diff] Conflict marker utility context
michaelblyons Dec 10, 2024
36b33f1
[Diff] Named context for Git email quotes
michaelblyons Dec 15, 2024
636739d
[Diff] Simplify date context
michaelblyons Dec 15, 2024
afc7fc3
[Diff] Named contexts for leading text body
michaelblyons Dec 15, 2024
ab04f94
[Diff] Named context for header body
michaelblyons Dec 15, 2024
b5c156a
[Diff] Remove some trailing whitespace
michaelblyons Dec 16, 2024
df6b4d6
[Diff] Embed Git Diff instead of pushing
michaelblyons Dec 16, 2024
fcff21a
[Diff] Merge leading text with headers
michaelblyons Dec 16, 2024
1f5f405
[Diff] Modify inheritable part of signature
michaelblyons Dec 16, 2024
53ae5aa
[Diff] Test Git-diff swap
michaelblyons Dec 16, 2024
2207f0a
[Diff] Tests from SVN documentation
michaelblyons Dec 17, 2024
fd7bfee
[Diff] Split unified diff into a common base
michaelblyons Dec 16, 2024
b1f984f
[Diff] Rename diff header related contexts
deathaxe Dec 17, 2024
2f1ddd1
[Diff] Remove redundant diff header implementations
deathaxe Dec 17, 2024
3968c7b
[Diff] Re-use line-ranges context
deathaxe Dec 17, 2024
409c0d7
[Diff] Re-use deltas context
deathaxe Dec 17, 2024
a6cadee
[Diff] combined and unified line-ranges share same patterns
deathaxe Dec 17, 2024
ef42739
[Diff] Tweak main key code style
deathaxe Dec 17, 2024
a8a3992
[Diff] Make Diff (Unified) non-standalone base syntax
deathaxe Dec 17, 2024
07457a4
[Diff] Simplify eol
deathaxe Dec 17, 2024
4f9d6dc
[Diff] Merge unique contexts
deathaxe Dec 17, 2024
563c3b0
[Diff] Rename line-range contexts
deathaxe Dec 17, 2024
8eded5f
[Diff] Rename delta contexts
deathaxe Dec 17, 2024
10c3968
[Diff] Add separator
deathaxe Dec 17, 2024
e9b57ae
[Diff] Rename date context to timestamps
deathaxe Dec 17, 2024
0447a06
[Diff] Include eol into meta.separator
deathaxe Dec 17, 2024
46ff975
[Diff] Rename file-header-continue to diff-file-header
deathaxe Dec 17, 2024
e076ddc
[Diff] Remove redundant includes
deathaxe Dec 18, 2024
18fb06e
[Diff] Fix diff3 edit format
deathaxe Dec 18, 2024
13c33f6
[Diff] Hunks and ranges
deathaxe Dec 18, 2024
d13e9fb
[Diff] Fold Conflict syntax back in
michaelblyons Dec 18, 2024
e94d9b7
[Diff] Side-by-side diff
michaelblyons Dec 18, 2024
15622fc
[Diff] Scope diff --git line meta.function-call
deathaxe Dec 19, 2024
98fa1f8
[Diff] Update twodot scope
michaelblyons Dec 19, 2024
39a126a
[Diff] Support multiline email headers
michaelblyons Dec 19, 2024
3d631ec
[Diff] Rescope paths
michaelblyons Dec 19, 2024
12066ad
[Diff] Add missing scopes for copy/move/etc.
michaelblyons Dec 20, 2024
3685f51
[Diff] Git diff file header paths
michaelblyons Dec 20, 2024
4ee85d3
[Diff] Embed Git Diff from Git Log
michaelblyons Dec 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions Diff/Diff (Basic).sublime-syntax
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
%YAML 1.2
---
# This is the common base syntax for Gnu Diff and Git Diff,
# which contains contexts, shared by both of them.
# It is not designed as standalone syntax and therefore does not expose
# anything when referenced or used directly.
#
# https://www.sublimetext.com/docs/syntax.html
# https://www.gnu.org/software/diffutils/manual/diffutils.html
scope: source.diff.basic
version: 2
hidden: true

contexts:
main: []

###[ HEADERS ]#################################################################

diff-header:
# https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified
- match: ^(-{3})[ ](?!$)
captures:
1: punctuation.definition.from-file.diff
push: diff-header-unified-from-file
- match: ^(\+{3})[ ](?!$)
captures:
1: punctuation.definition.to-file.diff
push: diff-header-unified-to-file

diff-header-unified-from-file:
- meta_scope: meta.diff.header.from-file meta.header.from-file.diff
- include: pop-eol
- include: dev-null
- include: path-separators
- include: timestamps
- include: diff-header-unified-file-comment

diff-header-unified-to-file:
- meta_scope: meta.diff.header.to-file meta.header.to-file.diff
- include: pop-eol
- include: dev-null
- include: path-separators
- include: timestamps
- include: diff-header-unified-file-comment

diff-header-unified-file-comment:
- match: \s+(\(.+\))$
captures:
1: comment.block.diff

###[ RANGES ]##################################################################

diff-line-ranges:
# https://www.gnu.org/software/diffutils/manual/diffutils.html#Detailed-Unified
- match: ^(@@)(?=[^@\n]+@@(?:\s|$))
captures:
1: punctuation.definition.range.begin.diff
push: [hunk-name, inside-diff-line-ranges-unified]

inside-diff-line-ranges-unified:
- meta_scope: meta.diff.range.unified meta.range.unified.diff meta.toc-list.hunk.diff
- include: pop-eol
- match: \1
scope: punctuation.definition.range.end.diff
pop: 1
- include: line-range-span
- match: '[+-](?=\d)'
scope: support.function.diff

hunk-name:
- include: pop-eol
- match: '[ \t]+'
scope: meta.toc-list.hunk.diff
- match: \S.+?(?=\s*{{eol}})
scope: meta.toc-list.hunk.diff entity.name.section.diff

line-range-span:
- match: \d+(?:(,)\d+)?
captures:
1: punctuation.separator.sequence.diff

###[ DELTAS ]##################################################################

diff-deltas:
# https://www.gnu.org/software/diffutils/manual/diffutils.html#Example-Unified
- match: ^\+
scope: punctuation.definition.inserted.diff
push: line-inserted
- match: ^-
scope: punctuation.definition.deleted.diff
push: line-deleted
- include: incomplete-line

# https://www.gnu.org/software/diffutils/manual/diffutils.html#Incomplete-Lines
incomplete-line:
- match: ^[\\/]
scope: punctuation.definition.comment.begin.diff
push: line-ignored

line-deleted:
- meta_scope: markup.deleted.diff
- include: pop-eol
- include: trailing-whitespace

line-inserted:
- meta_scope: markup.inserted.diff
- include: pop-eol
- include: trailing-whitespace

line-changed:
- meta_scope: markup.changed.diff
- include: pop-eol
- include: trailing-whitespace

line-ignored:
- meta_scope: comment.line.diff
- include: pop-eol
- include: trailing-whitespace

trailing-whitespace:
- match: '[ \t]*$'
scope: meta.whitespace.trailing.diff

###[ COMPONENTS ]##############################################################

dev-null:
- match: /dev/null\b
scope: constant.language.null.diff

path-separators:
- match: /|\\
scope: punctuation.separator.sequence.diff
- match: \B\.\.(?=/|\\)
scope: constant.other.path.parent.diff
- match: \B\.(?=/|\\)
scope: constant.other.path.self.diff

timestamps:
# 1970-01-01 00:00:00 +0000
- match: \b1970(-)01(-)01 0?0(:)00(:)00(?:(\.)0+)?(?:[ ]([+-]?0000|UTC))?
scope: meta.date.diff constant.language.null.diff
captures:
1: punctuation.separator.date.diff
2: punctuation.separator.date.diff
3: punctuation.separator.date.diff
4: punctuation.separator.date.diff
5: punctuation.separator.decimal.diff
6: storage.modifier.diff

# 2002-02-21 23:30:50.442260588 -0800
- match: \b\d{4}(-)\d\d(-)\d\d \d?\d(:)\d\d(:)\d\d(?:(\.)\d+)?(?:[ ]([+-]?\d{4}))?
scope: meta.date.diff meta.number.integer.decimal.diff constant.numeric.value.diff
captures:
1: punctuation.separator.date.diff
2: punctuation.separator.date.diff
3: punctuation.separator.date.diff
4: punctuation.separator.date.diff
5: punctuation.separator.decimal.diff
6: storage.modifier.diff

###[ PROTOTYPES ]##############################################################

pop-immediately:
- match: ''
pop: 1

pop-eol:
- match: '{{eol}}'
pop: 1

pop-before-eol:
- match: $
pop: 1

###############################################################################

variables:
git_hash40: '[0-9a-fA-F]{40}'
git_hash64: '[0-9a-fA-F]{64}'
git_hash_full: (?:{{git_hash64}}|{{git_hash40}})
git_first_line: |-
^(?x:
From [ ] \w+@z [ ]
Thu [ ] Jan [ ]{2} 1 [ ] 00:00:00 [ ] 1970 # git-send-email
| From [ ] {{git_hash_full}} [ ]
Mon [ ] Sep [ ] 17 [ ] 00:00:00 [ ] 2001 # git-format-patch
)
eol: (?:$\n?)
Loading
Loading