-
Notifications
You must be signed in to change notification settings - Fork 534
Missing fetch options: --force
, --no-tags
and --prune
#490
Comments
Great news! About the missing features:
Yep is the default behavior will be great having it as git does.
Great to have it in a PR
Yep we don't have gc, but at least can be implemented for the references. |
@mcuadros for It affects whether |
|
@lupine: I'm very interested in having a non-force mode as well. I'm curious what your plan is regarding locking, since presumably you'll need to lock the reference between when you check it and when you set it. Will this be a new ability of the Let me know if you need any help on the design or implementation. (I have no opinions re: default behavior. Ideally it would match the command line in terms of not failing early, but I don't feel strongly about it.) |
Hi @lupine and @mcuadros -- has there been any progress on this issue? I'm working on a project that will need it relatively soon, so I can potentially look into it if no one else has started yet (though I'm not 100% sure where to start). If anyone has thoughts or a status update, that would be great. Thanks! |
I need the ability to turn off forced fetches in a consistent way. That is, without the "+" prefix to a ref, I want go-git to be able to check for fast-forward and update a ref all under the same lock, so that no other operation can come in between the check and the update. |
Ok, sorry about the delay answering properly, but I have all the answers now: implementation of
|
Non-force fetch is required in order to implement a git remote helper using go-git, because in that case a user's push actually turns into a fetch from the local filesystem repo, and it's needed to distinguish a fast-forward push from a force push. (At least, that's the best way I've come up with so far to implement it.) We will definitely need the option to have a fetch that respects the + in the refspec. We're currently planning to implement it ourselves (probably @taruti will do it), and we hope you'll consider merging it. |
As I said, you have non-force and force fetch based on refspecs, this doesn't work for you? |
Oh, I was confused by what you said I guess, because you said "I rather no implement it", so I thought you were not going to implement it. If you mean today's code already supports force and non-force, I don't believe that's true. There's certainly nothing that takes a lock between checking the current HEAD and updating it, so non-force cannot work accurately. That's what we're planning to implement. |
The force is based on "+" flag in the refspec, is how it works. Lines 442 to 446 in f9a1c7a
Lines 554 to 566 in f9a1c7a
Also what I tried to explain before is that a lock is not required from our point of view because go-git is not designed to having concurrent call to the same You can how its working at this test: Lines 452 to 478 in f9a1c7a
|
Oh I see. In this case, it's not the same |
Then you need a lock to accessing the repositories. As we do at: If you are planning to create a server, as part of this server you will need to provide a lock for the write operations. Depending of the design of this feature, if for example is a the Maybe can be as easy of add a Mutex to the |
Closing this issue, feel free to open another issue with the feature request of the lock. |
Thanks, yes, we already have distributed lock in our storage layer. We'll open a PR for locking in the near future. We already have one for Billy that we hope to get merged: src-d/go-billy#44 |
Encouraged by the success of go-git in our elasticsearch indexer (https://gitlab.com/gitlab-org/gitlab-elasticsearch-indexer), I was hoping to use it in our repository mirroring code, as I'm adding support for SSH public key auth (https://gitlab.com/gitlab-org/gitlab-shell/issues/95 https://gitlab.com/gitlab-org/gitlab-shell/merge_requests/147). This is a simple wrapper around
git fetch
, but I don't seem able to replicate several aspects of existing behaviour with go-git:git fetch --force
seems to be the default behaviour? I can't see any mention of the check--force
disables inupdateReferenceStorerIfNeeded
or its callers, at any rate.git fetch --tags
isFetchOptions.Tags = git.AllTags
, but what aboutgit fetch --no-tags
? There doesn't seem to be aNoTags
constantgit fetch --prune
seems unsupported. In fact, all aspects ofgit gc
seem unsupported - although this could be worked around.I'd be happy to submit PRs to implement the first two options if they'd be considered for merge.
The text was updated successfully, but these errors were encountered: