← Back to team overview

dulwich-users team mailing list archive

Re: Deleting a remote branch via Dulwich?

 

On Thu, Jul 05, 2012 at 12:51:09AM -0700, Andi McClure wrote:
> Thanks! What I'm personally trying to do is interface with Github. I don't
> know what extensions they do or don't support.
They support delete-refs.

> So, I'm not sure I understand what to do here. ZERO_SHA1 is just 160 bits
> of 0x00, right? I tried this and it didn't seem to work. What I'm doing is
> again, the "changed" function which is my second argument to send_pack,
> when this function is called it gets in a mapping of all git repository
> heads to their corresponding git shas, I change the value associated with
> (for example) "refs/heads/bullet279" in this dictionary to ("00"*20) and
> return the modified dictionary. As far as I can tell (?) returning this
> dictionary rewrites what all the ref names point to during the pack-- the
> only point of the generate_pack_contents on the other hand seems (?) to be
> to return object files given a sha (the shas returned by
> determine_wants??). However when I set one of these to the 20-bytes-of-zero
> hash and return it, it appears to have no effect on the Github side. I
> don't get an error or anything, just... nothing happens. Any idea what I
> might be doing wrong, or how to debug this further? I'm using Dulwich 0.8.2.
What do you mean exactly when you say it doesn't work? The ref doesn't
go away, or it simply gets its value set to the ZERO_SHA1?

> By the way, there might be room for improvement in the documentation here.
> If you look at the GitClient documentation:
> http://www.samba.org/~jelmer/dulwich/apidocs/dulwich.client.GitClient.html#send_pack
> send_pack does not have its "determine_wants" argument documented at all.
> The fetch() method documents an argument by that name with "Optional
> function to determine what refs to fetch", but this doesn't seem to answer
> questions like, what are the arguments to this optional function and what
> does it return? The description of the generate_pack_contents argument of
> send_pack is similarly vague in terms of what this function takes as an
> argument and what it returns (I'm afraid I'm misunderstanding what it does
> completely...).
determine_wants() receives a dictionary of refs (refs as keys, the
SHA1 they references as value) and should return a list of heads that
you would like to see fetched.

Patches to improve the documentation are very much welcome.

Cheers,

Jelmer

> 
> On Wed, Jul 4, 2012 at 3:34 PM, Jelmer Vernooij <jelmer@xxxxxxxxx> wrote:
> 
> > On Tue, Jul 03, 2012 at 11:04:30PM -0700, Andi McClure wrote:
> > > Hello, I am trying to patch the "hg-git" project, which is based on
> > > Dulwich. I do not understand very much about what I am doing and am
> > mostly
> > > working by studying the surrounding code. What I am trying to do is add a
> > > feature where I delete a remote branch by name.
> >
> > > As far as I can tell, the way I'm meant to communicate with the server is
> > > to call
> > > client.send_pack(path, changed, genpack)
> > > where client is a GitClient object, path is the appropriate git path,
> > > "changed" is a method taking a dictionary of branch-name
> > > ->branch-points-to-rev and returning a new dictionary describing same,
> > and
> > > "genpack" is dulwich.object_store.BaseObjectStore.generate_pack_contents.
> > > The existing hg-git code uses this interface to upload objects and assign
> > > refs.
> >
> > > How can I use the GitClient object to *delete* a ref, though?
> > You should be able to do this by setting a particular ref to the
> > ZERO_SHA1.
> >
> > Note that the server has to support the 'delete-refs' capability for
> > this to work.
> >
> > Cheers,
> >
> > Jelmer
> >


Follow ups

References