|
Packit Service |
20376f |
/*
|
|
Packit Service |
20376f |
* Copyright (C) the libgit2 contributors. All rights reserved.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
|
Packit Service |
20376f |
* a Linking Exception. For full terms see the included COPYING file.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
#ifndef INCLUDE_config_h__
|
|
Packit Service |
20376f |
#define INCLUDE_config_h__
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#include "git2.h"
|
|
Packit Service |
20376f |
#include "git2/config.h"
|
|
Packit Service |
20376f |
#include "vector.h"
|
|
Packit Service |
20376f |
#include "repository.h"
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#define GIT_CONFIG_FILENAME_PROGRAMDATA "config"
|
|
Packit Service |
20376f |
#define GIT_CONFIG_FILENAME_SYSTEM "gitconfig"
|
|
Packit Service |
20376f |
#define GIT_CONFIG_FILENAME_GLOBAL ".gitconfig"
|
|
Packit Service |
20376f |
#define GIT_CONFIG_FILENAME_XDG "config"
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#define GIT_CONFIG_FILENAME_INREPO "config"
|
|
Packit Service |
20376f |
#define GIT_CONFIG_FILE_MODE 0666
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
struct git_config {
|
|
Packit Service |
20376f |
git_refcount rc;
|
|
Packit Service |
20376f |
git_vector files;
|
|
Packit Service |
20376f |
};
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
extern int git_config__global_location(git_buf *buf);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
extern int git_config_rename_section(
|
|
Packit Service |
20376f |
git_repository *repo,
|
|
Packit Service |
20376f |
const char *old_section_name, /* eg "branch.dummy" */
|
|
Packit Service |
20376f |
const char *new_section_name); /* NULL to drop the old section */
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Create a configuration file backend for ondisk files
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* These are the normal `.gitconfig` files that Core Git
|
|
Packit Service |
20376f |
* processes. Note that you first have to add this file to a
|
|
Packit Service |
20376f |
* configuration object before you can query it for configuration
|
|
Packit Service |
20376f |
* variables.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* @param out the new backend
|
|
Packit Service |
20376f |
* @param path where the config file is located
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
extern int git_config_file__ondisk(git_config_backend **out, const char *path);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
extern int git_config__normalize_name(const char *in, char **out);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/* internal only: does not normalize key and sets out to NULL if not found */
|
|
Packit Service |
20376f |
extern int git_config__lookup_entry(
|
|
Packit Service |
20376f |
git_config_entry **out,
|
|
Packit Service |
20376f |
const git_config *cfg,
|
|
Packit Service |
20376f |
const char *key,
|
|
Packit Service |
20376f |
bool no_errors);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/* internal only: update and/or delete entry string with constraints */
|
|
Packit Service |
20376f |
extern int git_config__update_entry(
|
|
Packit Service |
20376f |
git_config *cfg,
|
|
Packit Service |
20376f |
const char *key,
|
|
Packit Service |
20376f |
const char *value,
|
|
Packit Service |
20376f |
bool overwrite_existing,
|
|
Packit Service |
20376f |
bool only_if_existing);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/*
|
|
Packit Service |
20376f |
* Lookup functions that cannot fail. These functions look up a config
|
|
Packit Service |
20376f |
* value and return a fallback value if the value is missing or if any
|
|
Packit Service |
20376f |
* failures occur while trying to access the value.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
extern char *git_config__get_string_force(
|
|
Packit Service |
20376f |
const git_config *cfg, const char *key, const char *fallback_value);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
extern int git_config__get_bool_force(
|
|
Packit Service |
20376f |
const git_config *cfg, const char *key, int fallback_value);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
extern int git_config__get_int_force(
|
|
Packit Service |
20376f |
const git_config *cfg, const char *key, int fallback_value);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/* API for repository cvar-style lookups from config - not cached, but
|
|
Packit Service |
20376f |
* uses cvar value maps and fallbacks
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
extern int git_config__cvar(
|
|
Packit Service |
20376f |
int *out, git_config *config, git_cvar_cached cvar);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* The opposite of git_config_lookup_map_value, we take an enum value
|
|
Packit Service |
20376f |
* and map it to the string or bool value on the config.
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
int git_config_lookup_map_enum(git_cvar_t *type_out, const char **str_out,
|
|
Packit Service |
20376f |
const git_cvar_map *maps, size_t map_n, int enum_val);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
/**
|
|
Packit Service |
20376f |
* Unlock the backend with the highest priority
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* Unlocking will allow other writers to updat the configuration
|
|
Packit Service |
20376f |
* file. Optionally, any changes performed since the lock will be
|
|
Packit Service |
20376f |
* applied to the configuration.
|
|
Packit Service |
20376f |
*
|
|
Packit Service |
20376f |
* @param cfg the configuration
|
|
Packit Service |
20376f |
* @param commit boolean which indicates whether to commit any changes
|
|
Packit Service |
20376f |
* done since locking
|
|
Packit Service |
20376f |
* @return 0 or an error code
|
|
Packit Service |
20376f |
*/
|
|
Packit Service |
20376f |
GIT_EXTERN(int) git_config_unlock(git_config *cfg, int commit);
|
|
Packit Service |
20376f |
|
|
Packit Service |
20376f |
#endif
|