* git fast-import : How to change parent during import?
@ 2011-03-08 1:21 Vitor Antunes
2011-03-08 2:44 ` Jonathan Nieder
0 siblings, 1 reply; 9+ messages in thread
From: Vitor Antunes @ 2011-03-08 1:21 UTC (permalink / raw)
To: git
Hi everyone,
Is it possible to change the parent of a commit during fast import?
I've tried using "reset" command and making a new commit pointing to a
new parent, but in both cases I get a "new tip ... does not contain
..." error message.
Providing a bit of context. I'm trying to improve git-p4 to detect the
parent commit of a new branch. Unfortunately, in Perforce a branch is
nothing more than a copy of a bunch of files into a new location.
Because the origin of the copy can be any past commit and there is no
information about which commit was used it is very difficult to
identify a parent of a new branch. But if we assume that in this copy
process no file is modified then it should be possible to identify the
parent commit simply by comparing their SHA-1.
To achieve this I used the checkpoint command to flush the list of
imported commits to disk and then used standard rev-list and diff-tree
commands to make find the parent commit. I am now at a point where I
am able to correctly identify the parent commit, but when trying to
update the from information I get the above message.
Thanks in advance for your help,
--
Vitor Antunes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git fast-import : How to change parent during import?
2011-03-08 1:21 git fast-import : How to change parent during import? Vitor Antunes
@ 2011-03-08 2:44 ` Jonathan Nieder
2011-03-08 21:19 ` Vitor Antunes
2011-08-28 15:23 ` Vitor Antunes
0 siblings, 2 replies; 9+ messages in thread
From: Jonathan Nieder @ 2011-03-08 2:44 UTC (permalink / raw)
To: Vitor Antunes; +Cc: git
Hi,
Vitor Antunes wrote:
> Is it possible to change the parent of a commit during fast import?
> I've tried using "reset" command and making a new commit pointing to a
> new parent, but in both cases I get a "new tip ... does not contain
> ..." error message.
Have you tried "git fast-import --force"?
> Providing a bit of context. I'm trying to improve git-p4 to detect the
> parent commit of a new branch.
[...]
> To achieve this I used the checkpoint command to flush the list of
> imported commits to disk and then used standard rev-list and diff-tree
> commands to make find the parent commit. I am now at a point where I
> am able to correctly identify the parent commit, but when trying to
> update the from information I get the above message.
The advice in the section "Use Tag Fixup Branches" of git-fast-import(1)
might be useful.
Thanks for an interesting example, and hope that helps.
Jonathan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git fast-import : How to change parent during import?
2011-03-08 2:44 ` Jonathan Nieder
@ 2011-03-08 21:19 ` Vitor Antunes
2011-03-08 22:23 ` Jonathan Nieder
2011-08-28 15:23 ` Vitor Antunes
1 sibling, 1 reply; 9+ messages in thread
From: Vitor Antunes @ 2011-03-08 21:19 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git
Hi Jonathan,
On Tue, Mar 8, 2011 at 2:44 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> Is it possible to change the parent of a commit during fast import?
>> I've tried using "reset" command and making a new commit pointing to a
>> new parent, but in both cases I get a "new tip ... does not contain
>> ..." error message.
>
> Have you tried "git fast-import --force"?
Oh... I completely overlooked the command line argument list in the man page...
Thanks for the tip, worked like a charm!
>> Providing a bit of context. I'm trying to improve git-p4 to detect the
>> parent commit of a new branch.
> [...]
>> To achieve this I used the checkpoint command to flush the list of
>> imported commits to disk and then used standard rev-list and diff-tree
>> commands to make find the parent commit. I am now at a point where I
>> am able to correctly identify the parent commit, but when trying to
>> update the from information I get the above message.
>
> The advice in the section "Use Tag Fixup Branches" of git-fast-import(1)
> might be useful.
I'm still trying to understand it. Do you know of any practical
example that I can look into?
Thanks for your help,
--
Vitor Antunes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git fast-import : How to change parent during import?
2011-03-08 21:19 ` Vitor Antunes
@ 2011-03-08 22:23 ` Jonathan Nieder
2011-03-09 14:21 ` Vitor Antunes
2011-03-30 17:25 ` Vitor Antunes
0 siblings, 2 replies; 9+ messages in thread
From: Jonathan Nieder @ 2011-03-08 22:23 UTC (permalink / raw)
To: Vitor Antunes; +Cc: git
Hi,
Vitor Antunes wrote:
> On Tue, Mar 8, 2011 at 2:44 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> The advice in the section "Use Tag Fixup Branches" of git-fast-import(1)
>> might be useful.
>
> I'm still trying to understand it. Do you know of any practical
> example that I can look into?
It's likely I misunderstood what you're trying to do. If you have
some work in progress, I'd be glad to look at it.
Anyway, concerning tag fixup branches: git://repo.or.cz/cvs2svn.git
has an example in cvs2svn_lib/git_output_option.py::process_tag_commit.
The idea is to make commits that don't belong to any branch on a
separate TAG_FIXUP ref, using the "reset" command where appropriate;
then the resulting commits can be inspected, merged, reset to, or used
in some other way later.
The "tag fixup" idea is that in VCSes like CVS, tags do not
necessarily match the content on any branch. So the history looks
somewhat like so (time flowing left to right):
TAG
/
o --- o --- o --- o --- o --- o ...
instead of the perhaps more sensible
o --- o --- o --- TAG --- o --- o ...
The side branch leading up to a tag does not correspond to any branch
name; after it is in the correct state one can use the "tag" command
to get it remembered in permanent history. The same technique might
be useful whenever you are creating history that is not meant to stay
permanently on any branch.
Jonathan
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git fast-import : How to change parent during import?
2011-03-08 22:23 ` Jonathan Nieder
@ 2011-03-09 14:21 ` Vitor Antunes
2011-03-30 17:25 ` Vitor Antunes
1 sibling, 0 replies; 9+ messages in thread
From: Vitor Antunes @ 2011-03-09 14:21 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git
Hi Jonathan,
On Tue, Mar 8, 2011 at 10:23 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> It's likely I misunderstood what you're trying to do. If you have
> some work in progress, I'd be glad to look at it.
>
> Anyway, concerning tag fixup branches: git://repo.or.cz/cvs2svn.git
> has an example in cvs2svn_lib/git_output_option.py::process_tag_commit.
> The idea is to make commits that don't belong to any branch on a
> separate TAG_FIXUP ref, using the "reset" command where appropriate;
> then the resulting commits can be inspected, merged, reset to, or used
> in some other way later.
>
> The "tag fixup" idea is that in VCSes like CVS, tags do not
> necessarily match the content on any branch. So the history looks
> somewhat like so (time flowing left to right):
>
> TAG
> /
> o --- o --- o --- o --- o --- o ...
>
> instead of the perhaps more sensible
>
> o --- o --- o --- TAG --- o --- o ...
>
> The side branch leading up to a tag does not correspond to any branch
> name; after it is in the correct state one can use the "tag" command
> to get it remembered in permanent history. The same technique might
> be useful whenever you are creating history that is not meant to stay
> permanently on any branch.
I think I understood the idea behind TAG_FIXUP and I think it can be a
better solution for my problem. I could make the commit into
TAG_FIXUP, search for a better parent in the source branch and then
reset it to that parent or rebase it over any other commit. I'll try
to do this in the following days, so I will most likely come back with
more doubts :)
Thanks,
--
Vitor Antunes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git fast-import : How to change parent during import?
2011-03-08 22:23 ` Jonathan Nieder
2011-03-09 14:21 ` Vitor Antunes
@ 2011-03-30 17:25 ` Vitor Antunes
1 sibling, 0 replies; 9+ messages in thread
From: Vitor Antunes @ 2011-03-30 17:25 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git
Hi Jonathan,
On Tue, 8 Mar 2011 16:23:28 -0600
Jonathan Nieder <jrnieder@gmail.com> wrote:
> The "tag fixup" idea is that in VCSes like CVS, tags do not
> necessarily match the content on any branch. So the history looks
> somewhat like so (time flowing left to right):
>
> TAG
> /
> o --- o --- o --- o --- o --- o ...
>
> instead of the perhaps more sensible
>
> o --- o --- o --- TAG --- o --- o ...
>
> The side branch leading up to a tag does not correspond to any branch
> name; after it is in the correct state one can use the "tag" command
> to get it remembered in permanent history. The same technique might
> be useful whenever you are creating history that is not meant to stay
> permanently on any branch.
I don't think the TAG_FIXUP trick is what I need in this case. Assume the
following:
A --- B --- C --- D ... (branch1)
\
E --- F --- G ... (branch2)
Now assume that we are at commit D when we detect a commit to branch2. At this
point there is no way of knowing the origin commit in branch1. What is currently
being done is to use commit D as the parent of branch2, which is incorrect. But
if we assume that all branches are created through a "cp" like command, then we
know that B=E. So my idea is to go over A, B, C, etc and commit E "from:" each
one and see which results in a zero differences diff-tree.
Unfortunately, the current implementation I am using doesn't feel simple enough.
Because I'm using commands external to fast-import, I need to be constantly
making use of "checkpoint". And this seems to not be good enough, because I need
to sleep during 0.1s (didn't try other values) after each "checkpoint" before
being able to use diff-tree and similar commands. I am also forced to use the
"--force" command due to all the orphan commits I leave behind.
I would really prefer to have a simpler solution. Do you, or anyone else, see
another option?
Thanks in advance,
--
Vitor Antunes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git fast-import : How to change parent during import?
2011-03-08 2:44 ` Jonathan Nieder
2011-03-08 21:19 ` Vitor Antunes
@ 2011-08-28 15:23 ` Vitor Antunes
2011-08-28 23:39 ` Jonathan Nieder
1 sibling, 1 reply; 9+ messages in thread
From: Vitor Antunes @ 2011-08-28 15:23 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git
On Mon, 7 Mar 2011 20:44:27 -0600
Jonathan Nieder <jrnieder@gmail.com> wrote:
> > Is it possible to change the parent of a commit during fast import?
> > I've tried using "reset" command and making a new commit pointing to a
> > new parent, but in both cases I get a "new tip ... does not contain
> > ..." error message.
>
> Have you tried "git fast-import --force"?
I know this is an old topic, but I'm looking into this again now. What I'm
now trying to do is to stop using "--force".
Is there a way to manually force fast-import to drop an old commit that the
frontend script decided it was no longer necessary?
Thanks,
--
Vitor Antunes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git fast-import : How to change parent during import?
2011-08-28 15:23 ` Vitor Antunes
@ 2011-08-28 23:39 ` Jonathan Nieder
2011-08-29 1:13 ` Sverre Rabbelier
0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Nieder @ 2011-08-28 23:39 UTC (permalink / raw)
To: Vitor Antunes; +Cc: git, David Barr, Sverre Rabbelier
Vitor Antunes wrote:
> Is there a way to manually force fast-import to drop an old commit that the
> frontend script decided it was no longer necessary?
Sure --- patch fast-import (I'd be happy to review such a patch). :)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: git fast-import : How to change parent during import?
2011-08-28 23:39 ` Jonathan Nieder
@ 2011-08-29 1:13 ` Sverre Rabbelier
0 siblings, 0 replies; 9+ messages in thread
From: Sverre Rabbelier @ 2011-08-29 1:13 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Vitor Antunes, git, David Barr
Heya,
On Mon, Aug 29, 2011 at 01:39, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Vitor Antunes wrote:
>> Is there a way to manually force fast-import to drop an old commit that the
>> frontend script decided it was no longer necessary?
>
> Sure --- patch fast-import (I'd be happy to review such a patch). :)
That's actually a feature that we need for remote-helpers as well (to
be able to drop refs). Would be nice to have a 'drop ref' command in
fast export :).
--
Cheers,
Sverre Rabbelier
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-08-29 1:15 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-08 1:21 git fast-import : How to change parent during import? Vitor Antunes
2011-03-08 2:44 ` Jonathan Nieder
2011-03-08 21:19 ` Vitor Antunes
2011-03-08 22:23 ` Jonathan Nieder
2011-03-09 14:21 ` Vitor Antunes
2011-03-30 17:25 ` Vitor Antunes
2011-08-28 15:23 ` Vitor Antunes
2011-08-28 23:39 ` Jonathan Nieder
2011-08-29 1:13 ` Sverre Rabbelier
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 NNTP newsgroup(s).