mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 07:02:29 +02:00
eeshow/: option -N depth to limit history depth; -N-depth exits after parsing
This commit is contained in:
parent
02e4d6e071
commit
54922dc343
21
eeshow/gui.c
21
eeshow/gui.c
@ -996,7 +996,7 @@ struct add_hist_ctx {
|
||||
int n_args;
|
||||
char **args;
|
||||
bool recurse;
|
||||
unsigned limit;
|
||||
unsigned limit;
|
||||
};
|
||||
|
||||
|
||||
@ -1008,9 +1008,10 @@ static void add_hist(void *user, struct hist *h)
|
||||
const struct sheet *sch;
|
||||
unsigned age = 0;
|
||||
|
||||
if (!ahc->limit)
|
||||
return;
|
||||
ahc->limit--;
|
||||
if (!ahc->limit)
|
||||
return;
|
||||
ahc->limit--;
|
||||
|
||||
for (anchor = &ctx->hist; *anchor; anchor = &(*anchor)->next)
|
||||
age++;
|
||||
*anchor = alloc_type(struct gui_hist);
|
||||
@ -1024,7 +1025,7 @@ ahc->limit--;
|
||||
|
||||
|
||||
static void get_revisions(struct gui_ctx *ctx,
|
||||
int n_args, char **args, bool recurse)
|
||||
int n_args, char **args, bool recurse, int limit)
|
||||
{
|
||||
const char *sch_name = args[n_args - 1];
|
||||
struct add_hist_ctx add_hist_ctx = {
|
||||
@ -1032,7 +1033,7 @@ static void get_revisions(struct gui_ctx *ctx,
|
||||
.n_args = n_args,
|
||||
.args = args,
|
||||
.recurse = recurse,
|
||||
.limit = 30,
|
||||
.limit = limit < 0 ? -limit : limit,
|
||||
};
|
||||
|
||||
if (!vcs_git_try(sch_name)) {
|
||||
@ -1045,7 +1046,7 @@ static void get_revisions(struct gui_ctx *ctx,
|
||||
}
|
||||
|
||||
|
||||
int gui(unsigned n_args, char **args, bool recurse)
|
||||
int gui(unsigned n_args, char **args, bool recurse, int limit)
|
||||
{
|
||||
GtkWidget *window;
|
||||
struct gui_ctx ctx = {
|
||||
@ -1060,7 +1061,7 @@ int gui(unsigned n_args, char **args, bool recurse)
|
||||
.old_hist = NULL,
|
||||
};
|
||||
|
||||
get_revisions(&ctx, n_args, args, recurse);
|
||||
get_revisions(&ctx, n_args, args, recurse, limit);
|
||||
for (ctx.new_hist = ctx.hist; ctx.new_hist && !ctx.new_hist->sheets;
|
||||
ctx.new_hist = ctx.new_hist->next);
|
||||
if (!ctx.new_hist) {
|
||||
@ -1107,7 +1108,9 @@ int gui(unsigned n_args, char **args, bool recurse)
|
||||
go_to_sheet(&ctx, ctx.new_hist->sheets);
|
||||
gtk_widget_show_all(window);
|
||||
|
||||
gtk_main();
|
||||
/* for performance testing, use -N-depth */
|
||||
if (limit >= 0)
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -20,6 +20,6 @@
|
||||
* and there is no NULL at the end.
|
||||
*/
|
||||
|
||||
int gui(unsigned n_args, char **args, bool recurse);
|
||||
int gui(unsigned n_args, char **args, bool recurse, int limit);
|
||||
|
||||
#endif /* !GUI_H */
|
||||
|
@ -47,17 +47,18 @@ static struct gfx_ops const *ops_list[] = {
|
||||
void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [gtk_flags] [-r] [[rev:]file.lib ...] [rev:]file.sch\n"
|
||||
"usage: %s [gtk_flags] [-r] [-N n] [[rev:]file.lib ...] [rev:]file.sch\n"
|
||||
" %s [-r] [-v ...] [[rev:]file.lib ...] [rev:]file.sch\n"
|
||||
" %*s[-- driver_spec]\n"
|
||||
" %s [-v ...] -C [rev:]file\n"
|
||||
" %s [-v ...] -H path_into_repo\n"
|
||||
"\n"
|
||||
" rev git revision\n"
|
||||
" -r recurse into sub-sheets\n"
|
||||
" -v increase verbosity of diagnostic output\n"
|
||||
" -C 'cat' the file to standard output\n"
|
||||
" -H show history of repository on standard output\n"
|
||||
" rev git revision\n"
|
||||
" -r recurse into sub-sheets\n"
|
||||
" -v increase verbosity of diagnostic output\n"
|
||||
" -C 'cat' the file to standard output\n"
|
||||
" -H show history of repository on standard output\n"
|
||||
" -N n limit history to n revisions\n"
|
||||
"\n"
|
||||
"No driver spec: enter GUI\n"
|
||||
"\n"
|
||||
@ -96,6 +97,7 @@ int main(int argc, char **argv)
|
||||
const char *cat = NULL;
|
||||
const char *history = NULL;
|
||||
const char *fmt = NULL;
|
||||
int limit = 0;
|
||||
char c;
|
||||
int arg, dashdash;
|
||||
bool have_dashdash = 0;
|
||||
@ -112,7 +114,7 @@ int main(int argc, char **argv)
|
||||
if (!have_dashdash)
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
while ((c = getopt(dashdash, argv, "rvC:F:H:")) != EOF)
|
||||
while ((c = getopt(dashdash, argv, "rvC:F:H:N:")) != EOF)
|
||||
switch (c) {
|
||||
case 'r':
|
||||
recurse = 1;
|
||||
@ -129,6 +131,9 @@ int main(int argc, char **argv)
|
||||
case 'H':
|
||||
history = optarg;
|
||||
break;
|
||||
case 'N':
|
||||
limit = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
@ -173,7 +178,7 @@ int main(int argc, char **argv)
|
||||
memcpy(args, argv + optind, sizeof(const char *) * n);
|
||||
|
||||
optind = 0; /* reset getopt */
|
||||
return gui(n, args, recurse);
|
||||
return gui(n, args, recurse, limit);
|
||||
}
|
||||
|
||||
sch_init(&sch_ctx, recurse);
|
||||
|
Loading…
Reference in New Issue
Block a user