Skip to content

Commit 649c7bb

Browse files
pks-tgitster
authored andcommitted
builtin/reflog: improve grouping of subcommands
The way subcommands of git-reflog(1) are laid out does not make any immediate sense. Reorder them such that read-only subcommands precede writing commands for a bit more structure. Furthermore, move the "expire" subcommand last. This prepares for a subsequent change where we are about to introduce a new "write" command to append reflog entries. Like this, the writing subcommands are ordered such that those affecting a single reflog come before those spanning across all reflogs. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e9493c5 commit 649c7bb

File tree

2 files changed

+50
-49
lines changed

2 files changed

+50
-49
lines changed

Documentation/git-reflog.adoc

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ SYNOPSIS
1111
[synopsis]
1212
git reflog [show] [<log-options>] [<ref>]
1313
git reflog list
14-
git reflog expire [--expire=<time>] [--expire-unreachable=<time>]
15-
[--rewrite] [--updateref] [--stale-fix]
16-
[--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]
14+
git reflog exists <ref>
1715
git reflog delete [--rewrite] [--updateref]
1816
[--dry-run | -n] [--verbose] <ref>@{<specifier>}...
1917
git reflog drop [--all [--single-worktree] | <refs>...]
20-
git reflog exists <ref>
18+
git reflog expire [--expire=<time>] [--expire-unreachable=<time>]
19+
[--rewrite] [--updateref] [--stale-fix]
20+
[--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]
2121

2222
DESCRIPTION
2323
-----------
@@ -43,11 +43,9 @@ actions, and in addition the `HEAD` reflog records branch switching.
4343

4444
The "list" subcommand lists all refs which have a corresponding reflog.
4545

46-
The "expire" subcommand prunes older reflog entries. Entries older
47-
than `expire` time, or entries older than `expire-unreachable` time
48-
and not reachable from the current tip, are removed from the reflog.
49-
This is typically not used directly by end users -- instead, see
50-
linkgit:git-gc[1].
46+
The "exists" subcommand checks whether a ref has a reflog. It exits
47+
with zero status if the reflog exists, and non-zero status if it does
48+
not.
5149

