<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def history(location, model, filename, deployment, custom_config):
 """Generate a report over a model's git commit history."""

    callbacks.git_installed()
    LOGGER.info("Initialising history report generation.")
    if location is None:
        raise click.BadParameter("No 'location' given or configured.")
    try:
        repo = git.Repo()
    except git.InvalidGitRepositoryError:
        LOGGER.critical(
            "The history report requires a git repository in order to check "
            "the model's commit history.")
        sys.exit(1)
    LOGGER.info("Obtaining history of results from "
                "the deployment branch {}.".format(deployment))
    repo.git.checkout(deployment)
    try:
        manager = managers.SQLResultManager(repository=repo, location=location)
    except (AttributeError, ArgumentError):
        manager = managers.RepoResultManager(
            repository=repo, location=location)
    config = ReportConfiguration.load()
    # Update the default test configuration with custom ones (if any).
    for custom in custom_config:
        config.merge(ReportConfiguration.load(custom))
    LOGGER.info("Tracing the commit history.")
    history = managers.HistoryManager(repository=repo, manager=manager)
    history.load_history(model, skip={deployment})
    LOGGER.info("Composing the history report.")
    report = api.history_report(history, config=config)
    with open(filename, "w", encoding="utf-8") as file_handle:
        file_handle.write(report)