int cmd_config(int argc,char **argv,struct sub_command* cmd) { char* home=configdir(); char* path=cat(home,"config",NULL); if(argc==1) { printf("oneshot:\n"); print_opts(local_opt); printf("local:\n"); print_opts(global_opt); }else { struct opts* opt=global_opt; struct opts** opts=&opt; // TBD parse options if(argc==2) { unset_opt(opts, argv[1]); save_opts(path,opt); }else { if(strcmp(argv[1],"set")==0) { set_opt(opts, argv[2],(char*)argv[3],0); save_opts(path,opt); }else if (strcmp(argv[1],"show")==0) { printf("%s\n",_get_opt(opt,argv[2])); }else { set_opt(opts, argv[1],(char*)argv[2],0); save_opts(path,opt); } } } s(home),s(path); return 0; }
static int pick_revisions(struct replay_opts *opts) { struct commit_list *todo_list = NULL; unsigned char sha1[20]; read_and_refresh_cache(opts); /* * Decide what to do depending on the arguments; a fresh * cherry-pick should be handled differently from an existing * one that is being continued */ if (opts->subcommand == REPLAY_RESET) { remove_sequencer_state(1); return 0; } else if (opts->subcommand == REPLAY_CONTINUE) { if (!file_exists(git_path(SEQ_TODO_FILE))) goto error; read_populate_opts(&opts); read_populate_todo(&todo_list, opts); /* Verify that the conflict has been resolved */ if (!index_differs_from("HEAD", 0)) todo_list = todo_list->next; } else { /* * Start a new cherry-pick/ revert sequence; but * first, make sure that an existing one isn't in * progress */ walk_revs_populate_todo(&todo_list, opts); if (create_seq_dir() < 0) { error(_("A cherry-pick or revert is in progress.")); advise(_("Use --continue to continue the operation")); advise(_("or --reset to forget about it")); return -1; } if (get_sha1("HEAD", sha1)) { if (opts->action == REVERT) return error(_("Can't revert as initial commit")); return error(_("Can't cherry-pick into empty head")); } save_head(sha1_to_hex(sha1)); save_opts(opts); } return pick_commits(todo_list, opts); error: return error(_("No %s in progress"), action_name(opts)); }
int cmd_install(int argc,char **argv,struct sub_command* cmd) { install_cmds *cmds=NULL; struct install_options param; quicklisp=1; param.os=uname(); param.arch=uname_m(); param.arch_in_archive_name=0; param.expand_path=NULL; if(argc!=1) { int ret=1,k; for(k=1;k<argc;++k) { int i,pos; param.impl=argv[k]; pos=position_char("/",param.impl); if(pos!=-1) { param.version=subseq(param.impl,pos+1,0); param.impl=subseq(param.impl,0,pos); }else { param.version=NULL; param.impl=q(param.impl); } for(install_impl=NULL,i=0;i<sizeof(impls_to_install)/sizeof(struct install_impls*);++i) { struct install_impls* j=impls_to_install[i]; if(strcmp(param.impl,j->name)==0) { install_impl=j; } } if(install_impl) { for(cmds=install_impl->call;*cmds&&ret;++cmds) ret=(*cmds)(¶m); if(ret) { // after install latest installed impl/version should be default for 'run' struct opts* opt=global_opt; struct opts** opts=&opt; char* home=configdir(); char* path=cat(home,"config",NULL); char* v=cat(param.impl,".version",NULL); char* version=param.version; if(!install_impl->util) { int i; for(i=0;version[i]!='\0';++i) if(version[i]=='-') version[i]='\0'; set_opt(opts,"default.lisp",param.impl,0); set_opt(opts,v,version,0); save_opts(path,opt); } s(home),s(path),s(v); } }else { char* lisp_path=lispdir(); int i,j,argc_; char** tmp; char* install_ros=s_cat2(lisp_path,q("install.ros")); if(verbose&1) { fprintf(stderr,"%s is not implemented internal. %s argc:%d\n",param.impl,install_ros,argc); for(i=0;i<argc;++i) fprintf(stderr,"%s:",argv[i]); fprintf(stderr,"\n"); } tmp=(char**)alloc(sizeof(char*)*(argc+9)); i=0; tmp[i++]=q("--"); tmp[i++]=install_ros; tmp[i++]=q("install"); tmp[i++]=q(argv[1]); for(j=2;j<argc;tmp[i++]=q(argv[j++])); argc_=i; if(verbose&1) { int j; fprintf(stderr,"argc_=%d",argc_); for(j=0;j<argc_;++j) fprintf(stderr,"argv[%d]=%s,",j,tmp[j]); } for(i=0;i<argc_;i+=proccmd(argc_-i,&tmp[i],top_options,top_commands)); for(j=0;j<argc_;s(tmp[j++])); dealloc(tmp); return 0; } if(param.version)s(param.version); s(param.impl),s(param.arch),s(param.os); s(param.expand_path); if(!ret) exit(EXIT_FAILURE); } }else { char* tmp[]={"help","install"}; proccmd(2,tmp,top_options,top_commands); exit(EXIT_SUCCESS); } return 0; }
int sequencer_pick_revisions(struct replay_opts *opts) { struct commit_list *todo_list = NULL; unsigned char sha1[20]; if (opts->subcommand == REPLAY_NONE) assert(opts->revs); read_and_refresh_cache(opts); /* * Decide what to do depending on the arguments; a fresh * cherry-pick should be handled differently from an existing * one that is being continued */ if (opts->subcommand == REPLAY_REMOVE_STATE) { remove_sequencer_state(); return 0; } if (opts->subcommand == REPLAY_ROLLBACK) return sequencer_rollback(opts); if (opts->subcommand == REPLAY_CONTINUE) return sequencer_continue(opts); /* * If we were called as "git cherry-pick <commit>", just * cherry-pick/revert it, set CHERRY_PICK_HEAD / * REVERT_HEAD, and don't touch the sequencer state. * This means it is possible to cherry-pick in the middle * of a cherry-pick sequence. */ if (opts->revs->cmdline.nr == 1 && opts->revs->cmdline.rev->whence == REV_CMD_REV && opts->revs->no_walk && !opts->revs->cmdline.rev->flags) { struct commit *cmit; if (prepare_revision_walk(opts->revs)) die(_("revision walk setup failed")); cmit = get_revision(opts->revs); if (!cmit || get_revision(opts->revs)) die("BUG: expected exactly one commit from walk"); return single_pick(cmit, opts); } /* * Start a new cherry-pick/ revert sequence; but * first, make sure that an existing one isn't in * progress */ walk_revs_populate_todo(&todo_list, opts); if (create_seq_dir() < 0) return -1; if (get_sha1("HEAD", sha1)) { if (opts->action == REPLAY_REVERT) return error(_("Can't revert as initial commit")); return error(_("Can't cherry-pick into empty head")); } save_head(sha1_to_hex(sha1)); save_opts(opts); return pick_commits(todo_list, opts); }