summary refs log tree commit diff
path: root/www/text.causal.agency/026-git-comment.7
blob: fefb497ea961fc004cf5e12500c586106bf076d4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
.Dd September 10, 2021
.Dt GIT-COMMENT 7
.Os "Causal Agency"
.
.Sh NAME
.Nm git-comment
.Nd add comments from commit messages
.
.Sh SYNOPSIS
.Nm git comment
.Op Fl \-all
.Op Fl \-comment-start Ar string
.Op Fl \-comment-lead Ar string
.Op Fl \-comment-end Ar string
.Op Fl \-min-group Ar lines
.Op Fl \-min-repeat Ar lines
.Op Fl \-no-repeat
.Op Fl \-pretty Ar format
.Op Ar options ...
.Op Fl \-
.Ar file
.
.Sh DESCRIPTION
The
.Nm
command
adds comments to a file
showing the commit messages
which last modified
each group of lines.
By default only commit messages with bodies
and which modified groups of at least 2 lines
are added.
Each comment contains
the abbreviated commit hash
and the commit summary,
followed by the commit body.
.
.Pp
.Nm
accepts all the options of
.Xr git-blame 1
in addition to the following:
.Bl -tag -width Ds
.It Fl \-all
Include all commit messages.
The default is to include
only commit messages with bodies
(lines after the summary).
.
.It Fl \-comment-start Ar string
Start comments with
.Ar string .
The default is the value of
.Cm comment.start
or
.Ql /* .
.
.It Fl \-comment-lead Ar string
Continue comments with the leading
.Ar string .
The default is the value of
.Cm comment.lead
or
.Ql " *" .
.
.It Fl \-comment-end Ar string
End comments with
.Ar string .
The default is the value of
.Cm comment.end
or
.Ql " */" .
.
.It Fl \-min-group Ar lines
Add comments only for groups of at least
.Ar lines .
The default is 2 lines.
.
.It Fl \-min-repeat Ar lines
Avoid repeating a comment
if it occurred in the last
.Ar lines .
The default is 30 lines.
.
.It Fl \-no-repeat
Avoid repeating comments entirely.
.
.It Fl \-pretty Ar format
Set the pretty-print format
to use for commit messages.
The default is the value of
.Cm comment.pretty
or
.Ql format:%h\ %s%n%n%-b .
See
.Xr git-show 1 .
.El
.
.Sh EXAMPLES
For files with
.Ql #
comments:
.Bd -literal -offset indent
git config comment.start '#'
git config comment.lead '#'
git config comment.end ''
.Ed
.
.Pp
Add as many comments as possible:
.Bd -literal -offset indent
git comment --all --min-group 1 --min-repeat 1
.Ed
.
.Pp
Some examples of output from
.Xr catgirl 1 :
.Bd -literal
/* 347e2b4 Don't apply uiThreshold to Network and Debug
 *
 * Messages don't really need to be hidden from <network> and I think
 * it could be confusing. Debug messages are all Cold so everything
 * would be hidden, and I want to keep them that way so that <debug>
 * doesn't clutter the status line needlessly.
 */
if (id == Network || id == Debug) {
	window->thresh = Cold;
} else {
	window->thresh = uiThreshold;
}

/* b4c26a2 Measure timestamp width using ncurses
 *
 * This allows for non-ASCII characters in timestamps, and simplifies
 * things by including the trailing space in the width.
 */
int y;
char buf[TimeCap];
struct tm *time = localtime(&(time_t) { -22100400 });
size_t len = strftime(buf, sizeof(buf), uiTime.format, time);
if (!len) errx(EX_CONFIG, "invalid timestamp format: %s", uiTime.format);
waddstr(main, buf);
waddch(main, ' ');
getyx(main, y, uiTime.width);
(void)y;

/* 43b1dba Restore toggling ignore with M--
 *
 * So that pressing M-- repeatedly maintains the previous behavior.
 */
if (n < 0 && window->thresh == Ice) {
	window->thresh = Cold;
} else {
	window->thresh += n;
}

/* 1891c77 Preserve colon from previous tab-complete
 *
 * This fixes the case when pinging multiple nicks and one of them needs to
 * be cycled through.
 */
bool colon = (tab.len >= 2 && buf[tab.pos + tab.len - 2] == L':');
.Ed
.
.Sh SEE ALSO
.Lk https://git.causal.agency/src/tree/bin/git-comment.pl
.
.Sh AUTHORS
.An june Aq Mt june@causal.agency
.
.Pp
In case it's unclear,
this is a
.Xr git 1
subcommand I wrote.
Did you know you can add new
.Xr git 1
subcommands just by
adding executables named
.Pa git-*
to somewhere in
.Ev PATH ?
.
.Pp
This is also,
I think,
my third Perl script ever.
It's an interestingly shaped language.
Quite neat.
-pink/commit/filter.c?id=0c4d76755b98bb597279a1930bf4c69eca7dde62&follow=1'>filter: don't use dlsym unnecessarilyJohn Keeping We only need to hook write() if Lua filter's are in use. If support has been disabled, remove the dependency on dlsym(). Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13ui-tree: use "sane" isgraph()John Keeping Git's git-compat-util.h defines a "sane ctype" that does not use locale information and works with signed chars, but it does not include isgraph() so we have included ctype.h ourselves. However, this means we have to include a system header before git-compat-util.h which may lead to the system defining some macros (e.g. _FILE_OFFSET_BITS on Solaris) before git-compat-util.h redefines them with a different value. We cannot include ctype.h after git-compat-util.h because we have defined many of its functions as macros which causes a stream of compilation errors. Defining our own "sane" isgraph() using Git's sane isprint() and isspace() avoids all of these problems. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13cgit.h: move stdbool.h from ui-shared.hJohn Keeping Follow the Git policy of including system headers in only one place. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13cache.c: fix header orderJohn Keeping git-compat-util.h may define values that affect how system headers are interpreted, so move sys/sendfile.h after cgit.h (which includes git-compat-util.h). Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13configfile.c: don't include system headers directlyJohn Keeping git-compat-util.h may define various values that affect the interpretation of system headers. In most places we include cgit.h first, which pulls in git-compat-util.h, but this file does not depend on anything else in CGit, so use git-compat-util.h directly. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13Remove redundant includesJohn Keeping These are all included in git-compat-util.h (when necessary), which we include in cgit.h. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13Makefile: include Git's config.mak.unameJohn Keeping This pulls in the correct value of $(INSTALL) on a wide variety of systems. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13tests: allow shell to be overriddenJohn Keeping On some systems (e.g. Solaris), /bin/sh is not a POSIX shell. Git already provides suitable overrides in its config.mak.uname file and we provide cgit.conf to allow the user to further change this. The code for this is taken from Git's t/Makefile, meaning that we now invoke the tests in the same way that Git does. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-13redirect: cleanlinessJason A. Donenfeld 2015-08-13redirect: be more careful for different cgi setupsJason A. Donenfeld 2015-08-12ui-log: fix double countingJohn Keeping This crept in while rebasing the previous commit onto an updated upstream. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-12log: allow users to follow a fileJohn Keeping Teach the "log" UI to behave in the same way as "git log --follow", when given a suitable instruction by the user. The default behaviour remains to show the log without following renames, but the follow behaviour can be activated by following a link in the page header. Follow is not the default because outputting merges in follow mode is tricky ("git log --follow" will not show merges). We also disable the graph in follow mode because the commit graph is not simplified so we end up with frequent gaps in the graph and many lines that do not connect with any commits we're actually showing. We also teach the "diff" and "commit" UIs to respect the follow flag on URLs, causing the single-file version of these UIs to detect renames. This feature is needed only for commits that rename the path we're interested in. For commits before the file has been renamed (i.e. that appear later in the log list) we change the file path in the links from the log to point to the old name; this means that links to commits always limit by the path known to that commit. If we didn't do this we would need to walk down the log diff'ing every commit whenever we want to show a commit. The drawback is that the "Log" link in the top bar of such a page links to the log limited by the old name, so it will only show pre-rename commits. I consider this a reasonable trade-off since the "Back" button still works and the log matches the path displayed in the top bar. Since following renames requires running diff on every commit we consider, I've added a knob to the configuration file to globally enable/disable this feature. Note that we may consider a large number of commits the revision walking machinery no longer performs any path limitation so we have to examine every commit until we find a page full of commits that affect the target path or something related to it. Suggested-by: René Neumann <necoro@necoro.eu> Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-12shared: make cgit_diff_tree_cb publicJohn Keeping This will allow us to use this nice wrapper function elsewhere, avoiding dealing with the diff queue when we only need to inspect a filepair. Signed-off-by: John Keeping <john@keeping.me.uk> 2015-08-12t0110: Chain together using &&Jason A. Donenfeld 2015-08-12about: always ensure page has a trailing slashJason A. Donenfeld Otherwise we can't easily embed links to other /about/ pages. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2015-08-12filters: apply HTML escapingLazaros Koromilas http://www.w3.org/International/questions/qa-escapes#use 2015-08-12git: update to v2.5.0Christian Hesse Update to git version v2.5.0. * Upstream commit 5455ee0573a22bb793a7083d593ae1ace909cd4c (Merge branch 'bc/object-id') changed API: for_each_ref() callback functions were taught to name the objects not with "unsigned char sha1[20]" but with "struct object_id". * Upstream commit dcf692625ac569fefbe52269061230f4fde10e47 (path.c: make get_pathname() call sites return const char *) Signed-off-by: Christian Hesse <mail@eworm.de> 2015-08-12Fix processing of repo.hide and repo.ignoreDaniel Reichelt