Commit 9503576
committed
pretty: refactor
The function 'format_sanitized_subject()' is responsible for
sanitized subject line in pretty.c
e.g.
the subject line
the-sanitized-subject-line
It would be a nice enhancement to `subject` atom to have the
same feature. So in the later commits, we plan to add this feature
to ref-filter.
Refactor `format_sanitized_subject()`, so it can be reused in
ref-filter.c for adding new modifier `sanitize` to "subject" atom.
Currently, the loop inside `format_sanitized_subject()` runs
until `\n` is found. But now, we stored the first occurrence
of `\n` in a variable `eol` and passed it in
`format_sanitized_subject()`. And the loop runs upto `eol`.
But this change isn't sufficient to reuse this function in
ref-filter.c because there exist tags with multiline subject.
It's wise to replace `\n` with ' ', if `format_sanitized_subject()`
encounters `\n` before end of subject line, just like `copy_subject()`.
Because we'll be only using `format_sanitized_subject()` for
"%(subject:sanitize)", instead of `copy_subject()` and
`format_sanitized_subject()` both. So, added the code:
```
if (char == '\n') /* never true if called inside pretty.c */
char = ' ';
```
Now, it's ready to be reused in ref-filter.c
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Heba Waly <heba.waly@gmail.com>
Signed-off-by: Hariom Verma <hariom18599@gmail.com>format_sanitized_subject()
1 parent 764bb23 commit 9503576
1 file changed
Lines changed: 15 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
842 | | - | |
| 842 | + | |
843 | 843 | | |
| 844 | + | |
844 | 845 | | |
845 | 846 | | |
846 | 847 | | |
| 848 | + | |
847 | 849 | | |
848 | | - | |
849 | | - | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
850 | 854 | | |
851 | 855 | | |
852 | 856 | | |
853 | | - | |
854 | | - | |
855 | | - | |
856 | | - | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
857 | 861 | | |
858 | 862 | | |
859 | 863 | | |
| 864 | + | |
860 | 865 | | |
861 | 866 | | |
862 | 867 | | |
| |||
1155 | 1160 | | |
1156 | 1161 | | |
1157 | 1162 | | |
1158 | | - | |
| 1163 | + | |
1159 | 1164 | | |
1160 | 1165 | | |
1161 | 1166 | | |
| |||
1405 | 1410 | | |
1406 | 1411 | | |
1407 | 1412 | | |
1408 | | - | |
| 1413 | + | |
| 1414 | + | |
1409 | 1415 | | |
1410 | 1416 | | |
1411 | 1417 | | |
| |||
0 commit comments