git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Track git blame through two unrelated histories
@ 2023-03-09 11:05 Ilia Pozhilov
  2023-03-09 18:35 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Ilia Pozhilov @ 2023-03-09 11:05 UTC (permalink / raw)
  To: git

Hello!

I have a weird use case. A repository at my company was migrated git
-> non-git vcs -> git again.

During transition to non-git vcs the history was lost, i.e. an initial
commit was created from some known commit from the old git repo.

Migration to new git repo was more transparent and we have the whole history.

So let's say I add two remotes and fetch all the commits, but they
look like this:

A->B-> .... . . . -> Z    history1

1 -> 2 -> ..... -> 0 history2

and file contents in commits Z and 1 are exactly the same, but the
commits themselves are completely unrelated for git.

What I want to achieve is blame working across this boundary.

What can I do? It this possible right now? Is it difficult to
implement? Is there a good enough workaround? I don't think rewriting
commits 1... 0 is an option, but rewriting A ... Z is an option.

What do you think?

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

* Re: Track git blame through two unrelated histories
  2023-03-09 11:05 Track git blame through two unrelated histories Ilia Pozhilov
@ 2023-03-09 18:35 ` Junio C Hamano
  2023-03-13 11:48   ` Ilia Pozhilov
  2023-03-13 11:49   ` Ilia Pozhilov
  0 siblings, 2 replies; 4+ messages in thread
From: Junio C Hamano @ 2023-03-09 18:35 UTC (permalink / raw)
  To: Ilia Pozhilov; +Cc: git

Ilia Pozhilov <ilyapoz@gmail.com> writes:

> So let's say I add two remotes and fetch all the commits, but they
> look like this:
>
> A->B-> .... . . . -> Z    history1
>
> 1 -> 2 -> ..... -> 0 history2
>
> and file contents in commits Z and 1 are exactly the same, but the
> commits themselves are completely unrelated for git.

You mean you want to pretend that history "2 -> ... -> 0" was built
on top of Z?  Here I am assuming that time flows from left to right
in the picture.

If so, you should be able to graft the histories together, perhaps?

Totally untested but something like 

	$ git replace --graft 1 Z

based on my reading of "git help replace" should allow you to
pretend that Z happened immediately before 1.


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

* Re: Track git blame through two unrelated histories
  2023-03-09 18:35 ` Junio C Hamano
@ 2023-03-13 11:48   ` Ilia Pozhilov
  2023-03-13 11:49   ` Ilia Pozhilov
  1 sibling, 0 replies; 4+ messages in thread
From: Ilia Pozhilov @ 2023-03-13 11:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Track git blame through two unrelated histories

Inbox
Ilia Pozhilov
Thu, Mar 9, 1:05 PM (4 days ago)
Hello! I have a weird use case. A repository at my company was
migrated git -> non-git vcs -> git again. During transition to non-git
vcs the history was lost,

Junio C Hamano <gitster@pobox.com>

Thu, Mar 9, 8:35 PM (4 days ago)


to me, git
Ilia Pozhilov <ilyapoz@gmail.com> writes:

> So let's say I add two remotes and fetch all the commits, but they
> look like this:
>
> A->B-> .... . . . -> Z    history1
>
> 1 -> 2 -> ..... -> 0 history2
>
> and file contents in commits Z and 1 are exactly the same, but the
> commits themselves are completely unrelated for git.

You mean you want to pretend that history "2 -> ... -> 0" was built
on top of Z?  Here I am assuming that time flows from left to right
in the picture.

If so, you should be able to graft the histories together, perhaps?

Totally untested but something like

        $ git replace --graft 1 Z

based on my reading of "git help replace" should allow you to
pretend that Z happened immediately before 1.



Junio C Hamano (gitster@pobox.com), git@vger.kernel.org
Plain text






Ilia Pozhilov <ilyapoz@gmail.com>

Fri, Mar 10, 6:32 PM (3 days ago)


to Junio
Thank you very much for this! It worked, I found the corresponding
commits and did exactly as you suggested. Now blames just work!

Now I will need to figure out if this is push'able to github, but even
at this stage it's incredibly useful, I love blames!

On Thu, Mar 9, 2023 at 8:35 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Ilia Pozhilov <ilyapoz@gmail.com> writes:
>
> > So let's say I add two remotes and fetch all the commits, but they
> > look like this:
> >
> > A->B-> .... . . . -> Z    history1
> >
> > 1 -> 2 -> ..... -> 0 history2
> >
> > and file contents in commits Z and 1 are exactly the same, but the
> > commits themselves are completely unrelated for git.
>
> You mean you want to pretend that history "2 -> ... -> 0" was built
> on top of Z?  Here I am assuming that time flows from left to right
> in the picture.
>
> If so, you should be able to graft the histories together, perhaps?
>
> Totally untested but something like
>
>         $ git replace --graft 1 Z
>
> based on my reading of "git help replace" should allow you to
> pretend that Z happened immediately before 1.
>

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

* Re: Track git blame through two unrelated histories
  2023-03-09 18:35 ` Junio C Hamano
  2023-03-13 11:48   ` Ilia Pozhilov
@ 2023-03-13 11:49   ` Ilia Pozhilov
  1 sibling, 0 replies; 4+ messages in thread
From: Ilia Pozhilov @ 2023-03-13 11:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Thank you very much for this! It worked, I found the corresponding
commits and did exactly as you suggested. Now blames just work!

Now I will need to figure out if this is push'able to github, but even
at this stage it's incredibly useful, I love blames!

On Thu, Mar 9, 2023 at 8:35 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Ilia Pozhilov <ilyapoz@gmail.com> writes:
>
> > So let's say I add two remotes and fetch all the commits, but they
> > look like this:
> >
> > A->B-> .... . . . -> Z    history1
> >
> > 1 -> 2 -> ..... -> 0 history2
> >
> > and file contents in commits Z and 1 are exactly the same, but the
> > commits themselves are completely unrelated for git.
>
> You mean you want to pretend that history "2 -> ... -> 0" was built
> on top of Z?  Here I am assuming that time flows from left to right
> in the picture.
>
> If so, you should be able to graft the histories together, perhaps?
>
> Totally untested but something like
>
>         $ git replace --graft 1 Z
>
> based on my reading of "git help replace" should allow you to
> pretend that Z happened immediately before 1.
>

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

end of thread, other threads:[~2023-03-13 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-09 11:05 Track git blame through two unrelated histories Ilia Pozhilov
2023-03-09 18:35 ` Junio C Hamano
2023-03-13 11:48   ` Ilia Pozhilov
2023-03-13 11:49   ` Ilia Pozhilov

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