5250
The "delete" subcommand deletes single entries from the reflog, but
5351
not the reflog itself. Its argument must be an _exact_ entry (e.g. "`git
@@ -58,9 +56,11 @@ The "drop" subcommand completely removes the reflog for the specified
5856
references. This is in contrast to "expire" and "delete", both of which
5957
can be used to delete reflog entries, but not the reflog itself.
6058

61-
The "exists" subcommand checks whether a ref has a reflog. It exits
62-
with zero status if the reflog exists, and non-zero status if it does
63-
not.
59+
The "expire" subcommand prunes older reflog entries. Entries older
60+
than `expire` time, or entries older than `expire-unreachable` time
61+
and not reachable from the current tip, are removed from the reflog.
62+
This is typically not used directly by end users -- instead, see
63+
linkgit:git-gc[1].
6464

6565
OPTIONS
6666
-------
@@ -71,6 +71,25 @@ Options for `show`
7171
`git reflog show` accepts any of the options accepted by `git log`.
7272

7373

74+
Options for `delete`
75+
~~~~~~~~~~~~~~~~~~~~
76+
77+
`git reflog delete` accepts options `--updateref`, `--rewrite`, `-n`,
78+
`--dry-run`, and `--verbose`, with the same meanings as when they are
79+
used with `expire`.
80+
81+
Options for `drop`
82+
~~~~~~~~~~~~~~~~~~
83+
84+
`--all`::
85+
Drop the reflogs of all references from all worktrees.
86+
87+
`--single-worktree`::
88+
By default when `--all` is specified, reflogs from all working
89+
trees are dropped. This option limits the processing to reflogs
90+
from the current working tree only.
91+
92+
7493
Options for `expire`
7594
~~~~~~~~~~~~~~~~~~~~
7695

@@ -130,24 +149,6 @@ which didn't protect objects referred to by reflogs.
130149
Print extra information on screen.
131150

132151

133-
Options for `delete`
134-
~~~~~~~~~~~~~~~~~~~~
135-
136-
`git reflog delete` accepts options `--updateref`, `--rewrite`, `-n`,
137-
`--dry-run`, and `--verbose`, with the same meanings as when they are
138-
used with `expire`.
139-
140-
Options for `drop`
141-
~~~~~~~~~~~~~~~~~~
142-
143-
`--all`::
144-
Drop the reflogs of all references from all worktrees.
145-
146-
`--single-worktree`::
147-
By default when `--all` is specified, reflogs from all working
148-
trees are dropped. This option limits the processing to reflogs
149-
from the current working tree only.
150-
151152
GIT
152153
---
153154
Part of the linkgit:git[1] suite

builtin/reflog.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
#define BUILTIN_REFLOG_LIST_USAGE \
1818
N_("git reflog list")
1919

20-
#define BUILTIN_REFLOG_EXPIRE_USAGE \
21-
N_("git reflog expire [--expire=<time>] [--expire-unreachable=<time>]\n" \
22-
" [--rewrite] [--updateref] [--stale-fix]\n" \
23-
" [--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]")
20+
#define BUILTIN_REFLOG_EXISTS_USAGE \
21+
N_("git reflog exists <ref>")
2422

2523
#define BUILTIN_REFLOG_DELETE_USAGE \
2624
N_("git reflog delete [--rewrite] [--updateref]\n" \
2725
" [--dry-run | -n] [--verbose] <ref>@{<specifier>}...")
2826

29-
#define BUILTIN_REFLOG_EXISTS_USAGE \
30-
N_("git reflog exists <ref>")
31-
3227
#define BUILTIN_REFLOG_DROP_USAGE \
3328
N_("git reflog drop [--all [--single-worktree] | <refs>...]")
3429

30+
#define BUILTIN_REFLOG_EXPIRE_USAGE \
31+
N_("git reflog expire [--expire=<time>] [--expire-unreachable=<time>]\n" \
32+
" [--rewrite] [--updateref] [--stale-fix]\n" \
33+
" [--dry-run | -n] [--verbose] [--all [--single-worktree] | <refs>...]")
34+
3535
static const char *const reflog_show_usage[] = {
3636
BUILTIN_REFLOG_SHOW_USAGE,
3737
NULL,
@@ -42,33 +42,33 @@ static const char *const reflog_list_usage[] = {
4242
NULL,
4343
};
4444

45-
static const char *const reflog_expire_usage[] = {
46-
BUILTIN_REFLOG_EXPIRE_USAGE,
47-
NULL
45+
static const char *const reflog_exists_usage[] = {
46+
BUILTIN_REFLOG_EXISTS_USAGE,
47+
NULL,
4848
};
4949

5050
static const char *const reflog_delete_usage[] = {
5151
BUILTIN_REFLOG_DELETE_USAGE,
5252
NULL
5353
};
5454

55-
static const char *const reflog_exists_usage[] = {
56-
BUILTIN_REFLOG_EXISTS_USAGE,
57-
NULL,
58-
};
59-
6055
static const char *const reflog_drop_usage[] = {
6156
BUILTIN_REFLOG_DROP_USAGE,
6257
NULL,
6358
};
6459

60+
static const char *const reflog_expire_usage[] = {
61+
BUILTIN_REFLOG_EXPIRE_USAGE,
62+
NULL
63+
};
64+
6565
static const char *const reflog_usage[] = {
6666
BUILTIN_REFLOG_SHOW_USAGE,
6767
BUILTIN_REFLOG_LIST_USAGE,
68-
BUILTIN_REFLOG_EXPIRE_USAGE,
68+
BUILTIN_REFLOG_EXISTS_USAGE,
6969
BUILTIN_REFLOG_DELETE_USAGE,
7070
BUILTIN_REFLOG_DROP_USAGE,
71-
BUILTIN_REFLOG_EXISTS_USAGE,
71+
BUILTIN_REFLOG_EXPIRE_USAGE,
7272
NULL
7373
};
7474

@@ -404,10 +404,10 @@ int cmd_reflog(int argc,
404404
struct option options[] = {
405405
OPT_SUBCOMMAND("show", &fn, cmd_reflog_show),
406406
OPT_SUBCOMMAND("list", &fn, cmd_reflog_list),
407-
OPT_SUBCOMMAND("expire", &fn, cmd_reflog_expire),
408-
OPT_SUBCOMMAND("delete", &fn, cmd_reflog_delete),
409407
OPT_SUBCOMMAND("exists", &fn, cmd_reflog_exists),
408+
OPT_SUBCOMMAND("delete", &fn, cmd_reflog_delete),
410409
OPT_SUBCOMMAND("drop", &fn, cmd_reflog_drop),
410+
OPT_SUBCOMMAND("expire", &fn, cmd_reflog_expire),
411411
OPT_END()
412412
};
413413

0 commit comments

Comments
 (0)