git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: git@vger.kernel.org, Jacob Keller <jacob.keller@gmail.com>
Subject: Re: [PATCH] blame: allow --contents to work with non-HEAD commit
Date: Thu, 23 Mar 2023 21:41:21 -0700	[thread overview]
Message-ID: <xmqqy1nm69se.fsf@gitster.g> (raw)
In-Reply-To: <20230324010457.275902-1-jacob.e.keller@intel.com> (Jacob Keller's message of "Thu, 23 Mar 2023 18:04:57 -0700")

Jacob Keller <jacob.e.keller@intel.com> writes:

> From: Jacob Keller <jacob.keller@gmail.com>
>
> The --contents option can be used with git blame to blame the file as if
> it had the contents from the specified file. This is akin to copying the
> contents into the working tree and then running git blame. This option
> has been supported since 1cfe77333f27 ("git-blame: no rev means start
> from the working tree file.")
>
> The --contents option always blames the file as if it was based on the
> current HEAD commit. If you try to pass a revision while using
> --contents, you get the following error:
>
>   fatal: cannot use --contents with final commit object name
>
> This is because the blame process generates a fake working tree commit
> which always uses the HEAD object.

"the HEAD object as its sole parent."

> Fix fake_working_tree_commit to take the object ID to use for the
> parent instead of always using HEAD. If both a revision and --contents
> is provided, look up the object ID from the provided revision instead of
> using HEAD.

An obvious enhancement.

As the original author of 1cfe7733 (git-blame: no rev means start
from the working tree file., 2007-01-30), I am not sure if the verb
"fix" is fair to describe this change, though.  If you update the
working tree file with contents that is vastly different and totally
unrelated to the version at HEAD, then with this new feature, your
"blame" can start at the working tree file, and then some commit
that is totally unrelated to HEAD, and down the history from it, and
everything should make sense, but if you smudge your working tree
files that way, it would be quite awkward to use the working tree to
advance the history that leads to HEAD.  That is the reason why I
designed the "fake commit based on off-history contents" features to
work only with HEAD.  But unlike actually messing with the contents
of the working tree files, feeding a temporary contents via the
"--contents" option has much less chance of breaking the next
commit, so I do not have any objection to this patch.

Thanks.

  reply	other threads:[~2023-03-24  4:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24  1:04 [PATCH] blame: allow --contents to work with non-HEAD commit Jacob Keller
2023-03-24  4:41 ` Junio C Hamano [this message]
2023-03-24  6:00   ` Jacob Keller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy1nm69se.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jacob.keller@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).