Merge branch 'ps/stash-in-c'
"git stash" rewritten in C. * ps/stash-in-c: (28 commits) tests: add a special setup where stash.useBuiltin is off stash: optionally use the scripted version again stash: add back the original, scripted `git stash` stash: convert `stash--helper.c` into `stash.c` stash: replace all `write-tree` child processes with API calls stash: optimize `get_untracked_files()` and `check_changes()` stash: convert save to builtin stash: make push -q quiet stash: convert push to builtin stash: convert create to builtin stash: convert store to builtin stash: convert show to builtin stash: convert list to builtin stash: convert pop to builtin stash: convert branch to builtin stash: convert drop and clear to builtin stash: convert apply to builtin stash: mention options in `show` synopsis stash: add tests for `git stash show` config stash: rename test cases to be more descriptive ...
This commit is contained in:
20
ident.c
20
ident.c
@ -585,6 +585,26 @@ int git_ident_config(const char *var, const char *value, void *data)
|
||||
return set_ident(var, value);
|
||||
}
|
||||
|
||||
static void set_env_if(const char *key, const char *value, int *given, int bit)
|
||||
{
|
||||
if ((*given & bit) || getenv(key))
|
||||
return; /* nothing to do */
|
||||
setenv(key, value, 0);
|
||||
*given |= bit;
|
||||
}
|
||||
|
||||
void prepare_fallback_ident(const char *name, const char *email)
|
||||
{
|
||||
set_env_if("GIT_AUTHOR_NAME", name,
|
||||
&author_ident_explicitly_given, IDENT_NAME_GIVEN);
|
||||
set_env_if("GIT_AUTHOR_EMAIL", email,
|
||||
&author_ident_explicitly_given, IDENT_MAIL_GIVEN);
|
||||
set_env_if("GIT_COMMITTER_NAME", name,
|
||||
&committer_ident_explicitly_given, IDENT_NAME_GIVEN);
|
||||
set_env_if("GIT_COMMITTER_EMAIL", email,
|
||||
&committer_ident_explicitly_given, IDENT_MAIL_GIVEN);
|
||||
}
|
||||
|
||||
static int buf_cmp(const char *a_begin, const char *a_end,
|
||||
const char *b_begin, const char *b_end)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user