ref: b18bdb3ef382966221a4ea5be3c2443a6cf57b9e
parent: 6ac8cd916fbefdd081b25585aabc535d9dd0c49e
author: Michael Forney <[email protected]>
date: Sun Jan 31 22:22:14 EST 2021
git/query: add -r flag to print commits in reverse This is useful for git/rebase and git/export, which need to apply/export commits in chronological order.
--- a/git.1.man
+++ b/git.1.man
@@ -169,7 +169,7 @@
.PP
.B git/query
[
-.B -pc
+.B -pcr
]
.I query
.PP
@@ -444,7 +444,11 @@
.B Git/query
takes an expression describing a commit, or set of commits,
-and resolves it to a list of commits. With the
+and resolves it to a list of commits.
+The
+.I -r
+option reverses the order of the commit list.
+With the
.I -p
option, instead of printing the commit hashes, the full
path to their
--- a/query.c
+++ b/query.c
@@ -7,6 +7,7 @@
int fullpath;
int changes;
+int reverse;
char *path[128];
int npath;
@@ -120,7 +121,7 @@
void
usage(void)
{
- fprint(2, "usage: %s [-pc] query\n", argv0);
+ fprint(2, "usage: %s [-pcr] query\n", argv0);
exits("usage");
}
@@ -135,6 +136,7 @@
ARGBEGIN{
case 'p': fullpath++; break;
case 'c': changes++; break;
+ case 'r': reverse ^= 1; break;
default: usage(); break;
}ARGEND;
@@ -163,7 +165,7 @@
}else{
p = (fullpath ? "/mnt/git/object/" : "");
for(j = 0; j < n; j++)
- print("%s%H\n", p, h[j]);
+ print("%s%H\n", p, h[reverse ? n - 1 - j : j]);
}
exits(nil);
}