summaryrefslogtreecommitdiff
path: root/src/remote.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-04-22 04:54:00 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-05-13 09:46:36 +0200
commit6fb373a0e8eeff3c94853ff0ac55ca6b561c44a1 (patch)
tree47ebff2ded9e7f2e17a98236a8f8d76d4fbd21ce /src/remote.c
parent22261344de18b3cc60ee6937468d66a6a6a28875 (diff)
downloadlibgit2-6fb373a0e8eeff3c94853ff0ac55ca6b561c44a1.tar.gz
remote: add prune option to fetch
Add a prune setting in the fetch options to allow to fall back to the configuration (the default) or to set it on or off.
Diffstat (limited to 'src/remote.c')
-rw-r--r--src/remote.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/remote.c b/src/remote.c
index 9c044f7ad..a29b8aad9 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -973,6 +973,7 @@ int git_remote_fetch(
const char *reflog_message)
{
int error;
+ bool prune = false;
git_buf reflog_msg_buf = GIT_BUF_INIT;
const git_remote_callbacks *cbs = NULL;
@@ -1008,7 +1009,16 @@ int git_remote_fetch(
if (error < 0)
return error;
- if (remote->prune_refs)
+ if (opts && opts->prune == GIT_FETCH_PRUNE)
+ prune = true;
+ else if (opts && opts->prune == GIT_FETCH_PRUNE_FALLBACK && remote->prune_refs)
+ prune = true;
+ else if (opts && opts->prune == GIT_FETCH_NO_PRUNE)
+ prune = false;
+ else
+ prune = remote->prune_refs;
+
+ if (prune)
error = git_remote_prune(remote, cbs);
return error;