build-rev-cache.con commit Add Pine 4.63 help from Daniel. (1eb446f)
   1#include "refs.h"
   2#include "cache.h"
   3#include "commit.h"
   4#include "rev-cache.h"
   5
   6static void process_head_list(int verbose)
   7{
   8        char buf[512];
   9
  10        while (fgets(buf, sizeof(buf), stdin)) {
  11                unsigned char sha1[20];
  12                struct commit *commit;
  13
  14                if (get_sha1_hex(buf, sha1)) {
  15                        error("ignoring: %s", buf);
  16                        continue;
  17                }
  18                if (!(commit = lookup_commit_reference(sha1))) {
  19                        error("not a commit: %s", sha1_to_hex(sha1));
  20                        continue;
  21                }
  22                record_rev_cache(commit->object.sha1, verbose ? stderr : NULL);
  23        }
  24}
  25
  26
  27static const char *build_rev_cache_usage =
  28"git-build-rev-cache <rev-cache-file> < list-of-heads";
  29
  30int main(int ac, char **av)
  31{
  32        int verbose = 0;
  33        const char *path;
  34
  35        while (1 < ac && av[1][0] == '-') {
  36                if (!strcmp(av[1], "-v"))
  37                        verbose = 1;
  38                else
  39                        usage(build_rev_cache_usage);
  40                ac--; av++;
  41        }
  42
  43        if (ac != 2)
  44                usage(build_rev_cache_usage);
  45
  46        path = av[1];
  47
  48        /* read existing rev-cache */
  49        read_rev_cache(path, NULL, 0);
  50
  51        process_head_list(verbose);
  52
  53        /* update the rev-cache database by appending newly found one to it */
  54        write_rev_cache(path, path);
  55        return 0;
  56}