From 603d0fdce2ca84d4dc7b26e46430778fe9c4cb72 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Mon, 24 Apr 2023 12:35:08 -0700 Subject: blame: use different author name for fake commit generated by --contents When the --contents option is used with git blame, and the contents of the file have lines which can't be annotated by the history being blamed, the user will see an author of "Not Committed Yet". This is similar to the way blame handles working tree contents when blaming without a revision. This is slightly confusing since this data isn't the working copy and while it is technically "not committed yet", its also coming from an external file. Replace this author name with "External file (--contents)" to better differentiate such lines from actual working copy lines. Suggested-by: Junio C Hamano Suggested-by: Glen Choo Signed-off-by: Jacob Keller Signed-off-by: Junio C Hamano --- blame.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'blame.c') diff --git a/blame.c b/blame.c index 2c427bcdbf..47dd77d045 100644 --- a/blame.c +++ b/blame.c @@ -206,8 +206,12 @@ static struct commit *fake_working_tree_commit(struct repository *r, origin = make_origin(commit, path); - ident = fmt_ident("Not Committed Yet", "not.committed.yet", - WANT_BLANK_IDENT, NULL, 0); + if (contents_from) + ident = fmt_ident("External file (--contents)", "external.file", + WANT_BLANK_IDENT, NULL, 0); + else + ident = fmt_ident("Not Committed Yet", "not.committed.yet", + WANT_BLANK_IDENT, NULL, 0); strbuf_addstr(&msg, "tree 0000000000000000000000000000000000000000\n"); for (parent = commit->parents; parent; parent = parent->next) strbuf_addf(&msg, "parent %s\n", -- cgit v1.2.3