chiark
/
gitweb
/
~mdw
/
stgit
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add the 'log --number' option to limit the output
[stgit]
/
stgit
/
commands
/
log.py
diff --git
a/stgit/commands/log.py
b/stgit/commands/log.py
index cb56ec8d6cc4989aac8d9aa6438822b6e8133861..39c21182f6f5a3ab099d761eee0df6a5dec1b169 100644
(file)
--- a/
stgit/commands/log.py
+++ b/
stgit/commands/log.py
@@
-49,6
+49,8
@@
options = [make_option('-b', '--branch',
make_option('-p', '--patch',
help = 'show the refresh diffs',
action = 'store_true'),
make_option('-p', '--patch',
help = 'show the refresh diffs',
action = 'store_true'),
+ make_option('-n', '--number', type = 'int',
+ help = 'limit the output to NUMBER commits'),
make_option('-f', '--full',
help = 'show the full commit ids',
action = 'store_true'),
make_option('-f', '--full',
help = 'show the full commit ids',
action = 'store_true'),
@@
-60,8
+62,16
@@
def show_log(log, options):
"""List the patch changelog
"""
commit = git.get_commit(log)
"""List the patch changelog
"""
commit = git.get_commit(log)
- diff_str = ''
+ if options.number != None:
+ n = options.number
+ else:
+ n = -1
+ diff_list = []
while commit:
while commit:
+ if n == 0:
+ # limit the output
+ break
+
log = commit.get_log().split('\n')
cmd_rev = log[0].split()
log = commit.get_log().split('\n')
cmd_rev = log[0].split()
@@
-76,8
+86,10
@@
def show_log(log, options):
if options.patch:
if cmd in ['refresh', 'undo', 'sync', 'edit']:
if options.patch:
if cmd in ['refresh', 'undo', 'sync', 'edit']:
- diff_str = '%s%s\n' % (diff_str,
- git.pretty_commit(commit.get_id_hash()))
+ diff_list.append(git.pretty_commit(commit.get_id_hash()))
+
+ # limiter decrement
+ n -= 1
else:
if len(log) >= 3:
notes = log[2]
else:
if len(log) >= 3:
notes = log[2]
@@
-94,14
+106,17
@@
def show_log(log, options):
out.stdout('%-8s [%-7s] %-28s %s' % \
(rev[:8], cmd[:7], notes[:28], date))
out.stdout('%-8s [%-7s] %-28s %s' % \
(rev[:8], cmd[:7], notes[:28], date))
+ # limiter decrement
+ n -= 1
+
parent = commit.get_parent()
if parent:
commit = git.get_commit(parent)
else:
commit = None
parent = commit.get_parent()
if parent:
commit = git.get_commit(parent)
else:
commit = None
- if options.patch and diff_
str
:
- pager(
diff_str
.rstrip())
+ if options.patch and diff_
list
:
+ pager(
'\n'.join(diff_list)
.rstrip())
def func(parser, options, args):
"""Show the patch changelog
def func(parser, options, args):
"""Show the patch changelog