Commit d04520e
reset: give better reflog messages
The reset command creates its reflog entry from argv.
However, it does so after having run parse_options, which
means the only thing left in argv is any non-option
arguments. Thus you would end up with confusing reflog
entries like:
$ git reset --hard HEAD^
$ git reset --soft HEAD@{1}
$ git log -2 -g --oneline
8e46cad HEAD@{0}: HEAD@{1}: updating HEAD
1eb9486 HEAD@{1}: HEAD^: updating HEAD
However, we must also consider that some scripts may set
GIT_REFLOG_ACTION before calling reset, and we need to show
their reflog action (with our text appended). For example:
rebase -i (squash): updating HEAD
On top of that, we also set the ORIG_HEAD reflog action
(even though it doesn't generally exist). In that case, the
reset argument is somewhat meaningless, as it has nothing to
do with what's in ORIG_HEAD.
This patch changes the reset reflog code to show:
$GIT_REFLOG_ACTION: updating {HEAD,ORIG_HEAD}
as before, but only if GIT_REFLOG_ACTION is set. Otherwise,
show:
reset: moving to $rev
for HEAD, and:
reset: updating ORIG_HEAD
for ORIG_HEAD (this is still somewhat superfluous, since we
are in the ORIG_HEAD reflog, obviously, but at least we now
mention which command was used to update it).
While we're at it, we can clean up the code a bit:
- Use strbufs to make the message.
- Use the "rev" parameter instead of showing all options.
This makes more sense, since it is the only thing
impacting the writing of the ref.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 0dc310e commit d04520e
2 files changed
Lines changed: 20 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | 36 | | |
56 | 37 | | |
57 | 38 | | |
| |||
215 | 196 | | |
216 | 197 | | |
217 | 198 | | |
218 | | - | |
| 199 | + | |
| 200 | + | |
219 | 201 | | |
220 | | - | |
221 | 202 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
226 | 211 | | |
227 | 212 | | |
228 | 213 | | |
| |||
241 | 226 | | |
242 | 227 | | |
243 | 228 | | |
244 | | - | |
| 229 | + | |
245 | 230 | | |
246 | 231 | | |
247 | 232 | | |
| |||
261 | 246 | | |
262 | 247 | | |
263 | 248 | | |
264 | | - | |
265 | | - | |
266 | 249 | | |
267 | 250 | | |
268 | 251 | | |
| |||
357 | 340 | | |
358 | 341 | | |
359 | 342 | | |
360 | | - | |
361 | | - | |
| 343 | + | |
| 344 | + | |
362 | 345 | | |
363 | 346 | | |
364 | 347 | | |
365 | | - | |
366 | | - | |
| 348 | + | |
| 349 | + | |
367 | 350 | | |
368 | 351 | | |
369 | 352 | | |
| |||
380 | 363 | | |
381 | 364 | | |
382 | 365 | | |
383 | | - | |
| 366 | + | |
384 | 367 | | |
385 | 368 | | |
386 | 369 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
0 commit comments