RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: j...@rpm5.org Module: rpm Date: 14-Apr-2014 00:28:40 Branch: rpm-5_4 Handle: 2014041322283900 Modified files: (Branch: rpm-5_4) rpm/rpmio rpmgit.c rpmgit.h tgit.c Log: - git: haul out some trash. Summary: Revision Changes Path 2.1.2.43 +137 -70 rpm/rpmio/rpmgit.c 2.1.2.23 +2 -0 rpm/rpmio/rpmgit.h 1.1.2.38 +396 -60 rpm/rpmio/tgit.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/rpmgit.c ============================================================================ $ cvs diff -u -r2.1.2.42 -r2.1.2.43 rpmgit.c --- rpm/rpmio/rpmgit.c 12 Apr 2014 17:10:50 -0000 2.1.2.42 +++ rpm/rpmio/rpmgit.c 13 Apr 2014 22:28:39 -0000 2.1.2.43 @@ -496,19 +496,6 @@ goto exit; if (_rpmgit_debug < 0) rpmgitPrintRepo(git, git->R, git->fp); - /* Add an empty index to the new repository. */ - rc = chkgit(git, "git_repository_index", - git_repository_index((git_index **)&git->I, git->R)); - if (rc) - goto exit; - - /* XXX Clear the index??? */ - rc = chkgit(git, "git_index_read", - git_index_read(git->I, 0)); - git_index_clear(git->I); - rc = chkgit(git, "git_index_write", - git_index_write(git->I)); - exit: #endif /* defined(WITH_LIBGT2) */ SPEW(0, rc, git); @@ -520,7 +507,7 @@ int rc = -1; #if defined(WITH_LIBGIT2) - /* XXX TODO: strip out workdir prefix if present. */ + /* XXX Strip out workdir prefix if present. */ { const char * s = git_repository_workdir(git->R); size_t ns = strlen(s); if (strlen(fn) > ns && !strncmp(fn, s, ns)) @@ -903,39 +890,6 @@ /*==============================================================*/ -static int rpmgitToyFile(rpmgit git, const char * fn, - const char * b, size_t nb) -{ - int rc = RPMRC_FAIL; -#if defined(WITH_LIBGIT2) - const char * workdir = git_repository_workdir(git->R); - char * path = rpmGetPath(workdir, "/", fn, NULL); - char * t = xstrdup(path); - char * dn = dirname(t); - FD_t fd; - - rc = rpmioMkpath(dn, 0755, (uid_t)-1, (gid_t)-1); - if (rc) - goto exit; - if (fn[strlen(fn)-1] == '/' || b == NULL) - goto exit; - - if ((fd = Fopen(path, "w")) != NULL) { - size_t nw = Fwrite(b, 1, nb, fd); - rc = Fclose(fd); -assert(nw == nb); - } - -exit: -SPEW(0, rc, git); - t = _free(t); - path = _free(path); -#endif /* defined(WITH_LIBGIT2) */ - return rc; -} - -/*==============================================================*/ - static int rpmgitPopt(rpmgit git, int argc, char *argv[], poptOption opts) { static int _popt_flags = POPT_CONTEXT_POSIXMEHARDER; @@ -1037,7 +991,7 @@ goto exit; } - git_signature_free(git->I); + git_index_free(git->I); git->I = NULL; xx = chkgit(git, "git_tree_lookup", @@ -1192,11 +1146,6 @@ /* Create file(s) in _workdir (if any). */ for (i = 0; i < git->ac; i++) { const char * fn = git->av[i]; - struct stat sb; - - /* XXX Create non-existent files lazily. */ - if (Stat(fn, &sb) < 0) - xx = rpmgitToyFile(git, fn, fn, strlen(fn)); /* Add the file to the repository. */ xx = rpmgitAddFile(git, fn); @@ -1231,12 +1180,122 @@ /*==============================================================*/ +#if defined(WITH_LIBGIT2) +static int print_matched_cb(const char * fn, const char *matched_pathspec, + void * _git) +{ + FILE * fp = stdout; + rpmgit git = (rpmgit) _git; + git_status_t status; + int rc = -1; /* XXX assume abort */ + int xx; + + (void) matched_pathspec; + + xx = chkgit(git, "git_status_file", + git_status_file((unsigned int *) &status, git->R, fn)); + if (xx) + goto exit; + + if (status & GIT_STATUS_WT_MODIFIED || status & GIT_STATUS_WT_NEW) { + fprintf(fp, "add '%s'\n", fn); + rc = 0; + goto exit; + } + rc = 1; + +exit: +SPEW(0, rc, git); + return rc; +} +#endif + +#ifdef REFERENCE +OPTIONS + <filepattern>... + Files to add content from. Fileglobs (e.g. *.c) can be given to + add all matching files. Also a leading directory name (e.g. dir to + add dir/file1 and dir/file2) can be given to add all files in the + directory, recursively. + + -n, --dry-run + Donât actually add the file(s), just show if they exist. + + -v, --verbose + Be verbose. + + -f, --force + Allow adding otherwise ignored files. + + -i, --interactive + Add modified contents in the working tree interactively to the + index. Optional path arguments may be supplied to limit operation + to a subset of the working tree. See âInteractive modeâ for + details. + + -p, --patch + Interactively choose hunks of patch between the index and the work + tree and add them to the index. This gives the user a chance to + review the difference before adding modified contents to the index. + + This effectively runs add --interactive, but bypasses the initial + command menu and directly jumps to the patch subcommand. See + âInteractive modeâ for details. + + -e, --edit + Open the diff vs. the index in an editor and let the user edit it. + After the editor was closed, adjust the hunk headers and apply the + patch to the index. + + NOTE: Obviously, if you change anything else than the first + character on lines beginning with a space or a minus, the patch + will no longer apply. + + -u, --update + Only match <filepattern> against already tracked files in the index + rather than the working tree. That means that it will never stage + new files, but that it will stage modified new contents of tracked + files and that it will remove files from the index if the + corresponding files in the working tree have been removed. + + If no <filepattern> is given, default to "."; in other words, + update all tracked files in the current directory and its + subdirectories. + + -A, --all + Like -u, but match <filepattern> against files in the working tree + in addition to the index. That means that it will find new files as + well as staging modified content and removing files that are no + longer in the working tree. + + -N, --intent-to-add + Record only the fact that the path will be added later. An entry + for the path is placed in the index with no content. This is useful + for, among other things, showing the unstaged content of such files + with git diff and committing them with git commit -a. + + --refresh + Donât add the file(s), but only refresh their stat() information in + the index. + + --ignore-errors + If some files could not be added because of errors indexing them, + do not abort the operation, but continue adding the others. The + command shall still exit with non-zero status. + + -- + This option can be used to separate command-line options from the + list of files, (useful when filenames might be mistaken for + command-line options). +#endif + + rpmRC rpmgitCmdAdd(int argc, char *argv[]) { int rc = RPMRC_FAIL; #if defined(WITH_LIBGIT2) enum { - _ADD_DRY_RUN = (1 << 0), + _ADD_SKIP = (1 << 0), _ADD_VERBOSE = (1 << 1), _ADD_FORCE = (1 << 2), _ADD_INTERACTIVE = (1 << 3), @@ -1251,7 +1310,7 @@ int add_flags = 0; #define ADD_ISSET(_a) (add_flags & _ADD_##_a) struct poptOption addOpts[] = { - { "dry-run", 'n', POPT_BIT_SET, &add_flags, _ADD_DRY_RUN, + { "dry-run", 'n', POPT_BIT_SET, &add_flags, _ADD_SKIP, N_(""), NULL }, { "verbose", 'v', POPT_BIT_SET, &add_flags, _ADD_VERBOSE, N_("Verbose mode."), NULL }, @@ -1279,7 +1338,15 @@ }; rpmgit git = rpmgitNew(argv, 0, addOpts); int xx = -1; - int i; + + git_index_matched_path_cb matched_cb = NULL; + + git_strarray array = {0}; + array.strings = (char **) git->av; + array.count = git->ac; + + if (ADD_ISSET(VERBOSE) || ADD_ISSET(SKIP)) + matched_cb = print_matched_cb; /* XXX Get the index file for this repository. */ xx = chkgit(git, "git_repository_index", @@ -1288,26 +1355,24 @@ goto exit; if (_rpmgit_debug < 0) rpmgitPrintIndex(git->I, git->fp); - /* Create file(s) in _workdir (if any). */ - for (i = 0; i < git->ac; i++) { - const char * fn = git->av[i]; - struct stat sb; - - /* XXX Create non-existent files lazily. */ - if (Stat(fn, &sb) < 0) - xx = rpmgitToyFile(git, fn, fn, strlen(fn)); - - /* Add the file to the repository. */ - xx = rpmgitAddFile(git, fn); - if (xx) - goto exit; - } + if (ADD_ISSET(UPDATE)) + xx = chkgit(git, "git_index_update_all", + git_index_update_all(git->I, &array, matched_cb, git)); + else + xx = chkgit(git, "git_index_add_all", + git_index_add_all(git->I, &array, 0, matched_cb, git)); if (_rpmgit_debug < 0) rpmgitPrintIndex(git->I, git->fp); + xx = chkgit(git, "git_index_write", + git_index_write(git->I)); + exit: rc = (xx ? RPMRC_FAIL : RPMRC_OK); SPEW(0, rc, git); + if (git->I) + git_index_free(git->I); + git->I = NULL; git = rpmgitFree(git); #endif /* defined(WITH_LIBGIT2) */ return rc; @@ -2544,6 +2609,8 @@ git->fp = NULL; git->data = NULL; + git->hide = 0; + git->sorting = 0; git->state = 0; git->shared_umask = 0; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmgit.h ============================================================================ $ cvs diff -u -r2.1.2.22 -r2.1.2.23 rpmgit.h --- rpm/rpmio/rpmgit.h 12 Apr 2014 17:10:51 -0000 2.1.2.22 +++ rpm/rpmio/rpmgit.h 13 Apr 2014 22:28:39 -0000 2.1.2.23 @@ -64,6 +64,8 @@ uint32_t shared_umask; /*!< init: --shared mode */ int state; /*!< git_status_foreach() state */ + int hide; /*!< tgit.c cmd_log() */ + int sorting; /*!< git_revwalk_sorting() flags */ void * R; /*!< git_repository * */ void * I; /*!< git_index * */ @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/tgit.c ============================================================================ $ cvs diff -u -r1.1.2.37 -r1.1.2.38 tgit.c --- rpm/rpmio/tgit.c 12 Apr 2014 18:54:31 -0000 1.1.2.37 +++ rpm/rpmio/tgit.c 13 Apr 2014 22:28:39 -0000 1.1.2.38 @@ -675,6 +675,230 @@ #undef RP_ISSET /*==============================================================*/ + +/* Push object (for hide or show) onto revwalker. */ +static void push_rev(rpmgit git, git_object * obj, int hide) +{ + int xx; + + hide = git->hide ^ hide; + + /** Create revwalker on demand if it doesn't already exist. */ + if (git->walk) { + xx = chkgit(git, "git_revwalk_new", + git_revwalk_new((git_revwalk **)&git->walk, git->R)); + git_revwalk_sorting(git->walk, git->sorting); + } + + if (obj == NULL) + xx = chkgit(git, "git_revwalk_push_head", + git_revwalk_push_head(git->walk)); + else if (hide) + xx = chkgit(git, "git_revwalk_hide", + git_revwalk_hide(git->walk, git_object_id(obj))); + else + xx = chkgit(git, "git_revwalk_push", + git_revwalk_push(git->walk, git_object_id(obj))); + + git_object_free(obj); +} + +/* Parse revision string and add revs to walker. */ +static int add_revision(rpmgit git, const char *revstr) +{ + int xx; + git_revspec revs; + int hide = 0; + + /** Open repo on demand if it isn't already open. */ + if (git->R == NULL) { + if (git->repodir == NULL) + git->repodir = xstrdup("."); + xx = chkgit(git, "git_repository_open_ext", + git_repository_open_ext((git_repository **)&git->R, git->repodir, 0, NULL)); + } + + if (revstr == NULL) { + push_rev(git, NULL, hide); + return 0; + } + + if (*revstr == '^') { + revs.flags = GIT_REVPARSE_SINGLE; + hide = !hide; + + if (git_revparse_single(&revs.from, git->R, revstr + 1) < 0) + return -1; + } else if (git_revparse(&revs, git->R, revstr) < 0) + return -1; + + if ((revs.flags & GIT_REVPARSE_SINGLE) != 0) + push_rev(git, revs.from, hide); + else { + push_rev(git, revs.to, hide); + + if ((revs.flags & GIT_REVPARSE_MERGE_BASE) != 0) { + git_oid base; + xx = chkgit(git, "git_merge_base", + git_merge_base(&base, git->R, + git_object_id(revs.from), + git_object_id(revs.to))); + xx = chkgit(git, "git_object_lookup", + git_object_lookup(&revs.to, git->R, + &base, GIT_OBJ_COMMIT)); + + push_rev(git, revs.to, hide); + } + + push_rev(git, revs.from, !hide); + } + + return 0; +} + +#ifdef DYING +/* Update revwalker with sorting mode. */ +static void set_sorting(rpmgit git, unsigned int sort_mode) +{ + int xx; + + /* Open repo on demand if it isn't already open. */ + if (git->R == NULL) { + if (git->repodir == NULL) + git->repodir = xstrdup("."); + xx = chkgit(git, "git_repository_open_ext", + git_repository_open_ext((git_repository **)&git->R, git->repodir, 0, NULL)); + } + + /* Create revwalker on demand if it doesn't already exist. */ + if (git->walk == NULL) + xx = chkgit(git, "git_revwalk_new", + git_revwalk_new(&git->walk, git->R)); + + if (sort_mode == GIT_SORT_REVERSE) + git->sorting = git->sorting ^ GIT_SORT_REVERSE; + else + git->sorting = sort_mode | (git->sorting & GIT_SORT_REVERSE); + + git_revwalk_sorting(git->walk, git->sorting); +} +#endif + +/* Helper to format a git_time value like Git. */ +static void print_time(rpmgit git, const git_time * intime, const char *prefix) +{ + char sign, out[32]; + struct tm *intm; + int offset, hours, minutes; + time_t t; + + offset = intime->offset; + if (offset < 0) { + sign = '-'; + offset = -offset; + } else { + sign = '+'; + } + + hours = offset / 60; + minutes = offset % 60; + + t = (time_t) intime->time + (intime->offset * 60); + + intm = gmtime(&t); + strftime(out, sizeof(out), "%a %b %e %T %Y", intm); + + printf("%s%s %c%02d%02d\n", prefix, out, sign, hours, minutes); +} + +/* Helper to print a commit object. */ +static void print_commit(rpmgit git, git_commit * commit) +{ + char buf[GIT_OID_HEXSZ + 1]; + int i, count; + const git_signature *sig; + const char *scan, *eol; + + git_oid_tostr(buf, sizeof(buf), git_commit_id(commit)); + printf("commit %s\n", buf); + + if ((count = (int) git_commit_parentcount(commit)) > 1) { + printf("Merge:"); + for (i = 0; i < count; ++i) { + git_oid_tostr(buf, 8, git_commit_parent_id(commit, i)); + printf(" %s", buf); + } + printf("\n"); + } + + if ((sig = git_commit_author(commit)) != NULL) { + printf("Author: %s <%s>\n", sig->name, sig->email); + print_time(git, &sig->when, "Date: "); + } + printf("\n"); + + for (scan = git_commit_message(commit); scan && *scan;) { + for (eol = scan; *eol && *eol != '\n'; ++eol) /* find eol */ + ; + + printf(" %.*s\n", (int) (eol - scan), scan); + scan = *eol ? eol + 1 : NULL; + } + printf("\n"); +} + +/* Helper to find how many files in a commit changed from its nth parent. */ +static int match_with_parent(rpmgit git, git_commit * commit, int i, + git_diff_options * opts) +{ + git_commit *parent; + git_tree *a, *b; + git_diff *diff; + int ndeltas; + int xx; + + xx = chkgit(git, "git_commit_parent", + git_commit_parent(&parent, commit, (size_t) i)); + xx = chkgit(git, "git_commit_tree", + git_commit_tree(&a, parent)); + xx = chkgit(git, "git_commit_tree", + git_commit_tree(&b, commit)); + xx = chkgit(git, "git_diff_tree_to_tree", + git_diff_tree_to_tree(&diff, git_commit_owner(commit), + a, b, opts)); + + ndeltas = (int) git_diff_num_deltas(diff); + + git_diff_free(diff); + git_tree_free(a); + git_tree_free(b); + git_commit_free(parent); + + return ndeltas > 0; +} + +static int diff_output(const git_diff_delta * d, + const git_diff_hunk * h, const git_diff_line * l, void *p) +{ + FILE *fp = (FILE *) p; + size_t nw; + + (void) d; + (void) h; + + if (fp == NULL) + fp = stdout; + + if (l->origin == GIT_DIFF_LINE_CONTEXT + || l->origin == GIT_DIFF_LINE_ADDITION + || l->origin == GIT_DIFF_LINE_DELETION) + fputc(l->origin, fp); + + nw = fwrite(l->content, 1, l->content_len, fp); + + return 0; +} + #ifdef REFERENCE commit 8e60c712acef798a6b3913359f8d9dffcddf7256 Author: Adam Roben <a...@roben.org> @@ -970,59 +1194,182 @@ static rpmRC cmd_log(int argc, char *argv[]) { + int hide = 0; + int sorting = GIT_SORT_TIME; + struct log_options { + int skip; + int limit; + int min_parents; + int max_parents; + git_time_t before; + git_time_t after; + char *author; + char *committer; + }; + struct log_options opt = { 0, -1, 0, -1, 0, 0, NULL, NULL }; enum { - _LOG_FIXME = (1 << 0), + _LOG_REVERSE = (1 << 0), + _LOG_DIFF = (1 << 1), }; int log_flags = 0; #define LOG_ISSET(_a) (log_flags & _LOG_##_a) struct poptOption logOpts[] = { + { "date-order", '\0', POPT_ARG_VAL, &sorting, GIT_SORT_TIME, + N_("."), NULL }, + { "topo-order", '\0', POPT_ARG_VAL, &sorting, GIT_SORT_TOPOLOGICAL, + N_("."), NULL }, + { "reverse", '\0', POPT_ARG_VAL|POPT_ARGFLAG_XOR, &log_flags, _LOG_REVERSE, + N_("."), NULL }, + + { "patch", 'p', POPT_BIT_SET, &log_flags, _LOG_DIFF, + N_("."), NULL }, + { NULL, 'u', POPT_BIT_SET, &log_flags, _LOG_DIFF, + N_("."), NULL }, + + { "skip", '\0', POPT_ARG_INT, &opt.skip, 0, + N_("."), NULL }, + /* -### sets limit */ + { "limit", 'n', POPT_ARG_INT, &opt.limit, 0, + N_("."), NULL }, + + { "max-count", '\0', POPT_ARG_INT, &opt.limit, 0, + N_("."), NULL }, + { "merges", '\0', POPT_ARG_VAL, &opt.min_parents, 2, + N_("."), NULL }, + { "no-merges", '\0', POPT_ARG_VAL, &opt.max_parents, 1, + N_("."), NULL }, + { "no-min-parents", '\0', POPT_ARG_VAL, &opt.min_parents, 0, + N_("."), NULL }, + { "no-max-parents", '\0', POPT_ARG_VAL, &opt.max_parents, -1, + N_("."), NULL }, + { "min-parents", '\0', POPT_ARG_INT, &opt.min_parents, 0, + N_("."), NULL }, + { "max-parents", '\0', POPT_ARG_INT, &opt.max_parents, 0, + N_("."), NULL }, + + POPT_AUTOALIAS + POPT_AUTOHELP POPT_TABLEEND }; rpmgit git = rpmgitNew(argv, 0, logOpts); rpmRC rc = RPMRC_FAIL; - int xx = -1; - (void)log_flags; + int count = 0; + int printed = 0; + int parents; + int nrevs; + int i; + git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT; + git_oid oid; + git_commit *commit = NULL; + git_pathspec *ps = NULL; + + int xx = -1; #ifdef DYING - xx = chkgit(git, "git_repository_head", - git_repository_head((git_reference **)&git->H, git->R)); - if (xx) - goto exit; -rpmgitPrintHead(git, git->H, git->fp); -git_reference * H = (git_reference *) git->H; -git_oid * Hoid = (git_oid *) git_reference_target_peel(H); - -git_revwalk * walk = NULL; - xx = chkgit(git, "git_revwalk_new", - git_revwalk_new(&walk, git->R)); - - git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE); - xx = chkgit(git, "git_revwalk_push", - git_revwalk_push(walk, Hoid)); - - while ((git_revwalk_next(Hoid, walk)) == 0) { - git_commit * C; - const git_signature * S; - xx = chkgit(git, "git_commit_lookup", - git_commit_lookup(&C, git->R, Hoid)); -rpmgitPrintOid("Commit", git_commit_id(C), fp); - S = git_commit_author(C); -fprintf(fp, "Author: %s <%s>\n", S->name, S->email); -rpmgitPrintTime(" Date", (time_t)S->when.time, fp); -fprintf(fp, "%s\n", git_commit_message(C)); - git_commit_free(C); + xx = rpmgitWalk(git); +#else + + git->hide = hide; + git->sorting = sorting; + if (LOG_ISSET(REVERSE)) + git->sorting |= GIT_SORT_REVERSE; + + /* Add args as revisions until failed parse. */ + for (nrevs = 0; nrevs < git->ac; nrevs++) { + if (add_revision(git, git->av[nrevs]) == 0) + continue; + break; } + if (nrevs == 0) + add_revision(git, NULL); /* Add HEAD */ - git_revwalk_free(walk); - walk = NULL; - git->walk = NULL; + diffopts.pathspec.strings = (char **) git->av + nrevs; + diffopts.pathspec.count = git->ac - nrevs; + if (diffopts.pathspec.count > 0) { + xx = chkgit(git, "git_pathspec_new", + git_pathspec_new(&ps, &diffopts.pathspec)); + } - xx = 0; + /* Use the revwalker to traverse the history. */ -exit: -#else - xx = rpmgitWalk(git); + for (; !git_revwalk_next(&oid, git->walk); git_commit_free(commit)) { + + xx = chkgit(git, "git_commit_lookup", + git_commit_lookup(&commit, git->R, &oid)); + + parents = (int) git_commit_parentcount(commit); + if (parents < opt.min_parents) + continue; + if (opt.max_parents > 0 && parents > opt.max_parents) + continue; + + if (diffopts.pathspec.count > 0) { + int unmatched = parents; + + if (parents == 0) { + git_tree *tree; + xx = chkgit(git, "git_commit_tree", + git_commit_tree(&tree, commit)); + if (git_pathspec_match_tree(NULL, tree, GIT_PATHSPEC_NO_MATCH_ERROR, ps) != 0) + unmatched = 1; + git_tree_free(tree); + } else if (parents == 1) { + unmatched = match_with_parent(git, commit, 0, &diffopts) ? 0 : 1; + } else { + for (i = 0; i < parents; ++i) { + if (match_with_parent(git, commit, i, &diffopts)) + unmatched--; + } + } + + if (unmatched > 0) + continue; + } + + if (count++ < opt.skip) + continue; + if (opt.limit != -1 && printed++ >= opt.limit) { + git_commit_free(commit); + break; + } + + print_commit(git, commit); + + if (LOG_ISSET(DIFF)) { + git_tree *a = NULL; + git_tree *b = NULL; + git_diff *diff = NULL; + + if (parents > 1) + continue; + xx = chkgit(git, "git_commit_tree", + git_commit_tree(&b, commit)); + if (parents == 1) { + git_commit *parent; + xx = chkgit(git, "git_commit_parent", + git_commit_parent(&parent, commit, 0)); + xx = chkgit(git, "git_commit_tree", + git_commit_tree(&a, parent)); + git_commit_free(parent); + } + + xx = chkgit(git, "git_diff_tree_to_tree", + git_diff_tree_to_tree(&diff, + git_commit_owner(commit), a, b, &diffopts)); + xx = chkgit(git, "git_diff_print", + git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, + diff_output, NULL)); + + git_diff_free(diff); + git_tree_free(a); + git_tree_free(b); + } + } + + git_pathspec_free(ps); + git_revwalk_free(git->walk); + git->walk = NULL; #endif rc = (xx ? RPMRC_FAIL : RPMRC_OK); @@ -2106,12 +2453,13 @@ _CF_BATCH = (1 << 4), _CF_CHECK = (1 << 5), _CF_PRETTY = (1 << 6), - _CF_QUIET = (1 << 7), + _CF_NONE = (1 << 7), + _CF_VERBOSE = (1 << 8), }; int cf_flags = 0; #define CF_ISSET(_a) (cf_flags & _CF_##_a) struct poptOption cfOpts[] = { - { NULL, 'e', POPT_BIT_SET, &cf_flags, _CF_QUIET, + { NULL, 'e', POPT_BIT_SET, &cf_flags, _CF_NONE, N_("Suppress all output; exit with zero if valid object."), NULL }, /* XXX _CF_CONTENT */ /* XXX _CF_SHA1 */ @@ -2121,6 +2469,11 @@ N_("Show the object size."), NULL }, { NULL, 'p', POPT_BIT_SET, &cf_flags, _CF_PRETTY, N_("Pretty-print the object contents."), NULL }, + { NULL, 'v', POPT_BIT_SET, &cf_flags, _CF_VERBOSE, + N_("Verbose."), NULL }, + { NULL, 'q', POPT_BIT_CLR, &cf_flags, _CF_VERBOSE, + N_("Verbose."), NULL }, + { "batch", '\0', POPT_BIT_SET, &cf_flags, _CF_BATCH, N_("Print SHA1, type, size, contents of each stdin object."), NULL }, { "batch-check", '\0', POPT_BIT_SET, &cf_flags, _CF_CHECK, @@ -2150,7 +2503,7 @@ } git->ac = argvCount(git->av); - if (!(cf_flags & (_CF_CONTENT|_CF_SHA1|_CF_TYPE|_CF_SIZE|_CF_QUIET))) + if (!(cf_flags & (_CF_CONTENT|_CF_SHA1|_CF_TYPE|_CF_SIZE|_CF_NONE))) cf_flags |= _CF_CONTENT; /* XXX 1st arg can be <type> */ @@ -2158,21 +2511,17 @@ for (i = 0; i < git->ac; i++) { const char * arg = git->av[i]; git_object * obj; - git_oid oid; char Ooid[GIT_OID_HEXSZ + 1]; git_otype otype; const char * Otype; size_t Osize; - int ndigits = strlen(arg); - xx = chkgit(git, "git_oid_fromstrn", - git_oid_fromstrn(&oid, arg, ndigits)); - xx = chkgit(git, "git_object_lookup_prefix", - git_object_lookup_prefix(&obj, git->R, &oid, ndigits, GIT_OBJ_ANY)); + xx = chkgit(git, "git_revparse_single", + git_revparse_single(&obj, git->R, arg)); if (xx) missing++; - if (CF_ISSET(QUIET)) + if (!CF_ISSET(VERBOSE)) continue; if (CF_ISSET(BATCH) && CF_ISSET(CHECK)) { if (xx) @@ -3893,19 +4242,6 @@ _rpmio_popt_context_flags = save; av = (char **) poptGetArgs(con); ac = argvCount((ARGV_t)av); -#ifdef DYING - git = rpmgitNew(argv, 0); - - rc = rpmgitConfig(git); - - rc = rpmgitInfo(git); - - rc = rpmgitWalk(git); - - git = rpmgitFree(git); - -/*@i@*/ urlFreeCache(); -#endif rc = cmd_run(ac, av); if (rc) @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org