File README.md changed (mode: 100644) (index eb724b8..88e96a5) |
... |
... |
The project is work in progress, but is useful in its current state. |
44 |
44 |
Code isn't perfect and isn't extensively documented as initial version was more |
Code isn't perfect and isn't extensively documented as initial version was more |
45 |
45 |
of an experiment, but this situation gets better. |
of an experiment, but this situation gets better. |
46 |
46 |
|
|
47 |
|
### Supported languages ### |
|
48 |
|
|
|
49 |
|
| Language | Status | |
|
50 |
|
|-----------|------------------------------------------------------------------| |
|
51 |
|
| C | C11 and earlier with common extensions, but without K&R syntax | |
|
52 |
|
| C++ | C++14 and earlier with common extensions | |
|
53 |
|
| GNU Make | Most of the syntax | |
|
54 |
|
| Lua | Version 5.3 | |
|
55 |
|
|
|
56 |
|
#### C #### |
|
57 |
|
|
|
58 |
|
The exact grammar is that of C11 with extensions implemented in popular |
|
59 |
|
compilers and additional extensions needed to allow processing of code with |
|
60 |
|
macros. |
|
61 |
|
|
|
62 |
|
Note the following: |
|
63 |
|
* old K&R style of function declarations isn't parsed (there might be a |
|
64 |
|
workaround for it, but this syntax is deprecated either way) |
|
65 |
|
* preprocessor directives aren't tokenized according to language rules yet, |
|
66 |
|
but their contents is diffed |
|
67 |
|
* extensive use of macros in unusual places might not be parsed (this probably |
|
68 |
|
won't change) |
|
69 |
|
|
|
70 |
|
Other than that code in C89, C99, C11 and GNU-versions of C language should be |
|
71 |
|
recognized. |
|
72 |
|
|
|
73 |
|
#### C++ #### |
|
74 |
|
|
|
75 |
|
C++ support relies on external application called [srcml][srcml] and requires it |
|
76 |
|
to be installed in binary form (not necessary during build). |
|
77 |
|
|
|
78 |
|
Reported standard version supported by `srcml` is C++14, so all previous ones |
|
79 |
|
should work too. Although their parser doesn't handle all language constructs |
|
80 |
|
equally well, it's seems to be good enough, especially for a ready to use parser |
|
81 |
|
that wasn't that hard to integrate. |
|
82 |
|
|
|
83 |
|
Note the following: |
|
84 |
|
* the tuning of comparison is in progress and will be refined over time |
|
85 |
|
|
|
86 |
|
#### GNU Make #### |
|
87 |
|
|
|
88 |
|
It's hard to measure level of support in case of GNU Make, because there seem to |
|
89 |
|
be no reference for the syntax itself apart from documentation, which is not |
|
90 |
|
concise. |
|
91 |
|
|
|
92 |
|
Yet parser is capable of processing quite complicated examples of Makefiles |
|
93 |
|
(like the one used in this project or generated by `automake`) which contain |
|
94 |
|
many features most people don't know exist. It's definitely not 100%, but 90% |
|
95 |
|
or even more of all existing Makefiles out there should be parsed. |
|
96 |
|
|
|
97 |
|
Note the following: |
|
98 |
|
* the comparison might not produce best results on Makefiles as it needs |
|
99 |
|
some tuning, this should happen over time (Makefiles aren't changed that |
|
100 |
|
often) |
|
101 |
|
|
|
102 |
|
#### Lua #### |
|
103 |
|
|
|
104 |
|
Newly added (March 2021) with very little testing so far. However, the |
|
105 |
|
language is small and simple enough to not pose much difficulties. |
|
106 |
|
|
|
107 |
|
Note the following: |
|
108 |
|
* non-5.3 versions might still work, albeit can produce worse results |
|
109 |
|
|
|
110 |
|
#### Other #### |
|
111 |
|
|
|
112 |
|
More languages should be added in the future, maybe with external parsers that |
|
113 |
|
are capable of preserving all information about the source code. |
|
114 |
|
|
|
115 |
|
### Configuration ### |
|
116 |
|
|
|
117 |
|
Configuration is done per directory tree ("root") which is the closes parent (or |
|
118 |
|
current directory) that contains `.zs/` directory. The `.zs/` directory |
|
119 |
|
contains files which define how contents of the root is to be processed. |
|
120 |
|
Settings from multiple nested roots are not combined. |
|
121 |
|
|
|
122 |
|
#### `.zs/exclude` file #### |
|
123 |
|
|
|
124 |
|
A `.gitignore`-like (or `.git/info/exclude`-like) file that lists paths relative |
|
125 |
|
to the root. The purpose is to exclude uninteresting files (automatically |
|
126 |
|
generated, third-party or otherwise). `.zs/exclude` is used by tools that |
|
127 |
|
search for files automatically and doesn't prevent the use of the same files |
|
128 |
|
when they are specified explicitly. |
|
129 |
|
|
|
130 |
|
The following kinds of entries are recognized: |
|
131 |
|
|
|
132 |
|
* empty lines, which are ignored |
|
133 |
|
* lines that start with a `#` (comments), which are ignored |
|
134 |
|
* lines that end with `/` match only directories, the `/` is stripped and line |
|
135 |
|
processing continues |
|
136 |
|
* lines without `/` are treated as shell-like globs against filename which apply |
|
137 |
|
at any directory level and define paths whose processing should be skipped |
|
138 |
|
* lines that start with `!` define exception from rules that precede them, you |
|
139 |
|
can't undo exclusion of files in excluded directories, for the purpose of this |
|
140 |
|
discussion the `!` is stripped and line processing continues |
|
141 |
|
* lines that start with `/` always match paths instead of filename and provide a |
|
142 |
|
way to specify files to be ignored only in the root, otherwise they are |
|
143 |
|
processed as specified in the next item |
|
144 |
|
* other lines are treated as shell-like globs against paths relative to the |
|
145 |
|
root (leading `/` is allowed, but has no effect other than changing type of a |
|
146 |
|
match) which define paths whose processing should be skipped |
|
147 |
|
|
|
148 |
|
No way to escape leading `#` and `!` or a newline at the moment. |
|
149 |
|
|
|
150 |
|
Globs support the following: `[{char-class}]`, `[!{char-class}]`, |
|
151 |
|
`[^{char-class}]`, `?` (doesn't match `/`), `*` (matches any (including zero) |
|
152 |
|
number of characters except for `/`) and `\{char}` (matches literal `{char}`). |
|
153 |
|
|
|
154 |
|
Example: |
|
155 |
|
|
|
156 |
|
```gitignore |
|
157 |
|
# .zs/exclude |
|
158 |
|
|
|
159 |
|
# automatically generated sources |
|
160 |
|
src/c/c11-lexer.gen.cpp |
|
161 |
|
src/c/c11-parser.gen.cpp |
|
162 |
|
src/make/*.gen.* |
|
163 |
|
|
|
164 |
|
# Qt-produced sources |
|
165 |
|
ui_*.h |
|
166 |
|
moc_*.cpp |
|
167 |
|
moc_*.h |
|
168 |
|
|
|
169 |
|
# file in root |
|
170 |
|
/config.h |
|
171 |
|
``` |
|
172 |
|
|
|
173 |
|
#### `.zs/attributes` file #### |
|
174 |
|
|
|
175 |
|
Borrowing from the `git` project here again. This file consists of lines |
|
176 |
|
matching paths to attributes. Lines are trimmed before being processed. |
|
177 |
|
|
|
178 |
|
Empty lines and comments work like in `.zs/excludes` file, all other lines |
|
179 |
|
follow this pattern: |
|
180 |
|
|
|
181 |
|
exclude-expr [attr1=value1 [attr2=value2 [...]]] |
|
182 |
|
|
|
183 |
|
Expressions that define exceptions (start with `!`) are recognized but ignored |
|
184 |
|
to keep syntax consistent between different files, which basically makes them |
|
185 |
|
another type of comments. |
|
186 |
|
|
|
187 |
|
Each line of the file is visited in top down order and attributes from every |
|
188 |
|
matching entry are merged with the current state. Hierarchy of configuration |
|
189 |
|
values: |
|
190 |
|
1. Default values (lowest priority) |
|
191 |
|
2. Attributes |
|
192 |
|
3. Command-line parameters (highest priority) |
|
193 |
|
|
|
194 |
|
Supported attributes: |
|
195 |
|
|
|
196 |
|
* `lang`\ |
|
197 |
|
Default: ""\ |
|
198 |
|
Those accepted by `--lang` command-line option: c, cxx, make, lua |
|
199 |
|
* `tab-size`\ |
|
200 |
|
Default: 4\ |
|
201 |
|
Value should be an integer that's greater than zero |
|
202 |
|
|
|
203 |
|
Unknown attributes are ignored. |
|
204 |
|
|
|
205 |
|
Example: |
|
206 |
|
|
|
207 |
|
``` |
|
208 |
|
# .zs/exclude |
|
209 |
|
|
|
210 |
|
*.c tab-size=8 |
|
211 |
|
*.h tab-size=8 lang=c |
|
212 |
|
tab-2.[ch] tab-size=2 |
|
|
47 |
|
## Documentation ## |
213 |
48 |
|
|
214 |
|
# any.c has tab-size=8 |
|
215 |
|
# tab-2.c has tab-size=2 |
|
216 |
|
# tab-2.h has tab-size=2 lang=c |
|
217 |
|
# any.h has tab-size=8 lang=c |
|
218 |
|
# any.cpp has tab-size=4 |
|
219 |
|
``` |
|
|
49 |
|
See the [manual page](./docs/zograscope.md). |
220 |
50 |
|
|
221 |
51 |
## Tools ## |
## Tools ## |
222 |
52 |
|
|
|
... |
... |
make install |
281 |
111 |
* (optional, for `gdiff` tool) [qt5][qt5] |
* (optional, for `gdiff` tool) [qt5][qt5] |
282 |
112 |
* (optional, for `gdiff` tool) [libgit2][libgit2] |
* (optional, for `gdiff` tool) [libgit2][libgit2] |
283 |
113 |
* (optional, for `tui` tool) [curses][curses] with support of wide characters |
* (optional, for `tui` tool) [curses][curses] with support of wide characters |
|
114 |
|
* (optional) [pandoc][pandoc] for regenerating man pages |
284 |
115 |
|
|
285 |
116 |
#### For Debian-based distributions #### |
#### For Debian-based distributions #### |
286 |
117 |
|
|
|
... |
... |
sudo apt install ./srcML-Ubuntu18.04.deb |
303 |
134 |
You can also check out the [CI build script](data/appveyor/ubuntu.sh) in case |
You can also check out the [CI build script](data/appveyor/ubuntu.sh) in case |
304 |
135 |
dependencies change in the future. |
dependencies change in the future. |
305 |
136 |
|
|
306 |
|
## Documentation ## |
|
307 |
|
|
|
308 |
|
At the moment there is only `--help` option. |
|
309 |
|
|
|
310 |
137 |
## License ## |
## License ## |
311 |
138 |
|
|
312 |
139 |
![AGPLv3](data/agplv3.png) |
![AGPLv3](data/agplv3.png) |
|
... |
... |
Kaizhong Zhang and Dennis Shasha. |
352 |
179 |
[qt5]: https://www.qt.io/ |
[qt5]: https://www.qt.io/ |
353 |
180 |
[libgit2]: https://libgit2.org/ |
[libgit2]: https://libgit2.org/ |
354 |
181 |
[curses]: https://en.wikipedia.org/wiki/Curses_(programming_library) |
[curses]: https://en.wikipedia.org/wiki/Curses_(programming_library) |
|
182 |
|
[pandoc]: https://pandoc.org/ |
355 |
183 |
|
|
356 |
184 |
[dtl]: https://github.com/cubicdaiya/dtl |
[dtl]: https://github.com/cubicdaiya/dtl |
357 |
185 |
[pmr]: https://github.com/phalpern/CppCon2017Code |
[pmr]: https://github.com/phalpern/CppCon2017Code |
File docs/zograscope.md copied from file README.md (similarity 52%) (mode: 100644) (index eb724b8..91ac703) |
1 |
|
**zograscope**, _2017 - 2022_ |
|
|
1 |
|
NAME |
|
2 |
|
==== |
2 |
3 |
|
|
3 |
|
![Screenshot](data/examples/c/screenshot.png) |
|
4 |
|
|
|
5 |
|
**Clone recursively, there are submodules:** |
|
6 |
|
|
|
7 |
|
```bash |
|
8 |
|
git clone --recursive https://github.com/xaizek/zograscope.git |
|
9 |
|
``` |
|
10 |
|
|
|
11 |
|
1. [Description](#description) ([Status](#status); |
|
12 |
|
[Supported languages](#supported-languages); |
|
13 |
|
[Configuration](#configuration)) |
|
14 |
|
2. [Tools](#tools) |
|
15 |
|
3. [Building and Installing](#building-and-installing) |
|
16 |
|
([Dependencies](#dependencies)) |
|
17 |
|
4. [Documentation](#documentation) |
|
18 |
|
5. [License](#license) |
|
19 |
|
6. [Credits](#credits) |
|
20 |
|
([References](#references)) |
|
21 |
|
|
|
22 |
|
## Name ## |
|
23 |
|
|
|
24 |
|
"A zograscope is an optical device for enhancing the sense of depth perception |
|
25 |
|
from a flat picture." ([wiki][wiki-zograscope]) |
|
26 |
|
|
|
27 |
|
## Description ## |
|
28 |
|
|
|
29 |
|
`zograscope` is built around syntax-aware diff and includes a number of |
|
30 |
|
additional tools. |
|
|
4 |
|
*zograscope* is a collection of source-processing tools spawned out of |
|
5 |
|
syntax-aware diffing. |
31 |
6 |
|
|
32 |
7 |
The nature of syntax-aware diff requires knowledge of structure of the code, |
The nature of syntax-aware diff requires knowledge of structure of the code, |
33 |
8 |
which can be used to build other simple tools that can benefit from this |
which can be used to build other simple tools that can benefit from this |
|
... |
... |
text-processing utilities seems feasible and the result might be even more |
37 |
12 |
practical than some of the more elaborate tools which end up requiring |
practical than some of the more elaborate tools which end up requiring |
38 |
13 |
complicated setup process. |
complicated setup process. |
39 |
14 |
|
|
40 |
|
### Status ### |
|
41 |
|
|
|
42 |
|
The project is work in progress, but is useful in its current state. |
|
43 |
|
|
|
44 |
|
Code isn't perfect and isn't extensively documented as initial version was more |
|
45 |
|
of an experiment, but this situation gets better. |
|
46 |
|
|
|
47 |
|
### Supported languages ### |
|
|
15 |
|
LANGUAGE SUPPORT |
|
16 |
|
================ |
48 |
17 |
|
|
49 |
|
| Language | Status | |
|
50 |
|
|-----------|------------------------------------------------------------------| |
|
51 |
|
| C | C11 and earlier with common extensions, but without K&R syntax | |
|
52 |
|
| C++ | C++14 and earlier with common extensions | |
|
53 |
|
| GNU Make | Most of the syntax | |
|
54 |
|
| Lua | Version 5.3 | |
|
|
18 |
|
| Language | Status |
|
19 |
|
|-----------|------------------------------------------------------------------- |
|
20 |
|
| C | C11 and earlier with common extensions, but without K&R syntax |
|
21 |
|
| C++ | C++14 and earlier with common extensions |
|
22 |
|
| GNU Make | Most of the syntax |
|
23 |
|
| Lua | Version 5.3 |
55 |
24 |
|
|
56 |
|
#### C #### |
|
|
25 |
|
C |
|
26 |
|
- |
57 |
27 |
|
|
58 |
28 |
The exact grammar is that of C11 with extensions implemented in popular |
The exact grammar is that of C11 with extensions implemented in popular |
59 |
29 |
compilers and additional extensions needed to allow processing of code with |
compilers and additional extensions needed to allow processing of code with |
60 |
30 |
macros. |
macros. |
61 |
31 |
|
|
62 |
32 |
Note the following: |
Note the following: |
|
33 |
|
|
63 |
34 |
* old K&R style of function declarations isn't parsed (there might be a |
* old K&R style of function declarations isn't parsed (there might be a |
64 |
35 |
workaround for it, but this syntax is deprecated either way) |
workaround for it, but this syntax is deprecated either way) |
65 |
36 |
* preprocessor directives aren't tokenized according to language rules yet, |
* preprocessor directives aren't tokenized according to language rules yet, |
|
... |
... |
Note the following: |
70 |
41 |
Other than that code in C89, C99, C11 and GNU-versions of C language should be |
Other than that code in C89, C99, C11 and GNU-versions of C language should be |
71 |
42 |
recognized. |
recognized. |
72 |
43 |
|
|
73 |
|
#### C++ #### |
|
|
44 |
|
C++ |
|
45 |
|
--- |
74 |
46 |
|
|
75 |
47 |
C++ support relies on external application called [srcml][srcml] and requires it |
C++ support relies on external application called [srcml][srcml] and requires it |
76 |
48 |
to be installed in binary form (not necessary during build). |
to be installed in binary form (not necessary during build). |
|
... |
... |
equally well, it's seems to be good enough, especially for a ready to use parser |
81 |
53 |
that wasn't that hard to integrate. |
that wasn't that hard to integrate. |
82 |
54 |
|
|
83 |
55 |
Note the following: |
Note the following: |
|
56 |
|
|
84 |
57 |
* the tuning of comparison is in progress and will be refined over time |
* the tuning of comparison is in progress and will be refined over time |
85 |
58 |
|
|
86 |
|
#### GNU Make #### |
|
|
59 |
|
GNU Make |
|
60 |
|
-------- |
87 |
61 |
|
|
88 |
62 |
It's hard to measure level of support in case of GNU Make, because there seem to |
It's hard to measure level of support in case of GNU Make, because there seem to |
89 |
63 |
be no reference for the syntax itself apart from documentation, which is not |
be no reference for the syntax itself apart from documentation, which is not |
|
... |
... |
many features most people don't know exist. It's definitely not 100%, but 90% |
95 |
69 |
or even more of all existing Makefiles out there should be parsed. |
or even more of all existing Makefiles out there should be parsed. |
96 |
70 |
|
|
97 |
71 |
Note the following: |
Note the following: |
|
72 |
|
|
98 |
73 |
* the comparison might not produce best results on Makefiles as it needs |
* the comparison might not produce best results on Makefiles as it needs |
99 |
74 |
some tuning, this should happen over time (Makefiles aren't changed that |
some tuning, this should happen over time (Makefiles aren't changed that |
100 |
75 |
often) |
often) |
101 |
76 |
|
|
102 |
|
#### Lua #### |
|
103 |
|
|
|
104 |
|
Newly added (March 2021) with very little testing so far. However, the |
|
105 |
|
language is small and simple enough to not pose much difficulties. |
|
|
77 |
|
Lua |
|
78 |
|
--- |
106 |
79 |
|
|
107 |
80 |
Note the following: |
Note the following: |
|
81 |
|
|
108 |
82 |
* non-5.3 versions might still work, albeit can produce worse results |
* non-5.3 versions might still work, albeit can produce worse results |
109 |
83 |
|
|
110 |
|
#### Other #### |
|
|
84 |
|
Other |
|
85 |
|
----- |
111 |
86 |
|
|
112 |
87 |
More languages should be added in the future, maybe with external parsers that |
More languages should be added in the future, maybe with external parsers that |
113 |
88 |
are capable of preserving all information about the source code. |
are capable of preserving all information about the source code. |
114 |
89 |
|
|
115 |
|
### Configuration ### |
|
|
90 |
|
CONFIGURATION |
|
91 |
|
============= |
116 |
92 |
|
|
117 |
93 |
Configuration is done per directory tree ("root") which is the closes parent (or |
Configuration is done per directory tree ("root") which is the closes parent (or |
118 |
94 |
current directory) that contains `.zs/` directory. The `.zs/` directory |
current directory) that contains `.zs/` directory. The `.zs/` directory |
119 |
95 |
contains files which define how contents of the root is to be processed. |
contains files which define how contents of the root is to be processed. |
120 |
96 |
Settings from multiple nested roots are not combined. |
Settings from multiple nested roots are not combined. |
121 |
97 |
|
|
122 |
|
#### `.zs/exclude` file #### |
|
|
98 |
|
`.zs/exclude` file |
|
99 |
|
------------------ |
123 |
100 |
|
|
124 |
101 |
A `.gitignore`-like (or `.git/info/exclude`-like) file that lists paths relative |
A `.gitignore`-like (or `.git/info/exclude`-like) file that lists paths relative |
125 |
102 |
to the root. The purpose is to exclude uninteresting files (automatically |
to the root. The purpose is to exclude uninteresting files (automatically |
|
... |
... |
moc_*.h |
170 |
147 |
/config.h |
/config.h |
171 |
148 |
``` |
``` |
172 |
149 |
|
|
173 |
|
#### `.zs/attributes` file #### |
|
|
150 |
|
`.zs/attributes` file |
|
151 |
|
--------------------- |
174 |
152 |
|
|
175 |
153 |
Borrowing from the `git` project here again. This file consists of lines |
Borrowing from the `git` project here again. This file consists of lines |
176 |
154 |
matching paths to attributes. Lines are trimmed before being processed. |
matching paths to attributes. Lines are trimmed before being processed. |
|
... |
... |
another type of comments. |
187 |
165 |
Each line of the file is visited in top down order and attributes from every |
Each line of the file is visited in top down order and attributes from every |
188 |
166 |
matching entry are merged with the current state. Hierarchy of configuration |
matching entry are merged with the current state. Hierarchy of configuration |
189 |
167 |
values: |
values: |
|
168 |
|
|
190 |
169 |
1. Default values (lowest priority) |
1. Default values (lowest priority) |
191 |
170 |
2. Attributes |
2. Attributes |
192 |
171 |
3. Command-line parameters (highest priority) |
3. Command-line parameters (highest priority) |
|
... |
... |
tab-2.[ch] tab-size=2 |
218 |
197 |
# any.cpp has tab-size=4 |
# any.cpp has tab-size=4 |
219 |
198 |
``` |
``` |
220 |
199 |
|
|
221 |
|
## Tools ## |
|
|
200 |
|
INVOCATION |
|
201 |
|
========== |
222 |
202 |
|
|
223 |
|
### [zs-diff](tools/diff/README.md) ### |
|
|
203 |
|
All tools have common and specific command-line arguments. Tool-specific |
|
204 |
|
arguments are described on the page of the tool, common ones are below. |
224 |
205 |
|
|
225 |
|
A terminal-based syntax-aware diff. |
|
|
206 |
|
`-h`, `--help` \ |
|
207 |
|
print help message |
226 |
208 |
|
|
227 |
|
### [zs-find](tools/find/README.md) ### |
|
|
209 |
|
`--dry-run` \ |
|
210 |
|
parse and exit |
228 |
211 |
|
|
229 |
|
Grep-like tool that finds elements of source code structure. |
|
|
212 |
|
`--debug` \ |
|
213 |
|
enable debugging of grammar |
230 |
214 |
|
|
231 |
|
### [zs-gdiff](tools/gdiff/README.md) ### |
|
|
215 |
|
`--sdebug` \ |
|
216 |
|
enable debugging of strees |
232 |
217 |
|
|
233 |
|
A Qt5 GUI version of syntax-aware diff. |
|
|
218 |
|
`--dump-stree` \ |
|
219 |
|
display stree(s) |
234 |
220 |
|
|
235 |
|
### [zs-hi](tools/hi/README.md) ### |
|
|
221 |
|
`--dump-tree` \ |
|
222 |
|
display tree(s) |
236 |
223 |
|
|
237 |
|
Simple syntax highlighter for xterm-256color palette. |
|
|
224 |
|
`--time-report` \ |
|
225 |
|
report time spent on different activities |
238 |
226 |
|
|
239 |
|
### [zs-stats](tools/stats/README.md) ### |
|
|
227 |
|
`--fine-only` \ |
|
228 |
|
use only fine-grained tree |
240 |
229 |
|
|
241 |
|
Counter of lines of code. |
|
|
230 |
|
`--color` \ |
|
231 |
|
force colorization of output |
242 |
232 |
|
|
243 |
|
### [zs-tui](tools/tui/README.md) ### |
|
|
233 |
|
`--lang` _arg_ \ |
|
234 |
|
force specific language (`c`, `cxx`, `make`, `lua`) and disable auto-detection |
244 |
235 |
|
|
245 |
|
TUI interface with underdefined scope of functionality. |
|
246 |
|
|
|
247 |
|
## Building and Installing ## |
|
248 |
|
|
|
249 |
|
```bash |
|
250 |
|
# if Qt5 is available (use `qmake` if it corresponds to Qt5 on your machine) |
|
251 |
|
echo 'QT5_PROG := qmake-qt5' >> config.mk |
|
252 |
|
# if libgit2 is present |
|
253 |
|
echo 'HAVE_LIBGIT2 := yes' >> config.mk |
|
254 |
|
# if cursesw is present |
|
255 |
|
echo 'HAVE_CURSESW := yes' >> config.mk |
|
256 |
|
|
|
257 |
|
make release check |
|
258 |
|
``` |
|
259 |
|
|
|
260 |
|
This will build release version and run tests. The executables will be named |
|
261 |
|
`release/zs-*`. |
|
|
236 |
|
BEHAVIOUR |
|
237 |
|
========= |
262 |
238 |
|
|
263 |
|
There is no data, so just making them available in the `$PATH` will work. |
|
264 |
|
However, it's possible to install conventionally (`/usr` prefix by default): |
|
265 |
|
|
|
266 |
|
``` |
|
267 |
|
make install |
|
268 |
|
``` |
|
269 |
|
|
|
270 |
|
`DESTDIR` and `PREFIX` can be set to modify destination location. On invoking |
|
271 |
|
`make uninstall` same values of these values should be specified. |
|
272 |
|
|
|
273 |
|
### Dependencies ### |
|
274 |
|
|
|
275 |
|
* [GNU Make][make] |
|
276 |
|
* C++11-capable compiler (GCC 4.9 has some issues, GCC 5.3 works fine) |
|
277 |
|
* [flex][flex] |
|
278 |
|
* [GNU Bison][bison] v3+ |
|
279 |
|
* [Boost][boost], tested with 1.59, but older versions might work too |
|
280 |
|
* (optional, run-time, for C++) [srcml][srcml] (v0.9.5 and v1.0.0 were tested) |
|
281 |
|
* (optional, for `gdiff` tool) [qt5][qt5] |
|
282 |
|
* (optional, for `gdiff` tool) [libgit2][libgit2] |
|
283 |
|
* (optional, for `tui` tool) [curses][curses] with support of wide characters |
|
284 |
|
|
|
285 |
|
#### For Debian-based distributions #### |
|
286 |
|
|
|
287 |
|
If you are using Debian or one of its derivatives, you can install the |
|
288 |
|
dependencies as follows: |
|
289 |
|
|
|
290 |
|
```bash |
|
291 |
|
# install make and build tools |
|
292 |
|
sudo apt install -y build-essential |
|
293 |
|
# installing dependencies |
|
294 |
|
sudo apt install -y libboost-filesystem-dev libboost-iostreams-dev |
|
295 |
|
sudo apt install -y libboost-program-options-dev libboost-system-dev |
|
296 |
|
sudo apt install -y libarchive13 |
|
297 |
|
sudo apt install -y bison flex |
|
298 |
|
# installing srcml |
|
299 |
|
wget http://131.123.42.38/lmcrs/beta/srcML-Ubuntu18.04.deb |
|
300 |
|
sudo apt install ./srcML-Ubuntu18.04.deb |
|
301 |
|
``` |
|
|
239 |
|
Pager |
|
240 |
|
----- |
302 |
241 |
|
|
303 |
|
You can also check out the [CI build script](data/appveyor/ubuntu.sh) in case |
|
304 |
|
dependencies change in the future. |
|
|
242 |
|
When output is a terminal (not the case when invoked by Git), `less` is spawn |
|
243 |
|
if output is about the size of the screen. |
305 |
244 |
|
|
306 |
|
## Documentation ## |
|
|
245 |
|
Language detection |
|
246 |
|
------------------ |
307 |
247 |
|
|
308 |
|
At the moment there is only `--help` option. |
|
|
248 |
|
By default language is auto-detected based on file name. When name is not |
|
249 |
|
recognized the file is parsed as C. |
309 |
250 |
|
|
310 |
|
## License ## |
|
|
251 |
|
TOOLS |
|
252 |
|
===== |
311 |
253 |
|
|
312 |
|
![AGPLv3](data/agplv3.png) |
|
|
254 |
|
[**zs-diff**(1)](./zs-diff.md) |
313 |
255 |
|
|
314 |
|
Version 3 of the GNU Affero General Public License. |
|
315 |
|
|
|
316 |
|
## Credits ## |
|
317 |
|
|
|
318 |
|
[dtl library][dtl] is used for finding edit distance. |
|
319 |
|
|
|
320 |
|
[pmr implementation][pmr] from C++17 with a small addition is employed for |
|
321 |
|
custom allocators. |
|
322 |
|
|
|
323 |
|
[TinyXML2][tinyxml2] is used for parsing XML. |
|
|
256 |
|
A terminal-based syntax-aware diff. |
324 |
257 |
|
|
325 |
|
[tree-sitter][tree-sitter] is used for parsing of some languages. |
|
|
258 |
|
[**zs-find**(1)](./zs-find.md) |
326 |
259 |
|
|
327 |
|
[Catch2][catch] is used for tests. |
|
|
260 |
|
Grep-like tool that finds elements of source code structure. |
328 |
261 |
|
|
329 |
|
### References ### |
|
|
262 |
|
[**zs-gdiff**(1)](./zs-gdiff.md) |
330 |
263 |
|
|
331 |
|
[Change Distilling: Tree Differencing for Fine-Grained Source Code Change |
|
332 |
|
Extraction][cd]. |
|
333 |
|
Beat Fluri, Michael Würsch, Martin Pinzger, and Harald C. Gall. |
|
334 |
|
2007. |
|
|
264 |
|
A Qt5 GUI version of syntax-aware diff. |
335 |
265 |
|
|
336 |
|
[Change Detection in Hierarchically Structured Information][hier]. |
|
337 |
|
Sudarshan Chawathe, Hector Garcia-molina and Jennifer Widom. |
|
338 |
|
1996. |
|
|
266 |
|
[**zs-hi**(1)](./zs-hi.md) |
339 |
267 |
|
|
340 |
|
[Simple fast algorithms for the editing distance between trees and related |
|
341 |
|
problems][ted]. |
|
342 |
|
Kaizhong Zhang and Dennis Shasha. |
|
343 |
|
1989. |
|
|
268 |
|
Simple syntax highlighter for xterm-256color palette. |
344 |
269 |
|
|
345 |
|
[wiki-zograscope]: https://en.wikipedia.org/wiki/Zograscope |
|
|
270 |
|
[**zs-stats**(1)](./zs-stats.md) |
346 |
271 |
|
|
347 |
|
[make]: https://www.gnu.org/software/make/ |
|
348 |
|
[flex]: https://github.com/westes/flex |
|
349 |
|
[bison]: https://www.gnu.org/software/bison/ |
|
350 |
|
[boost]: http://www.boost.org/ |
|
351 |
|
[srcml]: http://www.srcml.org/ |
|
352 |
|
[qt5]: https://www.qt.io/ |
|
353 |
|
[libgit2]: https://libgit2.org/ |
|
354 |
|
[curses]: https://en.wikipedia.org/wiki/Curses_(programming_library) |
|
|
272 |
|
Counter of lines of code. |
355 |
273 |
|
|
356 |
|
[dtl]: https://github.com/cubicdaiya/dtl |
|
357 |
|
[pmr]: https://github.com/phalpern/CppCon2017Code |
|
358 |
|
[tinyxml2]: https://github.com/leethomason/tinyxml2 |
|
359 |
|
[tree-sitter]: https://tree-sitter.github.io/ |
|
360 |
|
[catch]: https://github.com/catchorg/Catch2 |
|
|
274 |
|
[**zs-tui**(1)](./zs-tui.md) |
361 |
275 |
|
|
362 |
|
[cd]: http://www.merlin.uzh.ch/publication/show/2531 |
|
363 |
|
[hier]: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.48.9224 |
|
364 |
|
[ted]: http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.460.5601 |
|
|
276 |
|
TUI interface with underdefined scope of functionality. |
File man/zograscope.7 added (mode: 100644) (index 0000000..42700d8) |
|
1 |
|
'\" t |
|
2 |
|
.\" Automatically generated by Pandoc 2.17.1.1 |
|
3 |
|
.\" |
|
4 |
|
.\" Define V font for inline verbatim, using C font in formats |
|
5 |
|
.\" that render this, and otherwise B font. |
|
6 |
|
.ie "\f[CB]x\f[]"x" \{\ |
|
7 |
|
. ftr V B |
|
8 |
|
. ftr VI BI |
|
9 |
|
. ftr VB B |
|
10 |
|
. ftr VBI BI |
|
11 |
|
.\} |
|
12 |
|
.el \{\ |
|
13 |
|
. ftr V CR |
|
14 |
|
. ftr VI CI |
|
15 |
|
. ftr VB CB |
|
16 |
|
. ftr VBI CBI |
|
17 |
|
.\} |
|
18 |
|
.TH "zograscope" "7" "July 19, 2022" "" "" |
|
19 |
|
.hy |
|
20 |
|
.SH NAME |
|
21 |
|
.PP |
|
22 |
|
\f[I]zograscope\f[R] is a collection of source-processing tools spawned |
|
23 |
|
out of syntax-aware diffing. |
|
24 |
|
.PP |
|
25 |
|
The nature of syntax-aware diff requires knowledge of structure of the |
|
26 |
|
code, which can be used to build other simple tools that can benefit |
|
27 |
|
from this information. |
|
28 |
|
Competing with real language front-ends in the level of accuracy is not |
|
29 |
|
possible, but making some things that are one step further than regular |
|
30 |
|
text-processing utilities seems feasible and the result might be even |
|
31 |
|
more practical than some of the more elaborate tools which end up |
|
32 |
|
requiring complicated setup process. |
|
33 |
|
.SH LANGUAGE SUPPORT |
|
34 |
|
.PP |
|
35 |
|
.TS |
|
36 |
|
tab(@); |
|
37 |
|
lw(9.9n) lw(60.1n). |
|
38 |
|
T{ |
|
39 |
|
Language |
|
40 |
|
T}@T{ |
|
41 |
|
Status |
|
42 |
|
T} |
|
43 |
|
_ |
|
44 |
|
T{ |
|
45 |
|
C |
|
46 |
|
T}@T{ |
|
47 |
|
C11 and earlier with common extensions, but without K&R syntax |
|
48 |
|
T} |
|
49 |
|
T{ |
|
50 |
|
C++ |
|
51 |
|
T}@T{ |
|
52 |
|
C++14 and earlier with common extensions |
|
53 |
|
T} |
|
54 |
|
T{ |
|
55 |
|
GNU Make |
|
56 |
|
T}@T{ |
|
57 |
|
Most of the syntax |
|
58 |
|
T} |
|
59 |
|
T{ |
|
60 |
|
Lua |
|
61 |
|
T}@T{ |
|
62 |
|
Version 5.3 |
|
63 |
|
T} |
|
64 |
|
.TE |
|
65 |
|
.SS C |
|
66 |
|
.PP |
|
67 |
|
The exact grammar is that of C11 with extensions implemented in popular |
|
68 |
|
compilers and additional extensions needed to allow processing of code |
|
69 |
|
with macros. |
|
70 |
|
.PP |
|
71 |
|
Note the following: |
|
72 |
|
.IP \[bu] 2 |
|
73 |
|
old K&R style of function declarations isn\[cq]t parsed (there might be |
|
74 |
|
a workaround for it, but this syntax is deprecated either way) |
|
75 |
|
.IP \[bu] 2 |
|
76 |
|
preprocessor directives aren\[cq]t tokenized according to language rules |
|
77 |
|
yet, but their contents is diffed |
|
78 |
|
.IP \[bu] 2 |
|
79 |
|
extensive use of macros in unusual places might not be parsed (this |
|
80 |
|
probably won\[cq]t change) |
|
81 |
|
.PP |
|
82 |
|
Other than that code in C89, C99, C11 and GNU-versions of C language |
|
83 |
|
should be recognized. |
|
84 |
|
.SS C++ |
|
85 |
|
.PP |
|
86 |
|
C++ support relies on external application called [srcml][srcml] and |
|
87 |
|
requires it to be installed in binary form (not necessary during build). |
|
88 |
|
.PP |
|
89 |
|
Reported standard version supported by \f[V]srcml\f[R] is C++14, so all |
|
90 |
|
previous ones should work too. |
|
91 |
|
Although their parser doesn\[cq]t handle all language constructs equally |
|
92 |
|
well, it\[cq]s seems to be good enough, especially for a ready to use |
|
93 |
|
parser that wasn\[cq]t that hard to integrate. |
|
94 |
|
.PP |
|
95 |
|
Note the following: |
|
96 |
|
.IP \[bu] 2 |
|
97 |
|
the tuning of comparison is in progress and will be refined over time |
|
98 |
|
.SS GNU Make |
|
99 |
|
.PP |
|
100 |
|
It\[cq]s hard to measure level of support in case of GNU Make, because |
|
101 |
|
there seem to be no reference for the syntax itself apart from |
|
102 |
|
documentation, which is not concise. |
|
103 |
|
.PP |
|
104 |
|
Yet parser is capable of processing quite complicated examples of |
|
105 |
|
Makefiles (like the one used in this project or generated by |
|
106 |
|
\f[V]automake\f[R]) which contain many features most people don\[cq]t |
|
107 |
|
know exist. |
|
108 |
|
It\[cq]s definitely not 100%, but 90% or even more of all existing |
|
109 |
|
Makefiles out there should be parsed. |
|
110 |
|
.PP |
|
111 |
|
Note the following: |
|
112 |
|
.IP \[bu] 2 |
|
113 |
|
the comparison might not produce best results on Makefiles as it needs |
|
114 |
|
some tuning, this should happen over time (Makefiles aren\[cq]t changed |
|
115 |
|
that often) |
|
116 |
|
.SS Lua |
|
117 |
|
.PP |
|
118 |
|
Note the following: |
|
119 |
|
.IP \[bu] 2 |
|
120 |
|
non-5.3 versions might still work, albeit can produce worse results |
|
121 |
|
.SS Other |
|
122 |
|
.PP |
|
123 |
|
More languages should be added in the future, maybe with external |
|
124 |
|
parsers that are capable of preserving all information about the source |
|
125 |
|
code. |
|
126 |
|
.SH CONFIGURATION |
|
127 |
|
.PP |
|
128 |
|
Configuration is done per directory tree (\[lq]root\[rq]) which is the |
|
129 |
|
closes parent (or current directory) that contains \f[V].zs/\f[R] |
|
130 |
|
directory. |
|
131 |
|
The \f[V].zs/\f[R] directory contains files which define how contents of |
|
132 |
|
the root is to be processed. |
|
133 |
|
Settings from multiple nested roots are not combined. |
|
134 |
|
.SS \f[V].zs/exclude\f[R] file |
|
135 |
|
.PP |
|
136 |
|
A \f[V].gitignore\f[R]-like (or \f[V].git/info/exclude\f[R]-like) file |
|
137 |
|
that lists paths relative to the root. |
|
138 |
|
The purpose is to exclude uninteresting files (automatically generated, |
|
139 |
|
third-party or otherwise). |
|
140 |
|
\f[V].zs/exclude\f[R] is used by tools that search for files |
|
141 |
|
automatically and doesn\[cq]t prevent the use of the same files when |
|
142 |
|
they are specified explicitly. |
|
143 |
|
.PP |
|
144 |
|
The following kinds of entries are recognized: |
|
145 |
|
.IP \[bu] 2 |
|
146 |
|
empty lines, which are ignored |
|
147 |
|
.IP \[bu] 2 |
|
148 |
|
lines that start with a \f[V]#\f[R] (comments), which are ignored |
|
149 |
|
.IP \[bu] 2 |
|
150 |
|
lines that end with \f[V]/\f[R] match only directories, the \f[V]/\f[R] |
|
151 |
|
is stripped and line processing continues |
|
152 |
|
.IP \[bu] 2 |
|
153 |
|
lines without \f[V]/\f[R] are treated as shell-like globs against |
|
154 |
|
filename which apply at any directory level and define paths whose |
|
155 |
|
processing should be skipped |
|
156 |
|
.IP \[bu] 2 |
|
157 |
|
lines that start with \f[V]!\f[R] define exception from rules that |
|
158 |
|
precede them, you can\[cq]t undo exclusion of files in excluded |
|
159 |
|
directories, for the purpose of this discussion the \f[V]!\f[R] is |
|
160 |
|
stripped and line processing continues |
|
161 |
|
.IP \[bu] 2 |
|
162 |
|
lines that start with \f[V]/\f[R] always match paths instead of filename |
|
163 |
|
and provide a way to specify files to be ignored only in the root, |
|
164 |
|
otherwise they are processed as specified in the next item |
|
165 |
|
.IP \[bu] 2 |
|
166 |
|
other lines are treated as shell-like globs against paths relative to |
|
167 |
|
the root (leading \f[V]/\f[R] is allowed, but has no effect other than |
|
168 |
|
changing type of a match) which define paths whose processing should be |
|
169 |
|
skipped |
|
170 |
|
.PP |
|
171 |
|
No way to escape leading \f[V]#\f[R] and \f[V]!\f[R] or a newline at the |
|
172 |
|
moment. |
|
173 |
|
.PP |
|
174 |
|
Globs support the following: \f[V][{char-class}]\f[R], |
|
175 |
|
\f[V][!{char-class}]\f[R], \f[V][\[ha]{char-class}]\f[R], \f[V]?\f[R] |
|
176 |
|
(doesn\[cq]t match \f[V]/\f[R]), \f[V]*\f[R] (matches any (including |
|
177 |
|
zero) number of characters except for \f[V]/\f[R]) and |
|
178 |
|
\f[V]\[rs]{char}\f[R] (matches literal \f[V]{char}\f[R]). |
|
179 |
|
.PP |
|
180 |
|
Example: |
|
181 |
|
.IP |
|
182 |
|
.nf |
|
183 |
|
\f[C] |
|
184 |
|
# .zs/exclude |
|
185 |
|
|
|
186 |
|
# automatically generated sources |
|
187 |
|
src/c/c11-lexer.gen.cpp |
|
188 |
|
src/c/c11-parser.gen.cpp |
|
189 |
|
src/make/*.gen.* |
|
190 |
|
|
|
191 |
|
# Qt-produced sources |
|
192 |
|
ui_*.h |
|
193 |
|
moc_*.cpp |
|
194 |
|
moc_*.h |
|
195 |
|
|
|
196 |
|
# file in root |
|
197 |
|
/config.h |
|
198 |
|
\f[R] |
|
199 |
|
.fi |
|
200 |
|
.SS \f[V].zs/attributes\f[R] file |
|
201 |
|
.PP |
|
202 |
|
Borrowing from the \f[V]git\f[R] project here again. |
|
203 |
|
This file consists of lines matching paths to attributes. |
|
204 |
|
Lines are trimmed before being processed. |
|
205 |
|
.PP |
|
206 |
|
Empty lines and comments work like in \f[V].zs/excludes\f[R] file, all |
|
207 |
|
other lines follow this pattern: |
|
208 |
|
.IP |
|
209 |
|
.nf |
|
210 |
|
\f[C] |
|
211 |
|
exclude-expr [attr1=value1 [attr2=value2 [...]]] |
|
212 |
|
\f[R] |
|
213 |
|
.fi |
|
214 |
|
.PP |
|
215 |
|
Expressions that define exceptions (start with \f[V]!\f[R]) are |
|
216 |
|
recognized but ignored to keep syntax consistent between different |
|
217 |
|
files, which basically makes them another type of comments. |
|
218 |
|
.PP |
|
219 |
|
Each line of the file is visited in top down order and attributes from |
|
220 |
|
every matching entry are merged with the current state. |
|
221 |
|
Hierarchy of configuration values: |
|
222 |
|
.IP "1." 3 |
|
223 |
|
Default values (lowest priority) |
|
224 |
|
.IP "2." 3 |
|
225 |
|
Attributes |
|
226 |
|
.IP "3." 3 |
|
227 |
|
Command-line parameters (highest priority) |
|
228 |
|
.PP |
|
229 |
|
Supported attributes: |
|
230 |
|
.IP \[bu] 2 |
|
231 |
|
\f[V]lang\f[R] |
|
232 |
|
.PD 0 |
|
233 |
|
.P |
|
234 |
|
.PD |
|
235 |
|
Default: \[lq]\[lq] |
|
236 |
|
.PD 0 |
|
237 |
|
.P |
|
238 |
|
.PD |
|
239 |
|
Those accepted by \f[V]--lang\f[R] command-line option: c, cxx, make, |
|
240 |
|
lua |
|
241 |
|
.IP \[bu] 2 |
|
242 |
|
\f[V]tab-size\f[R] |
|
243 |
|
.PD 0 |
|
244 |
|
.P |
|
245 |
|
.PD |
|
246 |
|
Default: 4 |
|
247 |
|
.PD 0 |
|
248 |
|
.P |
|
249 |
|
.PD |
|
250 |
|
Value should be an integer that\[cq]s greater than zero |
|
251 |
|
.PP |
|
252 |
|
Unknown attributes are ignored. |
|
253 |
|
.PP |
|
254 |
|
Example: |
|
255 |
|
.IP |
|
256 |
|
.nf |
|
257 |
|
\f[C] |
|
258 |
|
# .zs/exclude |
|
259 |
|
|
|
260 |
|
*.c tab-size=8 |
|
261 |
|
*.h tab-size=8 lang=c |
|
262 |
|
tab-2.[ch] tab-size=2 |
|
263 |
|
|
|
264 |
|
# any.c has tab-size=8 |
|
265 |
|
# tab-2.c has tab-size=2 |
|
266 |
|
# tab-2.h has tab-size=2 lang=c |
|
267 |
|
# any.h has tab-size=8 lang=c |
|
268 |
|
# any.cpp has tab-size=4 |
|
269 |
|
\f[R] |
|
270 |
|
.fi |
|
271 |
|
.SH INVOCATION |
|
272 |
|
.PP |
|
273 |
|
All tools have common and specific command-line arguments. |
|
274 |
|
Tool-specific arguments are described on the page of the tool, common |
|
275 |
|
ones are below. |
|
276 |
|
.PP |
|
277 |
|
\f[V]-h\f[R], \f[V]--help\f[R] |
|
278 |
|
.PD 0 |
|
279 |
|
.P |
|
280 |
|
.PD |
|
281 |
|
print help message |
|
282 |
|
.PP |
|
283 |
|
\f[V]--dry-run\f[R] |
|
284 |
|
.PD 0 |
|
285 |
|
.P |
|
286 |
|
.PD |
|
287 |
|
parse and exit |
|
288 |
|
.PP |
|
289 |
|
\f[V]--debug\f[R] |
|
290 |
|
.PD 0 |
|
291 |
|
.P |
|
292 |
|
.PD |
|
293 |
|
enable debugging of grammar |
|
294 |
|
.PP |
|
295 |
|
\f[V]--sdebug\f[R] |
|
296 |
|
.PD 0 |
|
297 |
|
.P |
|
298 |
|
.PD |
|
299 |
|
enable debugging of strees |
|
300 |
|
.PP |
|
301 |
|
\f[V]--dump-stree\f[R] |
|
302 |
|
.PD 0 |
|
303 |
|
.P |
|
304 |
|
.PD |
|
305 |
|
display stree(s) |
|
306 |
|
.PP |
|
307 |
|
\f[V]--dump-tree\f[R] |
|
308 |
|
.PD 0 |
|
309 |
|
.P |
|
310 |
|
.PD |
|
311 |
|
display tree(s) |
|
312 |
|
.PP |
|
313 |
|
\f[V]--time-report\f[R] |
|
314 |
|
.PD 0 |
|
315 |
|
.P |
|
316 |
|
.PD |
|
317 |
|
report time spent on different activities |
|
318 |
|
.PP |
|
319 |
|
\f[V]--fine-only\f[R] |
|
320 |
|
.PD 0 |
|
321 |
|
.P |
|
322 |
|
.PD |
|
323 |
|
use only fine-grained tree |
|
324 |
|
.PP |
|
325 |
|
\f[V]--color\f[R] |
|
326 |
|
.PD 0 |
|
327 |
|
.P |
|
328 |
|
.PD |
|
329 |
|
force colorization of output |
|
330 |
|
.PP |
|
331 |
|
\f[V]--lang\f[R] \f[I]arg\f[R] |
|
332 |
|
.PD 0 |
|
333 |
|
.P |
|
334 |
|
.PD |
|
335 |
|
force specific language (\f[V]c\f[R], \f[V]cxx\f[R], \f[V]make\f[R], |
|
336 |
|
\f[V]lua\f[R]) and disable auto-detection |
|
337 |
|
.SH BEHAVIOUR |
|
338 |
|
.SS Pager |
|
339 |
|
.PP |
|
340 |
|
When output is a terminal (not the case when invoked by Git), |
|
341 |
|
\f[V]less\f[R] is spawn if output is about the size of the screen. |
|
342 |
|
.SS Language detection |
|
343 |
|
.PP |
|
344 |
|
By default language is auto-detected based on file name. |
|
345 |
|
When name is not recognized the file is parsed as C. |
|
346 |
|
.SH TOOLS |
|
347 |
|
.PP |
|
348 |
|
\f[B]zs-diff\f[R](1) |
|
349 |
|
.PP |
|
350 |
|
A terminal-based syntax-aware diff. |
|
351 |
|
.PP |
|
352 |
|
\f[B]zs-find\f[R](1) |
|
353 |
|
.PP |
|
354 |
|
Grep-like tool that finds elements of source code structure. |
|
355 |
|
.PP |
|
356 |
|
\f[B]zs-gdiff\f[R](1) |
|
357 |
|
.PP |
|
358 |
|
A Qt5 GUI version of syntax-aware diff. |
|
359 |
|
.PP |
|
360 |
|
\f[B]zs-hi\f[R](1) |
|
361 |
|
.PP |
|
362 |
|
Simple syntax highlighter for xterm-256color palette. |
|
363 |
|
.PP |
|
364 |
|
\f[B]zs-stats\f[R](1) |
|
365 |
|
.PP |
|
366 |
|
Counter of lines of code. |
|
367 |
|
.PP |
|
368 |
|
\f[B]zs-tui\f[R](1) |
|
369 |
|
.PP |
|
370 |
|
TUI interface with underdefined scope of functionality. |
|
371 |
|
.SH AUTHORS |
|
372 |
|
xaizek <xaizek@posteo.net>. |
File man/zs-diff.1 added (mode: 100644) (index 0000000..ffc59a6) |
|
1 |
|
.\" Automatically generated by Pandoc 2.17.1.1 |
|
2 |
|
.\" |
|
3 |
|
.\" Define V font for inline verbatim, using C font in formats |
|
4 |
|
.\" that render this, and otherwise B font. |
|
5 |
|
.ie "\f[CB]x\f[]"x" \{\ |
|
6 |
|
. ftr V B |
|
7 |
|
. ftr VI BI |
|
8 |
|
. ftr VB B |
|
9 |
|
. ftr VBI BI |
|
10 |
|
.\} |
|
11 |
|
.el \{\ |
|
12 |
|
. ftr V CR |
|
13 |
|
. ftr VI CI |
|
14 |
|
. ftr VB CB |
|
15 |
|
. ftr VBI CBI |
|
16 |
|
.\} |
|
17 |
|
.TH "zs-diff" "1" "July 19, 2022" "" "" |
|
18 |
|
.hy |
|
19 |
|
.SH NAME |
|
20 |
|
.PP |
|
21 |
|
\f[I]zs-diff\f[R] is a terminal-based syntax-aware diff. |
|
22 |
|
The syntax-aware part means that comparison isn\[cq]t sensible to |
|
23 |
|
formatting changes and understands general structure of its input. |
|
24 |
|
.PP |
|
25 |
|
The primary purpose of the utility is to be used as external diff by |
|
26 |
|
\f[V]git\f[R]. |
|
27 |
|
.SH INVOCATION |
|
28 |
|
.SS Manual Form |
|
29 |
|
.PP |
|
30 |
|
\f[V]zs-diff\f[R] \f[V][options...]\f[R] \f[I]old-file\f[R] |
|
31 |
|
\f[I]new-file\f[R] |
|
32 |
|
.PP |
|
33 |
|
To be used in a shell. |
|
34 |
|
.SS Git Form |
|
35 |
|
.PP |
|
36 |
|
\f[V]zs-diff\f[R] \f[V][options...]\f[R] \f[I]path\f[R] |
|
37 |
|
\f[I]old-file\f[R] \f[I]old-hex\f[R] \f[I]old-mode\f[R] |
|
38 |
|
\f[I]new-file\f[R] \f[I]new-hex\f[R] \f[I]new-mode\f[R] |
|
39 |
|
.PP |
|
40 |
|
When Git calls external diff for a changed file. |
|
41 |
|
.SS Git Rename Form |
|
42 |
|
.PP |
|
43 |
|
\f[V]zs-diff\f[R] \f[V][options...]\f[R] \f[I]path\f[R] |
|
44 |
|
\f[I]old-file\f[R] \f[I]old-hex\f[R] \f[I]old-mode\f[R] |
|
45 |
|
\f[I]new-file\f[R] \f[I]new-hex\f[R] \f[I]new-mode\f[R] |
|
46 |
|
\f[I]new-path\f[R] \f[I]rename-msg\f[R] |
|
47 |
|
.PP |
|
48 |
|
When Git calls external diff for renamed and possibly changed file. |
|
49 |
|
.SS Tool-specific Options |
|
50 |
|
.PP |
|
51 |
|
\f[V]--no-refine\f[R] |
|
52 |
|
.PD 0 |
|
53 |
|
.P |
|
54 |
|
.PD |
|
55 |
|
do not refine coarse results |
|
56 |
|
.SH USAGE AND BEHAVIOUR |
|
57 |
|
.SS Invoking manually |
|
58 |
|
.PP |
|
59 |
|
Just do: |
|
60 |
|
.IP |
|
61 |
|
.nf |
|
62 |
|
\f[C] |
|
63 |
|
zs-diff old-file new-file |
|
64 |
|
\f[R] |
|
65 |
|
.fi |
|
66 |
|
.SS When Invoked by Git |
|
67 |
|
.PP |
|
68 |
|
If parsing fails when Git-like invocation is used, the tool attempts to |
|
69 |
|
invoke \f[V]git\f[R] with \f[V]--no-ext-diff\f[R] to do the diff. |
|
70 |
|
Unfortunately, Git doesn\[cq]t supply enough information for a proper |
|
71 |
|
invocation and \f[V]git\f[R]-header you\[cq]ll see will be with blob |
|
72 |
|
hashes or temporary paths. |
|
73 |
|
.SS Use with Git without Configuration |
|
74 |
|
.PP |
|
75 |
|
Use \f[V]$GIT_EXTERNAL_DIFF\f[R]: |
|
76 |
|
.IP |
|
77 |
|
.nf |
|
78 |
|
\f[C] |
|
79 |
|
GIT_EXTERNAL_DIFF=\[aq]zs-diff --color\[aq] git show --ext-diff |
|
80 |
|
\f[R] |
|
81 |
|
.fi |
|
82 |
|
.SS Local Git integration |
|
83 |
|
.PP |
|
84 |
|
Add \f[V]zs-diff\f[R] as a diff tool to \f[V]git\f[R] with these lines |
|
85 |
|
(\f[V].git/config\f[R]): |
|
86 |
|
.IP |
|
87 |
|
.nf |
|
88 |
|
\f[C] |
|
89 |
|
[diff \[dq]zs-diff\[dq]] |
|
90 |
|
command = zs-diff --color |
|
91 |
|
\f[R] |
|
92 |
|
.fi |
|
93 |
|
.PP |
|
94 |
|
Then configure which files it should be used for |
|
95 |
|
(\f[V].git/info/attributes\f[R]): |
|
96 |
|
.IP |
|
97 |
|
.nf |
|
98 |
|
\f[C] |
|
99 |
|
*.[ch] diff=zs-diff |
|
100 |
|
*.h.in diff=zs-diff |
|
101 |
|
|
|
102 |
|
*.[ch]pp diff=zs-diff |
|
103 |
|
|
|
104 |
|
Makefile diff=zs-diff |
|
105 |
|
Makefile.am diff=zs-diff |
|
106 |
|
Makefile.win diff=zs-diff |
|
107 |
|
|
|
108 |
|
*.lua diff=zs-diff |
|
109 |
|
\f[R] |
|
110 |
|
.fi |
|
111 |
|
.PP |
|
112 |
|
This will make it work for \f[V]git diff\f[R] and \f[V]git show\f[R], |
|
113 |
|
but \f[V]git log\f[R] and other subcommands don\[cq]t use custom diff |
|
114 |
|
tools by default and need \f[V]--ext-diff\f[R] option to be specified |
|
115 |
|
(can be done in an alias). |
|
116 |
|
.SS Global Git integration |
|
117 |
|
.PP |
|
118 |
|
Same as above, but specify attributes in |
|
119 |
|
\f[V]\[ti]/.config/git/attributes\f[R] and use one of the following |
|
120 |
|
files for configuration: |
|
121 |
|
.IP \[bu] 2 |
|
122 |
|
\f[V]\[ti]/.config/git/config\f[R] |
|
123 |
|
.IP \[bu] 2 |
|
124 |
|
\f[V]\[ti]/.gitconfig\f[R] |
|
125 |
|
.SS Explicit use in Git |
|
126 |
|
.PP |
|
127 |
|
Interactive (say \f[V]y\f[R] to view specific file): |
|
128 |
|
.IP |
|
129 |
|
.nf |
|
130 |
|
\f[C] |
|
131 |
|
git difftool -x zs-diff |
|
132 |
|
\f[R] |
|
133 |
|
.fi |
|
134 |
|
.SH SEE ALSO |
|
135 |
|
.PP |
|
136 |
|
\f[B]zograscope\f[R](7) for common options and list of all tools there. |
|
137 |
|
.SH AUTHORS |
|
138 |
|
xaizek <xaizek@posteo.net>. |
File tools/diff/README.md changed (mode: 100644) (index defcfbb..074b99f) |
... |
... |
Complicated changes of expressions or rewrites of functions might produce |
21 |
21 |
results that are hard to understand. Small or medium changes should be mostly |
results that are hard to understand. Small or medium changes should be mostly |
22 |
22 |
handled well. |
handled well. |
23 |
23 |
|
|
|
24 |
|
## Documentation ## |
|
25 |
|
|
|
26 |
|
See the [manual page][manual] for more details. |
|
27 |
|
|
24 |
28 |
## Comparison ## |
## Comparison ## |
25 |
29 |
|
|
|
30 |
|
(This section is outdated and needs an update.) |
|
31 |
|
|
26 |
32 |
This section presents various kinds of alternative diffs and demonstrates why |
This section presents various kinds of alternative diffs and demonstrates why |
27 |
33 |
syntax-aware ones are useful. |
syntax-aware ones are useful. |
28 |
34 |
|
|
|
... |
... |
Fine-grained matching would benefit from improvements as well as change |
81 |
87 |
detection for more complicated cases in general, but changes that were applied |
detection for more complicated cases in general, but changes that were applied |
82 |
88 |
to this piece of code are quite easy to see and reason about. |
to this piece of code are quite easy to see and reason about. |
83 |
89 |
|
|
84 |
|
## Running without integration ## |
|
85 |
|
|
|
86 |
|
### Outside git repository ### |
|
87 |
|
|
|
88 |
|
Just do: |
|
89 |
|
|
|
90 |
|
```bash |
|
91 |
|
zs-diff old-file new-file |
|
92 |
|
``` |
|
93 |
|
|
|
94 |
|
### Inside git repository ### |
|
95 |
|
|
|
96 |
|
Interactive (say `y` to view specific file): |
|
97 |
|
|
|
98 |
|
```bash |
|
99 |
|
git difftool -x zs-diff |
|
100 |
|
``` |
|
101 |
|
|
|
102 |
|
Non-interactive (there might be errors printed for files that are failed to |
|
103 |
|
parse, which is fine): |
|
104 |
|
|
|
105 |
|
```bash |
|
106 |
|
GIT_EXTERNAL_DIFF='zs-diff --color' git show --ext-diff |
|
107 |
|
``` |
|
108 |
|
|
|
109 |
|
## Integrating into Git ## |
|
110 |
|
|
|
111 |
|
### For a single repository ### |
|
112 |
|
|
|
113 |
|
Add `zs-diff` as a diff tool to `git` with these lines (`.git/config`): |
|
114 |
|
|
|
115 |
|
```gitconfig |
|
116 |
|
[diff "zs-diff"] |
|
117 |
|
command = zs-diff --color |
|
118 |
|
``` |
|
119 |
|
|
|
120 |
|
Then configure which files it should be used for (`.git/info/attributes`): |
|
121 |
|
|
|
122 |
|
```gitattributes |
|
123 |
|
*.[ch] diff=zs-diff |
|
124 |
|
*.h.in diff=zs-diff |
|
125 |
|
|
|
126 |
|
*.[ch]pp diff=zs-diff |
|
127 |
|
|
|
128 |
|
Makefile diff=zs-diff |
|
129 |
|
Makefile.am diff=zs-diff |
|
130 |
|
Makefile.win diff=zs-diff |
|
131 |
|
|
|
132 |
|
*.lua diff=zs-diff |
|
133 |
|
``` |
|
134 |
|
|
|
135 |
|
This will make it work for `git diff`, but `git show`, `git log` or other |
|
136 |
|
subcommands don't use custom diff tools by default and require `--ext-diff` |
|
137 |
|
option to be specified and might require use of an alias. |
|
138 |
|
|
|
139 |
|
If parsing or comparison failed for some reason, `git diff --no-ext` will be |
|
140 |
|
called to produce diff so in the worst case a regular diff will be displayed. |
|
141 |
|
|
|
142 |
|
### Globally ### |
|
143 |
|
|
|
144 |
|
Same as above, but specify attributes in `~/.config/git/attributes` and use one of the following files for configuration: |
|
145 |
|
|
|
146 |
|
* `~/.config/git/config` |
|
147 |
|
* `~/.gitconfig` |
|
148 |
|
|
|
149 |
90 |
[zograscope]: ../../README.md |
[zograscope]: ../../README.md |
150 |
91 |
|
|
|
92 |
|
[manual]: ../../docs/zs-diff.md |
151 |
93 |
[diff-highlight]: https://github.com/git/git/tree/master/contrib/diff-highlight |
[diff-highlight]: https://github.com/git/git/tree/master/contrib/diff-highlight |
152 |
94 |
[cdiff]: https://github.com/ymattw/cdiff |
[cdiff]: https://github.com/ymattw/cdiff |
153 |
95 |
[icdiff]: https://www.jefftk.com/icdiff |
[icdiff]: https://www.jefftk.com/icdiff |