Skip to content

Commit

Permalink
[Diff] Git diff file header paths
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelblyons committed Dec 20, 2024
1 parent 12066ad commit 3685f51
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Git Formats/Git Diff.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,21 @@ contexts:
signature:
- meta_content_scope: comment.block.diff

diff-header-unified-from-file:
- meta_prepend: true
- include: diff-file-header-path-start

diff-header-unified-to-file:
- meta_prepend: true
- include: diff-file-header-path-start

diff-file-header:
- meta_scope: meta.toc-list.git
- meta_content_scope: meta.function-call.arguments.git
- include: pop-eol
- include: diff-file-header-path-start

diff-file-header-path-start:
# TODO: Quoted file names https://git-scm.com/docs/git-config#Documentation/git-config.txt-corequotePath
- match: (?:a|b|ours|theirs)(?=/)
scope: variable.parameter.source.diff
Expand Down
22 changes: 22 additions & 0 deletions Git Formats/tests/syntax_test_git_diff.patch
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,28 @@ diff --git a/Gemfile b/Gemfile
\ ^ punctuation.separator.path.diff
index c661619..989efe8 100644
--- a/Gemfile
\^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.from-file meta.header.from-file.diff
\^^ punctuation.definition.from-file.diff
\ ^ variable.parameter.source.diff
\ ^^^^^^^^ meta.path.diff string.unquoted.git
\ ^ punctuation.separator.path.diff
+++ b/Gemfile
\^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.to-file meta.header.to-file.diff
\^^ punctuation.definition.to-file.diff
\ ^ variable.parameter.source.diff
\ ^^^^^^^^ meta.path.diff string.unquoted.git
\ ^ punctuation.separator.path.diff
@@ -24,6 +24,7 @@ group :development do
\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff
\^^^^^^^^^^^^^^^^ meta.diff.range.unified meta.range.unified.diff meta.toc-list.hunk.diff
\^ punctuation.definition.range.begin.diff
\ ^ support.function.diff
\ ^ punctuation.separator.sequence.diff
\ ^ support.function.diff
\ ^ punctuation.separator.sequence.diff
\ ^^ punctuation.definition.range.end.diff
\ ^^^^^^^^^^^^^^^^^^^^^^ meta.toc-list.hunk.diff
\ ^^^^^^^^^^^^^^^^^^^^^ entity.name.section.diff
gem 'listen', '~> 3.0.5'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
Expand All @@ -124,6 +144,8 @@ index c661619..989efe8 100644
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
diff --git a/app/assets/images/logo.jpeg b/app/assets/images/logo.jpeg
new file mode 100644
\^^^^^^^^^^^^^^^^^^^ meta.block.header.diff markup.inserted.diff
\ ^^^^^^ meta.number.integer.octal.diff constant.numeric.value.diff
index 0000000000000000000000000000000000000000..064fa38be3ecd426a3c8977ed43df627c6f6f229
\^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.header.diff
\^^^^ keyword.other.diff
Expand Down
6 changes: 6 additions & 0 deletions Git Formats/tests/syntax_test_git_diff_combined.patch
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,15 @@ index fabadb8,cc95eb0..4866510 644
--- a/describe.c
\^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.from-file meta.header.from-file.diff
\^^ punctuation.definition.from-file.diff
\ ^ variable.parameter.source.diff
\ ^^^^^^^^^^^ meta.path.diff string.unquoted.git
\ ^ punctuation.separator.path.diff
+++ b/describe.c
\^^^^^^^^^^^^^^^^ meta.block.header.diff meta.diff.header.to-file meta.header.to-file.diff
\^^ punctuation.definition.to-file.diff
\ ^ variable.parameter.source.diff
\ ^^^^^^^^^^^ meta.path.diff string.unquoted.git
\ ^ punctuation.separator.path.diff
@@@ -98,20 -98,12 +98,20 @@@
\ ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.block.delta.diff meta.diff.range.combined meta.range.combined.diff meta.toc-list.hunk.diff
return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
Expand Down

0 comments on commit 3685f51

Please sign in to comment.