Esempio n. 1
0
int gbr_remote_delta(const char *name, git_branch_t type, struct gbr_dump_context *ctx)
{
	char tbuf[32];
	struct gbr_sha sha;
	int err;

	ctx->local_name = name;
	ctx->uptodate_remotes = 0;
	err = git_revparse_single(&ctx->local_obj, ctx->repo, name);
	if (err == 0) {
		printf("%s %s %s",
		       gbr_ctime_object(tbuf, sizeof(tbuf), ctx->local_obj),
		       name,
		       gbr_sha(&sha, git_object_id(ctx->local_obj), ctx->abbrev));
		gbr_for_each_remote(ctx->repo, dump_matching_branch, ctx);
		git_object_free(ctx->local_obj);
	} else {
		printf("%s ERROR [%d] %s", name, err, giterr_last()->message);
	}

	printf("\n");

	if (ctx->prune && ctx->uptodate_remotes > 0) {
		do_prune(ctx->repo, name);
	}

	return err;
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
  if (argc == 1) {
    usage(argv[0]);
    return EXIT_FAILURE;
  }

  std::string szInputFolder;
  int index;
  bool bDryRun = false;

  for (index = 1; index < argc && argv[index][0] == '-'; index++) {
    std::string option(&argv[index][1]);

    if (option == "h" || option == "-help") {
      usage(argv[0]);
      return EXIT_SUCCESS;
    } else if (option == "d" || option == "-dry-run") {
      bDryRun = true;
    } else if (option == "i" || option == "-input") {
      if (index + 1 < argc) {
        szInputFolder = argv[++index];
        struct stat sb;
        int ret = stat(szInputFolder.c_str(), &sb);
        if (ret) {
          perror("stat");
          return EXIT_FAILURE;
        }

        if (!S_ISDIR(sb.st_mode)) {
          fprintf(stderr, "Input directory not a directory\n");
          return EXIT_FAILURE;
        }

      } else {
        fprintf(stderr, "Error: Missing directory name\n");
        return EXIT_FAILURE;
      }
    } else {
      fprintf(stderr, "Error: Unknown option \"-%s\"\n", option.c_str());
      usage(argv[0]);
      return EXIT_FAILURE;
    }
  }

  if (index == argc) {
    fprintf(stderr, "Error: No directory specified\n");
    return EXIT_FAILURE;
  }

  if (index + 1 != argc) {
    fprintf(stderr, "Error: More than one directory specified\n");
    return EXIT_FAILURE;
  }

  FileFinder oFiles;

  int rc = handle_arg(argv[index], oFiles);
  if (rc)
    return EXIT_FAILURE;

  if (szInputFolder.empty())
    szInputFolder = argv[index];

  const std::vector<RawWorkItem *> o_WorkItems = oFiles.get_work_items();
  if (o_WorkItems.size() == 0) {
    printf("No raw files found in folder '%s'\n", argv[index]);
    return EXIT_SUCCESS;
  }

  std::list<std::string> filter;
  filter.push_back(dng_suffix);

  std::list<std::string> files;
  rc = list_dir(szInputFolder, files, filter);
  if (rc)
    return EXIT_FAILURE;

  if (files.size() == 0) {
    printf("No DNG files found in folder '%s'\n", szInputFolder.c_str());
    return EXIT_SUCCESS;
  }

  rc = do_prune(o_WorkItems, files, bDryRun);
  if (rc)
    return EXIT_FAILURE;

  printf("Prune complete\n");

  return EXIT_SUCCESS;
}