commit - 50617b77af7b0af9788a0e4b09697e06067cb8f4
commit + 0f104432aecf1cda4672c5ff4e4d228f5aae1bdb
blob - 2fae628addc1982ebd45678a1abce970b074a17a
blob + f978e93058d0e2a0ba0fc2fe42c3385a24fbf75c
--- got/got.1
+++ got/got.1
.It Fl R
Recurse into sub-directories in the repository.
.El
-.It Cm ref Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl c Ar object Oc Oo Fl s Ar reference Oc Oo Fl d Oc Op Ar name
+.It Cm ref Oo Fl r Ar repository-path Oc Oo Fl l Oc Oo Fl t Oc Oo Fl c Ar object Oc Oo Fl s Ar reference Oc Oo Fl d Oc Op Ar name
Manage references in a repository.
.Pp
References may be listed, created, deleted, and changed.
Otherwise, show only the reference with the given
.Ar name .
Cannot be used together with any other options except
-.Fl r .
+.Fl r
+and
+.Fl t .
+.It Fl t
+Sort listed references by modification time (most recently modified first)
+instead of sorting by lexicographical order.
+Use of this option requires the
+.Fl l
+option to be used as well.
.It Fl c Ar object
Create a reference or change an existing reference.
The reference with the specified
blob - 79b118613c6a18ad07b44c2dc907e5894b63b712
blob + 34fa60a650ef8a73873242635c42f9e8e2cc8806
--- got/got.c
+++ got/got.c
usage_ref(void)
{
fprintf(stderr,
- "usage: %s ref [-r repository] [-l] [-c object] [-s reference] "
- "[-d] [name]\n",
+ "usage: %s ref [-r repository] [-l] [-t] [-c object] "
+ "[-s reference] [-d] [name]\n",
getprogname());
exit(1);
}
static const struct got_error *
-list_refs(struct got_repository *repo, const char *refname)
+list_refs(struct got_repository *repo, const char *refname, int sort_by_time)
{
static const struct got_error *err = NULL;
struct got_reflist_head refs;
struct got_reflist_entry *re;
TAILQ_INIT(&refs);
- err = got_ref_list(&refs, repo, refname, got_ref_cmp_by_name, NULL);
+ err = got_ref_list(&refs, repo, refname, sort_by_time ?
+ got_ref_cmp_by_commit_timestamp_descending : got_ref_cmp_by_name,
+ repo);
if (err)
return err;
struct got_repository *repo = NULL;
struct got_worktree *worktree = NULL;
char *cwd = NULL, *repo_path = NULL;
- int ch, do_list = 0, do_delete = 0;
+ int ch, do_list = 0, do_delete = 0, sort_by_time = 0;
const char *obj_arg = NULL, *symref_target= NULL;
char *refname = NULL;
- while ((ch = getopt(argc, argv, "c:dr:ls:")) != -1) {
+ while ((ch = getopt(argc, argv, "c:dr:ls:t")) != -1) {
switch (ch) {
case 'c':
obj_arg = optarg;
break;
case 's':
symref_target = optarg;
+ break;
+ case 't':
+ sort_by_time = 1;
break;
default:
usage_ref();
option_conflict('s', 'l');
if (do_delete && do_list)
option_conflict('d', 'l');
+ if (sort_by_time && !do_list)
+ errx(1, "-t option requires -l option");
argc -= optind;
argv += optind;
goto done;
if (do_list)
- error = list_refs(repo, refname);
+ error = list_refs(repo, refname, sort_by_time);
else if (do_delete)
error = delete_ref_by_name(repo, refname);
else if (symref_target)