git/log: support -n option to restrict log counts
this is useful for scripting, and convenient for interactive use.
This commit is contained in:
parent
d457233c70
commit
21aac62c1f
2 changed files with 15 additions and 2 deletions
|
@ -96,6 +96,10 @@ git/pull, git/rm, git/serve
|
||||||
.I expr
|
.I expr
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
.B -n
|
||||||
|
.I count
|
||||||
|
]
|
||||||
|
[
|
||||||
.B -s
|
.B -s
|
||||||
]
|
]
|
||||||
[
|
[
|
||||||
|
@ -384,6 +388,11 @@ The
|
||||||
.I -s
|
.I -s
|
||||||
option shows a summary of the commit, instead of the full message.
|
option shows a summary of the commit, instead of the full message.
|
||||||
The
|
The
|
||||||
|
.I -n count
|
||||||
|
option stops printing messages after
|
||||||
|
.I count
|
||||||
|
messages.
|
||||||
|
The
|
||||||
.I -e expr
|
.I -e expr
|
||||||
option shows commits matching the query expression provided.
|
option shows commits matching the query expression provided.
|
||||||
The expression is in the syntax of
|
The expression is in the syntax of
|
||||||
|
|
|
@ -14,6 +14,7 @@ Biobuf *out;
|
||||||
char *queryexpr;
|
char *queryexpr;
|
||||||
char *commitid;
|
char *commitid;
|
||||||
int shortlog;
|
int shortlog;
|
||||||
|
int msgcount;
|
||||||
|
|
||||||
Objset done;
|
Objset done;
|
||||||
Objq objq;
|
Objq objq;
|
||||||
|
@ -180,7 +181,7 @@ showquery(char *q)
|
||||||
|
|
||||||
if((n = resolverefs(&h, q)) == -1)
|
if((n = resolverefs(&h, q)) == -1)
|
||||||
sysfatal("resolve: %r");
|
sysfatal("resolve: %r");
|
||||||
for(i = 0; i < n; i++){
|
for(i = 0; i < n && msgcount-- > 0; i++){
|
||||||
if((o = readobject(h[i])) == nil)
|
if((o = readobject(h[i])) == nil)
|
||||||
sysfatal("read %H: %r", h[i]);
|
sysfatal("read %H: %r", h[i]);
|
||||||
show(o);
|
show(o);
|
||||||
|
@ -206,7 +207,7 @@ showcommits(char *c)
|
||||||
qinit(&objq);
|
qinit(&objq);
|
||||||
osinit(&done);
|
osinit(&done);
|
||||||
qput(&objq, o, 0);
|
qput(&objq, o, 0);
|
||||||
while(qpop(&objq, &e)){
|
while(qpop(&objq, &e) && msgcount-- > 0){
|
||||||
show(e.o);
|
show(e.o);
|
||||||
for(i = 0; i < e.o->commit->nparent; i++){
|
for(i = 0; i < e.o->commit->nparent; i++){
|
||||||
if(oshas(&done, e.o->commit->parent[i]))
|
if(oshas(&done, e.o->commit->parent[i]))
|
||||||
|
@ -243,6 +244,9 @@ main(int argc, char **argv)
|
||||||
case 's':
|
case 's':
|
||||||
shortlog++;
|
shortlog++;
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
msgcount = atoi(EARGF(usage()));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue