Override storing ref specs on custom GitgRemote

This commit is contained in:
Jesse van den Kieboom 2015-07-30 20:38:14 +02:00
parent eff2b28f1f
commit 4faa86f163
2 changed files with 42 additions and 20 deletions

View file

@ -134,22 +134,14 @@ class RemoteManager : Object, GitgExt.RemoteLookup
string[] fetch_specs;
string[] push_specs;
try
{
fetch_specs = remote.get_fetch_specs();
} catch { break; }
fetch_specs = remote.fetch_specs;
push_specs = remote.push_specs;
try
{
push_specs = remote.get_push_specs();
} catch { break; }
var defspec = "+refs/heads/*:refs/remotes/" + name + "/*";
Gitg.Remote? tmp = null;
try
{
tmp = (new Ggit.Remote.anonymous(d_window.repository, url, defspec)) as Gitg.Remote;
tmp = (new Ggit.Remote.anonymous(d_window.repository, url)) as Gitg.Remote;
}
catch (Error e)
{
@ -161,15 +153,8 @@ class RemoteManager : Object, GitgExt.RemoteLookup
break;
}
try
{
tmp.set_fetch_specs(fetch_specs);
} catch { break; }
try
{
tmp.set_push_specs(push_specs);
} catch { break; }
tmp.fetch_specs = fetch_specs;
tmp.push_specs = push_specs;
remote = tmp;
break;

View file

@ -40,6 +40,8 @@ public class Remote : Ggit.Remote
{
private RemoteState d_state;
private Error? d_authentication_error;
private string[]? d_fetch_specs;
private string[]? d_push_specs;
public Error authentication_error
{
@ -202,6 +204,41 @@ public class Remote : Ggit.Remote
public new async void fetch(Ggit.Signature signature, string? message) throws Error
{
yield download_intern(signature, message);
public string[]? fetch_specs {
owned get {
if (d_fetch_specs != null) {
return d_fetch_specs;
}
try {
return get_fetch_specs();
} catch (Error e) {
return null;
}
}
set {
d_fetch_specs = value;
}
}
public string[]? push_specs {
owned get {
if (d_push_specs != null) {
return d_push_specs;
}
try {
return get_push_specs();
} catch (Error e) {
return null;
}
}
set {
d_push_specs = value;
}
}
}