summaryrefslogtreecommitdiff
path: root/examples/network/fetch.c
diff options
context:
space:
mode:
authorMichael Schubert <schu@schu.io>2012-05-01 22:25:43 +0200
committerMichael Schubert <schu@schu.io>2012-05-02 01:06:49 +0200
commit42ea35c06157a5c75cfd20e8fe3a813140c26485 (patch)
tree9066237c97077be789fd1498ef9f400e743b9aa5 /examples/network/fetch.c
parent52877c897504ed610bc957b88b6ba9e442077c07 (diff)
downloadlibgit2-42ea35c06157a5c75cfd20e8fe3a813140c26485.tar.gz
remote: don't free transport on disconnect
Currently, git_remote_disconnect not only closes the connection but also frees the underlying transport object, making it impossible to write code like // fetch stuff git_remote_download() // close connection git_remote_disconnect() // call user provided callback for each ref git_remote_update_tips(remote, callback) because remote->refs points to references owned by the transport object. This means, we have an idling connection while running the callback for each reference. Instead, allow immediate disconnect and free the transport later in git_remote_free().
Diffstat (limited to 'examples/network/fetch.c')
-rw-r--r--examples/network/fetch.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/examples/network/fetch.c b/examples/network/fetch.c
index d4a39746f..23046bd09 100644
--- a/examples/network/fetch.c
+++ b/examples/network/fetch.c
@@ -93,6 +93,9 @@ int fetch(git_repository *repo, int argc, char **argv)
} while (!data.finished);
printf("\rReceived %d/%d objects in %d bytes\n", stats.processed, stats.total, bytes);
+ // Disconnect the underlying connection to prevent from idling.
+ git_remote_disconnect(remote);
+
// Update the references in the remote's namespace to point to the
// right commits. This may be needed even if there was no packfile
// to download, which can happen e.g. when the branches have been