Merge branch 'kh/commit'
* kh/commit: (33 commits) git-commit --allow-empty git-commit: Allow to amend a merge commit that does not change the tree quote_path: fix collapsing of relative paths Make git status usage say git status instead of git commit Fix --signoff in builtin-commit differently. git-commit: clean up die messages Do not generate full commit log message if it is not going to be used Remove git-status from list of scripts as it is builtin Fix off-by-one error when truncating the diff out of the commit message. builtin-commit.c: export GIT_INDEX_FILE for launch_editor as well. Add a few more tests for git-commit builtin-commit: Include the diff in the commit message when verbose. builtin-commit: fix partial-commit support Fix add_files_to_cache() to take pathspec, not user specified list of files Export three helper functions from ls-files builtin-commit: run commit-msg hook with correct message file builtin-commit: do not color status output shown in the message template file_exists(): dangling symlinks do exist Replace "runstatus" with "status" in the tests t7501-commit: Add test for git commit <file> with dirty index. ...
This commit is contained in:
28
ident.c
28
ident.c
@ -182,12 +182,14 @@ static const char *env_hint =
|
||||
"Omit --global to set the identity only in this repository.\n"
|
||||
"\n";
|
||||
|
||||
const char *fmt_ident(const char *name, const char *email,
|
||||
const char *date_str, int error_on_no_name)
|
||||
static const char *fmt_ident_1(const char *name, const char *email,
|
||||
const char *date_str, int flag)
|
||||
{
|
||||
static char buffer[1000];
|
||||
char date[50];
|
||||
int i;
|
||||
int error_on_no_name = !!(flag & 01);
|
||||
int name_addr_only = !!(flag & 02);
|
||||
|
||||
setup_ident();
|
||||
if (!name)
|
||||
@ -214,20 +216,36 @@ const char *fmt_ident(const char *name, const char *email,
|
||||
}
|
||||
|
||||
strcpy(date, git_default_date);
|
||||
if (date_str)
|
||||
if (!name_addr_only && date_str)
|
||||
parse_date(date_str, date, sizeof(date));
|
||||
|
||||
i = copy(buffer, sizeof(buffer), 0, name);
|
||||
i = add_raw(buffer, sizeof(buffer), i, " <");
|
||||
i = copy(buffer, sizeof(buffer), i, email);
|
||||
i = add_raw(buffer, sizeof(buffer), i, "> ");
|
||||
i = copy(buffer, sizeof(buffer), i, date);
|
||||
if (!name_addr_only) {
|
||||
i = add_raw(buffer, sizeof(buffer), i, "> ");
|
||||
i = copy(buffer, sizeof(buffer), i, date);
|
||||
} else {
|
||||
i = add_raw(buffer, sizeof(buffer), i, ">");
|
||||
}
|
||||
if (i >= sizeof(buffer))
|
||||
die("Impossibly long personal identifier");
|
||||
buffer[i] = 0;
|
||||
return buffer;
|
||||
}
|
||||
|
||||
const char *fmt_ident(const char *name, const char *email,
|
||||
const char *date_str, int error_on_no_name)
|
||||
{
|
||||
int flag = (error_on_no_name ? 01 : 0);
|
||||
return fmt_ident_1(name, email, date_str, flag);
|
||||
}
|
||||
|
||||
const char *fmt_name(const char *name, const char *email)
|
||||
{
|
||||
return fmt_ident_1(name, email, NULL, 03);
|
||||
}
|
||||
|
||||
const char *git_author_info(int error_on_no_name)
|
||||
{
|
||||
return fmt_ident(getenv("GIT_AUTHOR_NAME"),
|
||||
|
Reference in New Issue
Block a user