git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?
@ 2012-09-15 12:02 David Chanters
  2012-09-15 17:21 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: David Chanters @ 2012-09-15 12:02 UTC (permalink / raw)
  To: git

Hi,

Earlier this month I asked how best to handle two branches without a
common ancestor to sync changes from one branch to another.  Initially
I did this via the grafts mechanism, but this wasn't a "shared"
solution, in that the graft was local to my checkout of the repository
and no one else's.

I read on StackOverflow that git-replace can be used instead.  Having read this:

http://stackoverflow.com/questions/3810348/setting-git-parent-pointer-to-a-different-parent

I followed the instructions to use git-replace.  Have successfully
done that, I was then able to merge the two branches which didn't have
a common ancestor and have the correct commits on the branch I was
hoping for.  AFAIAC, this worked fine.

But now I have some questions:

1.  I thought the replace data in .git/refs/replace was published when
I did "git push" so that others could use this information as a
base-point, yet it seems not to be the case.  How do I publish this?
2.  If I do publish it, are there any caveats with that?  i.e.,
because the replace data will likely point to a repo which in my
working checkout I added with "git-remote", is that going to be a
problem?  I assume I can instruct people who care, to "git remote add
foo ...." and then treat master and foo/master as intended?  i.e.,
foo/master will see commits on it over time which "master" won't have,
so "git checkout master && git merge foo/master" can always happen?
3.  If it is possible to publish this replace data, is there anything
which needs to happen in .git/config either on the bare repo or local
checkouts?

What I'm aiming for now, in publishing this merge, is that if I can
publish the replace data, that people besides me, can clone the repo,
and the remote repo in place, and merge the branches as outlined in
question 2.   What I also am unsure of is whether or not I have to
keep updating the replace refs each time I merge the branch?

TIA!

David

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

* Re: Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?
  2012-09-15 12:02 Using git-replace in place of grafts -- and publishing .git/refs/replace between repos? David Chanters
@ 2012-09-15 17:21 ` Junio C Hamano
  2012-09-15 21:49   ` David Chanters
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2012-09-15 17:21 UTC (permalink / raw)
  To: David Chanters; +Cc: git

David Chanters <david.chanters@googlemail.com> writes:

> 1.  I thought the replace data in .git/refs/replace was published when
> I did "git push" so that others could use this information as a
> base-point, yet it seems not to be the case.  How do I publish this?

If you don't tell it what to push, the command will just update the
branches.  You can tell "git push" what you want to push explicitly,
e.g. 

    $ git replace -l ;# to learn what replacement I want to send
    77d5ba8477eb90509e79dbcf63814a3dfdefb906
    $ git push origin refs/replace/77d5ba8477eb90509e79dbcf63814a3dfdefb906

> 2.  If I do publish it, are there any caveats with that?  i.e.,
> because the replace data will likely point to a repo which in my
> working checkout I added with "git-remote", is that going to be a
> problem?

That is between you and other project participants.  They may not
want to see replacement in their project in the first place.

Assuming that they do, pushing the replacement ref makes the
replacing object available in the pushed-into repository, so
they will *not* rely on your repository.

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

* Re: Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?
  2012-09-15 17:21 ` Junio C Hamano
@ 2012-09-15 21:49   ` David Chanters
  2012-09-16  2:42     ` Christian Couder
  2012-09-16  6:04     ` Junio C Hamano
  0 siblings, 2 replies; 5+ messages in thread
From: David Chanters @ 2012-09-15 21:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On 15 September 2012 18:21, Junio C Hamano <gitster@pobox.com> wrote:
> David Chanters <david.chanters@googlemail.com> writes:
>> 2.  If I do publish it, are there any caveats with that?  i.e.,
>> because the replace data will likely point to a repo which in my
>> working checkout I added with "git-remote", is that going to be a
>> problem?
>
> That is between you and other project participants.  They may not
> want to see replacement in their project in the first place.
>
> Assuming that they do, pushing the replacement ref makes the
> replacing object available in the pushed-into repository, so
> they will *not* rely on your repository.

This makes sense.  But it is more the mechanics of what happens with
needing to update the "fetch" line for the remote in .git/config I am
more puzzled by.

For example, if I have two repos -- repoA and repoB, where repoA
contains the replace refs for repoB -- if I clone both repos with the
intent of wanting to look at the two histories, what must I do in
repoA to fetch the replace refs in the first place?

I've tried:

[remote "origin"]
        fetch =
+refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*

But this results in:

% git pull
fatal: Invalid refspec
'+refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*'

So I'm clearly not understanding something here, and even then, I'm
assuming that I can manipulate the correct "fetch" line via "git
config", it's just that I'm not sure which one to use.

I keep meaning to read up on refspec stuff because it looks so useful.

Kindly,

David

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

* Re: Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?
  2012-09-15 21:49   ` David Chanters
@ 2012-09-16  2:42     ` Christian Couder
  2012-09-16  6:04     ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Christian Couder @ 2012-09-16  2:42 UTC (permalink / raw)
  To: David Chanters; +Cc: Junio C Hamano, git

Hi,

On Sat, Sep 15, 2012 at 11:49 PM, David Chanters
<david.chanters@googlemail.com> wrote:
> Hi,
>
> On 15 September 2012 18:21, Junio C Hamano <gitster@pobox.com> wrote:
>
>> Assuming that they do, pushing the replacement ref makes the
>> replacing object available in the pushed-into repository, so
>> they will *not* rely on your repository.
>
> This makes sense.  But it is more the mechanics of what happens with
> needing to update the "fetch" line for the remote in .git/config I am
> more puzzled by.
>
> For example, if I have two repos -- repoA and repoB, where repoA
> contains the replace refs for repoB -- if I clone both repos with the
> intent of wanting to look at the two histories, what must I do in
> repoA to fetch the replace refs in the first place?
>
> I've tried:
>
> [remote "origin"]
>         fetch =
> +refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*

Could you try the following:

[remote "origin"]
        fetch = +refs/replace/*:refs/replace/*
        fetch = +refs/heads/*:refs/remotes/origin/*


> But this results in:
>
> % git pull
> fatal: Invalid refspec
> '+refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*'

Best,
Christian.

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

* Re: Using git-replace in place of grafts -- and publishing .git/refs/replace between repos?
  2012-09-15 21:49   ` David Chanters
  2012-09-16  2:42     ` Christian Couder
@ 2012-09-16  6:04     ` Junio C Hamano
  1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2012-09-16  6:04 UTC (permalink / raw)
  To: David Chanters; +Cc: git

David Chanters <david.chanters@googlemail.com> writes:

> I've tried:
>
> [remote "origin"]
>         fetch =
> +refs/replace/*:+refs/heads/*:refs/remotes/origin/*:refs/replace/*

Read the documentation and learn about <refspec> instead of blindly
guessing.

	[remote "origin"]
		fetch = +refs/heads/*:refs/remotes/origin/*
	        fetch = +refs/replace/*:refs/replace/*

would be syntactically more correct.  That would blindly fetch each
and every replace refs from the other side and apply the replacement.

It is questionable if it is a sensible thing to do, though.

"Git cabal" has been discussing a plan to make this easier but it is
not quite ready to outline here yet.  Perhaps after I return from my
vacation post 1.8.0 release ;-)

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

end of thread, other threads:[~2012-09-16  6:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-15 12:02 Using git-replace in place of grafts -- and publishing .git/refs/replace between repos? David Chanters
2012-09-15 17:21 ` Junio C Hamano
2012-09-15 21:49   ` David Chanters
2012-09-16  2:42     ` Christian Couder
2012-09-16  6:04     ` Junio C Hamano

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