git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug report: git branch behaves as if --no-replace-objects is passed
@ 2021-03-30  6:05 Elijah Newren
  2021-03-30  7:02 ` Jeff King
  0 siblings, 1 reply; 10+ messages in thread
From: Elijah Newren @ 2021-03-30  6:05 UTC (permalink / raw)
  To: Git Mailing List

Hi,

Forwarding a report from
https://github.com/newren/git-filter-repo/issues/229, with a few more
details...

log, diff, etc. seem to all support replace objects nicely:

    git init -b main whatever
    cd whatever/
    >empty
    git add empty
    git commit -m initial
    git replace -f deadbeefdeadbeefdeadbeefdeadbeefdeadbeef $(git
rev-parse main)

    echo stuff >>empty

Now, If I try to use this replace object:

    $ git diff --stat deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
     empty | 1 +
     1 file changed, 1 insertion(+)
    $ git log --oneline deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
    deadbee (replaced) initial

it all works well.  BUT, if I try to use it with branch it doesn't work:

    $ git branch --contains deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
    $

and possibly worse, if I create a new branch based on it and use it:

    $ git branch foobar deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
    $ git checkout foobar
    $ echo stuff >empty
    $ git add empty
    $ git commit -m more

then it's clear that branch created foobar pointing to the replaced
object rather than the replacement object -- despite the fact that the
replaced object doesn't even exist within this repo:

    $ git cat-file -p HEAD
    tree 18108bae26dc91af2055bc66cc9fea278012dbd3
    parent deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
    author Elijah Newren <newren@gmail.com> 1617083739 -0700
    committer Elijah Newren <newren@gmail.com> 1617083739 -0700

    more

I poked around in the code a little but it is not at all clear to me
why some parts of the code (log, diff) translate replace refs
correctly, while others (branch) don't.  It is clear from the output
that log is aware that the refs are replaced, which makes me wonder if
every caller needs to be aware of replace refs for them to work
correctly everywhere, because I couldn't find a missing environment
setup for "branch".

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-03-31  0:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-30  6:05 Bug report: git branch behaves as if --no-replace-objects is passed Elijah Newren
2021-03-30  7:02 ` Jeff King
2021-03-30 18:58   ` Junio C Hamano
2021-03-30 21:19     ` Elijah Newren
2021-03-30 21:30       ` Elijah Newren
2021-03-30 21:59         ` Junio C Hamano
2021-03-30 21:53       ` Junio C Hamano
2021-03-30 22:43         ` Elijah Newren
2021-03-30 23:04           ` Junio C Hamano
2021-03-31  0:32             ` Elijah Newren

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).