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:   10-Jun-2012 13:54:29
  Branch: rpm-5_4                          Handle: 2012061011542800

  Modified files:           (Branch: rpm-5_4)
    rpm/rpmio               rpmgit.c tgit.c

  Log:
    - git: WIP.

  Summary:
    Revision    Changes     Path
    2.1.2.14    +36 -32     rpm/rpmio/rpmgit.c
    1.1.2.12    +66 -117    rpm/rpmio/tgit.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmgit.c
  ============================================================================
  $ cvs diff -u -r2.1.2.13 -r2.1.2.14 rpmgit.c
  --- rpm/rpmio/rpmgit.c        8 Jun 2012 17:52:14 -0000       2.1.2.13
  +++ rpm/rpmio/rpmgit.c        10 Jun 2012 11:54:28 -0000      2.1.2.14
  @@ -188,7 +188,7 @@
       size_t nw = strftime(_b, _nb-1, _fmt, localtime_r(&_Ctime, &tm));
       (void)nw;
   if (msg) fprintf(fp, "%s:", msg);
  -fprintf(fp, " %s\n", _b);
  +fprintf(fp, " %s", _b);
   }
   
   void rpmgitPrintSig(const char * msg, const void * _S, void * _fp)
  @@ -199,6 +199,7 @@
   if (msg) fprintf(fp, "%s:", msg);
   fprintf(fp, " %s <%s>", S->name, S->email);
   rpmgitPrintTime(NULL, (time_t)S->when.time, fp);
  +fprintf(fp, "\n");
   }
   
   void rpmgitPrintIndex(void * _I, void * _fp)
  @@ -221,7 +222,7 @@
   
        rpmgitPrintOid("\n\t  oid", &E->oid, fp);
   
  -     fprintf(fp, "\n\t  dev: %x", (unsigned)E->dev);
  +     fprintf(fp,   "\t  dev: %x", (unsigned)E->dev);
        fprintf(fp, "\n\t  ino: %lu", (unsigned long)E->ino);
        fprintf(fp, "\n\t mode: %o", (unsigned)E->mode);
   
  @@ -240,6 +241,7 @@
       }
   }
   
  +#ifdef       DYING
   static const char * rpmgitOtype(git_otype otype)
        /*@*/
   {
  @@ -257,8 +259,8 @@
       case GIT_OBJ_REF_DELTA:  s = "delta oid";        break;
       }
       return s;
  -
   }
  +#endif
   
   void rpmgitPrintTree(void * _T, void * _fp)
   {
  @@ -285,7 +287,7 @@
        t = git_oid_allocfmt(git_tree_entry_id(E));
        fprintf(fp, "%06o %.4s %s\t%s\n",
                git_tree_entry_attributes(E),
  -             rpmgitOtype(git_tree_entry_type(E)),
  +             git_object_type2string(git_tree_entry_type(E)),
                t,
                git_tree_entry_name(E));
        t = _free(t);
  @@ -309,6 +311,7 @@
   fprintf(fp,     "         Cmsg: %s\n", git_commit_message(C));
   
   rpmgitPrintTime("        Ctime", git_commit_time(C), fp);
  +fprintf(fp, "\n");
   
   fprintf(fp,     "          Ctz: %d\n", git_commit_time_offset(C));
    rpmgitPrintSig("      Cauthor", git_commit_author(C), fp);
  @@ -348,7 +351,7 @@
   fprintf(fp,     "      Htarget: %s\n", git_reference_target(H));
   fprintf(fp,     "        Hname: %s\n", git_reference_name(H));
   fprintf(fp,     "    Hresolved: %p\n", Hresolved);
  -fprintf(fp,     "       Howner: %p\n", git_reference_owner(H));
  +fprintf(fp,     "       Howner: %p", git_reference_owner(H));
   #ifdef       DYING
   fprintf(fp,     "       Hrtype: %d\n", (int)git_reference_type(H));
   #else
  @@ -371,11 +374,14 @@
   fprintf(fp, "head_detached: %d\n", git_repository_head_detached(R));
   fprintf(fp, "  head_orphan: %d\n", git_repository_head_orphan(R));
   fprintf(fp, "     is_empty: %d\n", git_repository_is_empty(R));
  +fprintf(fp, "      is_bare: %d\n", git_repository_is_bare(R));
       fn = git_repository_path(R);
   fprintf(fp, "         path: %s\n", fn);
       fn = git_repository_workdir(R);
   fprintf(fp, "      workdir: %s\n", fn);
  -fprintf(fp, "      is_bare: %d\n", git_repository_is_bare(R));
  +    /* XXX get_repository_config */
  +    /* XXX get_repository_odb */
  +    /* XXX get_repository_index */
   
   }
   #endif       /* defined(WITH_LIBGT2) */
  @@ -589,41 +595,42 @@
   int rpmgitWalk(rpmgit git)
   {
       int rc = -1;
  -#if defined(WITH_LIBGIT2) && defined(NOTYET)
  +#if defined(WITH_LIBGIT2)
       FILE * fp = (git->fp ? git->fp : stdout);
  +    git_revwalk * walk;
       git_oid oid;
       int xx;
   
       xx = chkgit(git, "git_revwalk_new",
  -             git_revwalk_new((git_revwalk **)&git->walk, git->R));
  -    git_revwalk_sorting(git->walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE);
  +             git_revwalk_new(&walk, git->R));
  +    git_revwalk_sorting(walk, GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE);
       xx = chkgit(git, "git_revwalk_push_head",
  -             git_revwalk_push_head(git->walk));
  +             git_revwalk_push_head(walk));
  +    git->walk = (void *) walk;
   
       while ((xx = chkgit(git, "git_revwalk_next",
  -             git_revwalk_next(&oid, git->walk))) == GIT_SUCCESS)
  +             git_revwalk_next(&oid, walk))) == GIT_OK)
       {
  -     git_commot *wcommit;
  -     const git_signature * cauth;
  -     const char * cmsg;
  -
  -     git_oid_fmt(t, &oid);
  -     t[GIT_OID_HEXSZ] = '\0';
  -     fprintf(fp, "\t  oid: %s", t);
  +     git_commit * C;
  +     const git_signature * S;
   
        xx = chkgit(git, "git_commit_lookup",
  -             git_commit_lookup(&wcommit, git->R, &oid));
  -     cmsg  = git_commit_message(wcommit);
  -     cauth = git_commit_author(wcommit);
  -     fprintf(fp, "\n\t%s (%s)", cmsg, cauth->email);
  -     git_commit_free(wcommit);
  -     
  -     fprintf(fp, "\n");
  +             git_commit_lookup(&C, git->R, &oid));
  +rpmgitPrintOid("Commit", git_commit_id(C), fp);
  +     S = git_commit_author(C);
  +fprintf(fp, "Author: %s <%s>", S->name, S->email);
  +rpmgitPrintTime("\n  Date", (time_t)S->when.time, fp);
  +fprintf(fp, "\n%s", git_commit_message(C));
  +fprintf(fp, "\n");
  +     git_commit_free(C);
       }
   
  -    git_revwalk_free(git->walk);
       git->walk = NULL;
  +    git_revwalk_free(walk);
  +    walk = NULL;
       rc = 0;  /* XXX */
  +
  +exit:
   #endif
   SPEW(0, rc, git);
       return rc;
  @@ -802,20 +809,17 @@
   
   rpmgit rpmgitNew(const char * fn, int flags)
   {
  -    static const char _gitfn[] = "/var/tmp/rpmgit/.git";
       rpmgit git = rpmgitGetPool(_rpmgitPool);
       int xx;
   
  -    if (fn == NULL)
  -     fn = _gitfn;
  -
       if (fn)
        git->fn = xstrdup(fn);
   
   #if defined(WITH_LIBGIT2)
       git_libgit2_version(&git->major, &git->minor, &git->rev);
  -    xx = chkgit(git, "git_repository_open",
  -             git_repository_open((git_repository **)&git->R, fn));
  +    if (git->fn)
  +     xx = chkgit(git, "git_repository_open",
  +             git_repository_open((git_repository **)&git->R, git->fn));
   #endif
   
       return rpmgitLink(git);
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tgit.c
  ============================================================================
  $ cvs diff -u -r1.1.2.11 -r1.1.2.12 tgit.c
  --- rpm/rpmio/tgit.c  9 Jun 2012 18:35:53 -0000       1.1.2.11
  +++ rpm/rpmio/tgit.c  10 Jun 2012 11:54:28 -0000      1.1.2.12
  @@ -16,14 +16,14 @@
   
   #include "debug.h"
   
  -static const char * repofn = "/var/tmp/git/.git";
  -
   #define      SPEW(_t, _rc, _git)     \
     { if ((_t) || _rpmgit_debug ) \
        fprintf(stderr, "<-- %s(%p) rc %d\n", __FUNCTION__, (_git), \
                (_rc)); \
     }
   
  +#define      RPMGIT_DIR      "/var/tmp/git"
  +
   static const char * exec_path;
   static const char * html_path;
   static const char * man_path;
  @@ -31,13 +31,13 @@
   static int paginate;
   static int no_replace_objects;
   static int bare;
  -static const char * git_dir;
  -static const char * work_tree;
  +static const char * git_dir = RPMGIT_DIR "/.git";
  +static const char * work_tree = RPMGIT_DIR;
   
  -static git_diff_options opts = {0};
  +static git_diff_options opts;
   static int color = -1;
  -static int compact = 0;
  -static int cached = 0;
  +static int compact;
  +static int cached;
   
   /*==============================================================*/
   static int Xchkgit(/*@unused@*/ rpmgit git, const char * msg,
  @@ -148,16 +148,12 @@
       static const char _msg[] = "WDJ commit";
       rpmRC rc = RPMRC_FAIL;
       const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
       int i;
   
  -assert(ac >= 2);
   if (strcmp(av[0], "init")) assert(0);
   
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
  -
       /* Initialize a git repository. */
       xx = rpmgitInit(git);
       if (xx)
  @@ -290,16 +286,12 @@
   {
       rpmRC rc = RPMRC_FAIL;
       const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
       int i;
   
  -assert(ac >= 2);
   if (strcmp(av[0], "add")) assert(0);
   
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
  -
       /* XXX Get the index file for this repository. */
       xx = chkgit(git, "git_repository_index",
                git_repository_index((git_index **)&git->I, git->R));
  @@ -308,7 +300,7 @@
   
   if (_rpmgit_debug < 0) rpmgitPrintIndex(git->I, git->fp);
       /* Create file(s) in _workdir (if any). */
  -    for (i = 2; i < ac; i++) {
  +    for (i = 1; i < ac; i++) {
        struct stat sb;
   
        fn = av[i];
  @@ -510,17 +502,11 @@
   {
       static const char _msg[] = "WDJ commit";
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
  -    int i;
   
  -assert(ac >= 2);
   if (strcmp(av[0], "commit")) assert(0);
   
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
  -
       /* XXX Get the index file for this repository. */
       xx = chkgit(git, "git_repository_index",
                git_repository_index((git_index **)&git->I, git->R));
  @@ -643,24 +629,22 @@
   
   static rpmRC cmd_diff(int ac, char *av[])
   {
  -char path[GIT_PATH_MAX];
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
       rpmgit git = NULL;
  -const char * dir = ".";
   git_diff_list * diff = NULL;
   const char * treeish1 = NULL;
   git_tree *t1 = NULL;
   const char * treeish2 = NULL;
   git_tree *t2 = NULL;
       int xx = -1;
  -    int i;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 1);
   if (strcmp(av[0], "diff")) assert(0);
   
   #ifdef       NOTYET
  +const char * dir = ".";
  +char path[GIT_PATH_MAX];
  +const char * fn;
       xx = chkgit(git, "git_repository_discover",
        git_repository_discover(path, sizeof(path), dir, 0, "/"));
       if (xx) {
  @@ -668,10 +652,8 @@
        goto exit;
       }
       fn = path;
  -#else
  -    fn = "/var/tmp/xxx";
   #endif
  -    git = rpmgitNew(fn, 0);
  +    git = rpmgitNew(git_dir, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
       if (ac >= 2)
  @@ -790,19 +772,16 @@
   static rpmRC cmd_status(int ac, char *av[])
   {
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
  -    int i;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 2);
   if (strcmp(av[0], "status")) assert(0);
   
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
  +    xx = 0;
  +
   exit:
       rc = (xx ? RPMRC_FAIL : RPMRC_OK);
   SPEW(0, rc, git);
  @@ -816,20 +795,17 @@
   static rpmRC cmd_clone(int ac, char *av[])
   {
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
  -    int i;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 2);
   if (strcmp(av[0], "clone")) assert(0);
   
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
  -fprintf(stderr, "\ttgit clone %s\n", av[2]);
  +fprintf(stderr, "\ttgit clone %s\n", av[1]);
  +
  +    xx = 0;
   
   exit:
       rc = (xx ? RPMRC_FAIL : RPMRC_OK);
  @@ -844,19 +820,16 @@
   static rpmRC cmd_walk(int ac, char *av[])
   {
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
  -    int i;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 2);
   if (strcmp(av[0], "walk")) assert(0);
   
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
  +    xx = 0;
  +
   exit:
       rc = (xx ? RPMRC_FAIL : RPMRC_OK);
   SPEW(0, rc, git);
  @@ -1163,18 +1136,15 @@
   {
       FILE * fp = stdout;
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 1);
   if (strcmp(av[0], "log")) assert(0);
   
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
  +#ifdef       DYING
       xx = chkgit(git, "git_repository_head",
                git_repository_head((git_reference **)&git->H, git->R));
       if (xx)
  @@ -1207,6 +1177,9 @@
       git->walk = NULL;
   
       xx = 0;
  +#else
  +    xx = rpmgitWalk(git);
  +#endif
   
   exit:
       rc = (xx ? RPMRC_FAIL : RPMRC_OK);
  @@ -1329,24 +1302,21 @@
   {
       FILE * fp = stdout;
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
   git_strarray branches;
       char active = '*';       /* XXX assumes 1st branch is active */
       int xx = -1;
       int i;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 1);
   if (strcmp(av[0], "branch")) assert(0);
  -
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
       /* XXX assumes -a listing */
       xx = chkgit(git, "git_branch_list",
                git_branch_list(&branches, git->R, GIT_BRANCH_LOCAL));
  +    if (xx)
  +     goto exit;
       for (i = 0; i < (int)branches.count; ++i) {
        char * brname = branches.strings[i];
        fprintf(fp, "%c %s\n", active, basename(brname));
  @@ -1405,25 +1375,22 @@
   static rpmRC cmd_hash_object(int ac, char *av[])
   {
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn = NULL;
  -    rpmgit git;
  +    const char * fn = "-";   /* XXX assume --stdin */
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
   rpmiob iob = NULL;
   char * digest = NULL;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 1);
   if (strcmp(av[0], "hash-object")) assert(0);
  -
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
       /* XXX assume -t blob */
  -    fn = "-";        /* XXX assume --stdin */
   
       xx = rpmiobSlurp(fn, &iob);
  -    if (!(xx || iob == NULL)) {
  +    if (xx)
  +     goto exit;
  +    if (iob) {
        DIGEST_CTX ctx;
        char b[128];
        size_t nb = sizeof(b);
  @@ -1485,8 +1452,7 @@
   static rpmRC cmd_cat_file(int ac, char *av[])
   {
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn = NULL;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
   git_blob * blob = NULL;
   git_oid oid;
   const char * b;
  @@ -1494,11 +1460,7 @@
       int xx = -1;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 2);
   if (strcmp(av[0], "cat-file")) assert(0);
  -
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
       git_oid_fromstr(&oid, av[2]);
  @@ -1529,16 +1491,11 @@
   static rpmRC cmd_index(int ac, char *av[])
   {
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 1);
   if (strcmp(av[0], "index")) assert(0);
  -
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
       xx = chkgit(git, "git_repository_index",
  @@ -1564,22 +1521,19 @@
   {
       FILE * fp = stdout;
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
   git_strarray refs;
       int xx = -1;
       int i;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 1);
   if (strcmp(av[0], "refs")) assert(0);
  -
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
       xx = chkgit(git, "git_reference_list",
                git_reference_list(&refs, git->R, GIT_REF_LISTALL));
  +    if (xx)
  +     goto exit;
   
       for (i = 0; i < (int)refs.count; ++i) {
        char oid[GIT_OID_HEXSZ + 1];
  @@ -1617,16 +1571,11 @@
   static rpmRC cmd_config(int ac, char *av[])
   {
       rpmRC rc = RPMRC_FAIL;
  -    const char * fn;
  -    rpmgit git;
  +    rpmgit git = rpmgitNew(git_dir, 0);
       int xx = -1;
   
   argvPrint(__FUNCTION__, (ARGV_t)av, NULL);
  -assert(ac >= 1);
   if (strcmp(av[0], "config")) assert(0);
  -
  -    fn = (ac >= 2 ? av[1] : repofn);
  -    git = rpmgitNew(fn, 0);
   rpmgitPrintRepo(git, git->R, git->fp);
   
       /* Print configuration info. */
  @@ -1656,7 +1605,7 @@
   static rpmRC cmd_ls_remote(int ac, char *av[])
   {
       rpmRC rc = RPMRC_FAIL;
  -    rpmgit git = rpmgitNew(repofn, 0);
  +    rpmgit git = rpmgitNew(git_dir, 0);
       git_remote * remote = NULL;
       int xx = -1;
   
  @@ -1753,7 +1702,6 @@
   static int update_cb(const char *refname, const git_oid * a, const git_oid * 
b)
   {
       FILE * fp = stdout;
  -    const char *action;
       char a_str[GIT_OID_HEXSZ + 1];
       char b_str[GIT_OID_HEXSZ + 1];
   
  @@ -1775,7 +1723,7 @@
   {
       FILE * fp = stdout;
       rpmRC rc = RPMRC_FAIL;
  -    rpmgit git = rpmgitNew(repofn, 0);
  +    rpmgit git = rpmgitNew(git_dir, 0);
       git_remote *remote = NULL;
       git_off_t bytes = 0;
       git_indexer_stats stats;
  @@ -1865,7 +1813,7 @@
   {
       FILE * fp = stderr;
       rpmRC rc = RPMRC_FAIL;
  -    rpmgit git = rpmgitNew(repofn, 0);
  +    rpmgit git = rpmgitNew(git_dir, 0);
       git_indexer_stream *idx = NULL;
       git_indexer_stats stats = { 0, 0 };
       int fdno = 0;
  @@ -1937,7 +1885,7 @@
   {
       FILE * fp = stderr;
       rpmRC rc = RPMRC_FAIL;
  -    rpmgit git = rpmgitNew(repofn, 0);
  +    rpmgit git = rpmgitNew(git_dir, 0);
       git_indexer *indexer = NULL;
       git_indexer_stats stats;
       char hash[GIT_OID_HEXSZ + 1] = {0};
  @@ -2118,7 +2066,6 @@
   
   static rpmRC cmd_run(int ac, /*@unused@*/ char *av[])
   {
  -    FILE * fp = stderr;
       struct poptOption * c;
       const char * cmd;
       rpmRC rc = RPMRC_FAIL;
  @@ -2224,17 +2171,6 @@
   };
   
   static struct poptOption rpmgitOptionsTable[] = {
  -#ifdef       REFERENCE
  -static const char * exec_path;
  -static const char * html_path;
  -static const char * man_path;
  -static const char * info_path;
  -static int paginate;
  -static int no_replace_objects;
  -static int bare;
  -static const char * git_dir;
  -static const char * work_tree;
  -#endif
     { "exec-path", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN,      
&exec_path, 0,
           N_("Set exec path to <DIR>. env(GIT_EXEC_PATH)"), N_("<DIR>") },
     { "html-path", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN,      
&html_path, 0,
  @@ -2250,9 +2186,9 @@
    { "bare", '\0', POPT_ARG_VAL|POPT_ARGFLAG_DOC_HIDDEN,       &bare, 1,
        N_("Treat as a bare repository."), NULL },
   
  -  { "git-dir", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN,        
&git_dir, 0,
  +  { "git-dir", '\0', POPT_ARG_STRING,        &git_dir, 0,
           N_("Set git repository dir to <DIR>. env(GIT_DIR)"), N_("<DIR>") },
  -  { "work-tree", '\0', POPT_ARG_STRING|POPT_ARGFLAG_DOC_HIDDEN,      
&work_tree, 0,
  +  { "work-tree", '\0', POPT_ARG_STRING,      &work_tree, 0,
           N_("Set git work tree to <DIR>. env(GIT_WORK_TREE)"), N_("<DIR>") },
   
    { NULL, '\0', POPT_ARG_INCLUDE_TABLE, rpmgitDiffOpts, 0,
  @@ -2271,11 +2207,21 @@
   int
   main(int argc, char *argv[])
   {
  -    poptContext con = rpmioInit(argc, argv, rpmgitOptionsTable);
  -    char ** av = (char **) poptGetArgs(con);
  -    int ac = argvCount((ARGV_t)av);
  +    poptContext con;
  +    char ** av;
  +    int ac;
       int rc = 0;
   
  +    if ((git_dir = getenv("GIT_DIR")) == NULL)
  +     git_dir = RPMGIT_DIR "/.git";
  +    git_dir = xstrdup(git_dir);
  +    if ((work_tree = getenv("GIT_WORK_TREE")) == NULL)
  +     work_tree = RPMGIT_DIR;
  +    work_tree = xstrdup(work_tree);
  +
  +    con = rpmioInit(argc, argv, rpmgitOptionsTable);
  +    av = (char **) poptGetArgs(con);
  +    ac = argvCount((ARGV_t)av);
   #ifdef       DYING
       git = rpmgitNew(NULL, 0);
   
  @@ -2293,5 +2239,8 @@
   
       con = rpmioFini(con);
   
  +    git_dir = _free(git_dir);
  +    work_tree = _free(work_tree);
  +
       return rc;
   }
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to