From: Junio C Hamano <gitster@pobox.com>
To: Tao Klerks <tao@klerks.biz>
Cc: git <git@vger.kernel.org>, Derrick Stolee <stolee@gmail.com>
Subject: Re: Can git log be made to "follow" in the same way as git blame? Why / in what way is "--follow" broken or limited?
Date: Mon, 26 Aug 2024 15:52:30 -0700 [thread overview]
Message-ID: <xmqqjzg2gamp.fsf@gitster.g> (raw)
In-Reply-To: <xmqqa5gzhxxg.fsf@gitster.g> (Junio C. Hamano's message of "Mon, 26 Aug 2024 12:43:55 -0700")
Junio C Hamano <gitster@pobox.com> writes:
> Unlike the above checkbox hack, "git blame" uses a real data
> structure to keep track of what came from where. Instead of a
> global "this single path is what interests us now", it knows "in
> this commit, this is the path we are looking at", and when it looks
> at the parents of that commit, it checks where that path the child
> was interested in came from each different parent, and records a
> similar "in this commit (which is parent of the commit we were
> looking at), this path is what we are interested in".
FWIW, the above is greatly simplified. For "git blame" to correctly
handle a case like "This commit created file F by taking pieces from
files A, B, C, D, and E", and annotating the lines in file F, we
need to keep track of the set of "lines n..m of path A", "lines l..k
of path B", etc., at commit X as the targets of interest, and as we
dig down the history, figure out where in the parent commits of X
each of these range of lines come from. So what "blame" uses is
much richer than just a single path per commit being traversed (once
the traversal passes through from a commit to all of its parents,
this list of "line ranges per path" can be released, so that is not
a huge memory burden even for a deep history).
Now "git log --follow" does not have to keep track of range of
lines, but if you start following from file F that was created by
concatenating pieces of multiple existing files A, B, ..., and E,
you either want to pick one of these 5 and follow it, or you replace
F with all five of these files and follow them from that point. In
any case, you need a richer data structure than the current (ab)use
of the .pathspec member during the traversal.
prev parent reply other threads:[~2024-08-26 22:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 19:00 Can git log be made to "follow" in the same way as git blame? Why / in what way is "--follow" broken or limited? Tao Klerks
2024-08-26 19:43 ` Junio C Hamano
2024-08-26 22:52 ` Junio C Hamano [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqjzg2gamp.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=stolee@gmail.com \
--cc=tao@klerks.biz \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox