-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow alternative remotes to be handled by LFS #5066
Conversation
what can I do about the ruby gem issue within the CI job? it does not look like my patch is responsible for this |
It's not. I'm working on finishing the patch which should fix that and I'll re-run the job once it's merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey,
Thanks for the patch, and welcome to Git LFS!
Overall, I think this could be a valuable feature. I think we'll need to make these options since overall they change behaviour in an incompatible way. We'll also need some integration tests here (those would be in the t/
directory). Finally, CI has been fixed, but you'll need to rebase on the main branch to pick up the fixes.
If you need any help on getting this into shape, let me know, and I'll try to help you out. My apologies for taking so long to get to this.
e1037c7
to
cd2a789
Compare
Thanks @bk2204 for your feedback! We (a co-worker @Leo1690 and me) have treated most of your comments. I rebased my branch, squashed the new changes in the old commits and pushed it to my feature branch. However, we are still working on the test environment. We have also shell scripts which reproduce the issue, but to port that to the environment within t/ of git-lfs it takes a bit more effort. I hope we can at least review and discuss the updated patch in the meantime. |
Thanks @bk2204 for your feedback!
|
Additionally, I can try to mount the remotes as docker containers and and use git with ssh to transfer lfs data, but I do not know if you would accept a merge request that adds docker containers to your testing environment. |
I pushed a commit authored by @Leo1690 which implements the tests. I hope it is fine that this MR contains now two different authors in the line of commits. It seems that using a more recent git version did do the trick to support file:// URL based remotes. |
I believe, provided you use different URLs, the test LFS server should expose different repositories. It should be sufficient to expose multiple repositories on the same server instead of different servers, I would think.
The standalone transfer agent should be built-in automatically for file URLs. However, it is known that it requires an absolute URL and it doesn't work for Windows SMB paths. Sparse checkout almost certainly doesn't work and is tracked in #3803. Can you provide an example of a shell script that doesn't work for you (without sparse checkout)? |
Hi @bk2204.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking pretty good. I left some more comments, but I think we should be good to go soon.
t/t-multiple-remotes.sh
Outdated
HOME=$MRHOME | ||
git config --global user.name "Git LFS Tests" | ||
git config --global user.email "git-lfs@example.com" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be setting HOME
here, since the test library does that, and we also don't need to set the Git config values, since those should already be set.
Also, please here and everywhere else, double-quote all variables. On Windows, it's extremely common for a user's home directory (and thus all paths to their repositories) to have spaces, and we need to handle that gracefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. We added a comment to explain our motivation for that.
The global configuration sets a common http endpoint (ip:port) for lfs
We deactivate the git global configuration related with the http protocol
by setting a new .gitconfig file
Additionally, We are not setting a new $HOME. Instead We are removing .gitconfig file and adding the global settings we need. Which it seems ok because at the begging of the next test, the original .gitconfig file is restored by the function begin_test()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I still think there's something I'm missing. What specific setting is causing the problem? In t/t-standalone-file.sh
, we use file:///
URLs just fine, so it can't be lfs.url
.
Can we keep the regular .gitconfig
and simply unset the offending option in each test with git config --global --unset
? I'd rather we do that because it means that if we add an important new setting into the testsuite in the future, the entire testsuite picks it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry. I seems that it was not necessary to chage the global configuration after all. Thank you for pointing that out. The new patch uses the global seetings provided by setup()
t/t-multiple-remotes.sh
Outdated
rm -rf $smain | ||
rm -rf $sfork | ||
rm -rf $cmain | ||
rm -rf $cfork |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of deleting and recreating repos like this, let's use a parameter which is specific to each call and set that differently in each individual test. Then we can avoid different tests affecting each other and let the cleanup code at the end of the test clean up all of the test data for us.
You can see an example in t/t-pull.sh
how we do this with setup_remote_repo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. That looks cleaner. We changed the new function prepare_forks()
to create remote and local repos with different paths
prepare_forks test_case
t/t-multiple-remotes.sh
Outdated
git push -u fr master | ||
#Add a .bin in main repo | ||
touch a.bin | ||
echo 1234 >> a.bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically prefer printf
over echo
in our codebase. It's more consistent and flexible, and in some Windows environments, echo
may insert CRLF, which makes our hashes change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We fixed it.
printf "1234" > a.bin
t/t-multiple-remotes.sh
Outdated
git push mr master | ||
prepare_consumer $cfork | ||
} | ||
begin_test "pull from different remote" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put a space here and in between each set of tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We fixed it.
prepare_consumer "$cfork"
}
begin_test "reset to different remote"
(
git/git.go
Outdated
// We could use git for-each-ref with %(upstream:remotename) if there were a tracking branch, | ||
// but this is not guaranteed to exist either. | ||
func remoteForRef(refname string) string { | ||
tracerx.Printf("Git Working Ref %", refname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this works with just a single percent sign. Also, typically, we write the trace messages downcase, often with a prefix (so, here, “git: working ref: %s”), which would be great to fix here and elsewhere. We typically write mostly fragments or phrases which are punctuated with colons as necessary to avoid ambiguity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We fixed it.
tracerx.Printf("git: working ref: %s", refname)
tracerx.Printf("git: ref remote: cannot determine remote for ref %s since remote %s contains a slash", refname, name)
tracerx.Printf("git: working remote %s", remote)
tracerx.Printf("git: remote treeish: no valid remote refs parsed for %q", treeish)
tracerx.Printf("git: smudge: default remote failed. searching alternate remotes")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few more comments. We probably want to also add some documentation in AsciiDoc in the git-lfs-config
manual page so folks will know how this works.
t/t-multiple-remotes.sh
Outdated
HOME=$MRHOME | ||
git config --global user.name "Git LFS Tests" | ||
git config --global user.email "git-lfs@example.com" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I still think there's something I'm missing. What specific setting is causing the problem? In t/t-standalone-file.sh
, we use file:///
URLs just fine, so it can't be lfs.url
.
Can we keep the regular .gitconfig
and simply unset the offending option in each test with git config --global --unset
? I'd rather we do that because it means that if we add an important new setting into the testsuite in the future, the entire testsuite picks it up.
t/t-multiple-remotes.sh
Outdated
sfork="$HOME"/"$reponame"-"$testcase"-fork-remote.git | ||
cmain="$HOME"/"$reponame"-"$testcase"-main-repo | ||
cfork="$HOME"/"$reponame"-"$testcase"-fork-repo | ||
prepare_remote "$smain" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this to setup_remote_repo "$smain"
and then use "$REMOTEDIR/$smain.git"
? We shouldn't need the git lfs install
since that's already been done once by our setup code, and if we don't delete the .gitconfig
file as I suggested, then we'll have the configuration persisted.
Basically, my request here is to use as much of the same setup code and other helper functions as possible. The style of this test is currently very different from our other tests, and if we can make it as similar as possible, then it will be easier to maintain. You can see what t/t-verify.sh
looks like, which I think is a good example of a typical test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, I adapted the tests to use the function setup_remote_repo()
34c4ee1
to
c85a7c0
Compare
I added a commit which extends the documentation. I hope this is to your liking what I have phrased @bk2204 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Thanks so much for the patch and working with me on this.
I'm going to announce this as an experimental feature in v3.3.0 so that we can see if there are any bugs and shake them out before we commit to supporting it long term.
I've kicked off CI, and I'll check back on Monday to verify it's passed and then merge.
Oh, I just fixed the phrasing of a comment of a function. I didn't knew that the approval would reset completely. So this is just a minor cosmetic last minute change. |
Hmmm, it looks like CI is broken. Could you look into that? |
@bk2204 2 CI jobs failed because the feature can only be supported for git version 2.27 or newer. We added an exclusion rule for the tests. The other job, which uses the git development version of git, is not explainable. We never touched any of the other tests and the new feature is disabled in that setup. In particular, the job which uses the default git version on Ubuntu runs without any issue. My guess is right now that git upstream behavior changed such that the tests are failing now. Can we run the same CI job without our patch to confirm this theory? |
I'm testing a PR in #5082 to see if it makes any difference. |
Before this change, LFS was only respecting remotes which were directly tracked by a branch, or, in a detached state, using a heuristic. Sometimes this failed as reported in issue git-lfs#3835. This patch allows to use the tree-ish to retrieve a corresonding remote. Thanks to Stan Hu, who provided inspiration to fix this bug.
The tree-ish during cherry-pick points to the resulting commit. This commit has never been pushed to any remote and thus it can not resolve to a remote. This patch introduces a fallback mechanism to check all remotes for the existence of the LFS object.
… and lfs.remote.searchall options
@bk2204 I just rebased the branch on your latest fix. I just hope this fixes the CI issues we had before. |
This fixes issue #3835. LFS could not derive the right remote endpoint under certain circumstances. For example, in a detached state, a simple heuristic was used to derive the remote (i.e. branch.*.remote, remote.lfsdefault, any other single remote, origin). This fails if there are multiple remotes in play. This patch derives the corresponding remote from the commit hash / treeish.
Thanks to @stanhu for providing the first version which this PR is based on.