Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
setup_revisions(): handle -n<n> and -<n> internally.
author
Junio C Hamano
<junkio@cox.net>
Thu, 2 Mar 2006 23:24:01 +0000
(15:24 -0800)
committer
Junio C Hamano
<junkio@cox.net>
Thu, 2 Mar 2006 23:24:01 +0000
(15:24 -0800)
This moves the handling of max-count shorthand from the internal
implementation of "git log" to setup_revisions() so other users
of setup_revisions() can use it.
Signed-off-by: Junio C Hamano <junkio@cox.net>
git.c
patch
|
blob
|
history
revision.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
7ae0b0c
)
diff --git
a/git.c
b/git.c
index bf68daca200cee00747cec1bbcace985ff0af9d1..a547dbd9136c70e49340814d1d57e92ec94c4c3d 100644
(file)
--- a/
git.c
+++ b/
git.c
@@
-264,20
+264,7
@@
static int cmd_log(int argc, char **argv, char **envp)
argc = setup_revisions(argc, argv, &rev, "HEAD");
while (1 < argc) {
char *arg = argv[1];
argc = setup_revisions(argc, argv, &rev, "HEAD");
while (1 < argc) {
char *arg = argv[1];
- /* accept -<digit>, like traditilnal "head" */
- if ((*arg == '-') && isdigit(arg[1])) {
- rev.max_count = atoi(arg + 1);
- }
- else if (!strcmp(arg, "-n")) {
- if (argc < 2)
- die("-n requires an argument");
- rev.max_count = atoi(argv[2]);
- argc--; argv++;
- }
- else if (!strncmp(arg,"-n",2)) {
- rev.max_count = atoi(arg + 2);
- }
- else if (!strncmp(arg, "--pretty", 8)) {
+ if (!strncmp(arg, "--pretty", 8)) {
commit_format = get_commit_format(arg + 8);
if (commit_format == CMIT_FMT_ONELINE)
commit_prefix = "";
commit_format = get_commit_format(arg + 8);
if (commit_format == CMIT_FMT_ONELINE)
commit_prefix = "";
diff --git
a/revision.c
b/revision.c
index 48858714250da8e7328c132f60dfcd076d103433..a3df8100763136e8936b8e3b4c647d5b83cc7239 100644
(file)
--- a/
revision.c
+++ b/
revision.c
@@
-482,6
+482,21
@@
int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
revs->max_count = atoi(arg + 12);
continue;
}
revs->max_count = atoi(arg + 12);
continue;
}
+ /* accept -<digit>, like traditilnal "head" */
+ if ((*arg == '-') && isdigit(arg[1])) {
+ revs->max_count = atoi(arg + 1);
+ continue;
+ }
+ if (!strcmp(arg, "-n")) {
+ if (argc <= i + 1)
+ die("-n requires an argument");
+ revs->max_count = atoi(argv[++i]);
+ continue;
+ }
+ if (!strncmp(arg,"-n",2)) {
+ revs->max_count = atoi(arg + 2);
+ continue;
+ }
if (!strncmp(arg, "--max-age=", 10)) {
revs->max_age = atoi(arg + 10);
revs->limited = 1;
if (!strncmp(arg, "--max-age=", 10)) {
revs->max_age = atoi(arg + 10);
revs->limited = 1;