Skip to content
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

usage of fetch #12

Open
bertsky opened this issue Apr 18, 2023 · 7 comments
Open

usage of fetch #12

bertsky opened this issue Apr 18, 2023 · 7 comments

Comments

@bertsky
Copy link

bertsky commented Apr 18, 2023

I am having difficulty understanding how to use fetch. If I do not pass a checkout_dir (which I would expect to be generated from the last path component of git_repo as in git clone URL), then it says Can't checkout into a bare repo. If I do pass some checkout_dir, then I run into this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/site-packages/git_lfs/__init__.py", line 165, in fetch
    with TempDir(dir=checkout_dir) as d:
  File "/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/usr/lib/python3.8/site-packages/git_lfs/utils.py", line 33, in TempDir
    d = mkdtemp(**kw)
  File "/usr/lib/python3.8/tempfile.py", line 498, in mkdtemp
    _os.mkdir(file, 0o700)
FileNotFoundError: [Errno 2] No such file or directory: 'test/tmp9jicu15s'

So this obviously expects an existing directory. Why?

@Changaco
Copy link
Member

Requiring an existing directory was most likely unintentional. Again, I encourage you to make a pull request to fix the problem.

@bertsky
Copy link
Author

bertsky commented Apr 20, 2023

Ok, I will, but allow me to understand how usage was meant to work.

checkout_git_dir = checkout_dir+'/.git'
if not os.path.isdir(checkout_git_dir):
with TempDir(dir=checkout_dir) as d:
check_output(['git', 'clone', '-ns', git_repo, d], stderr=STDOUT)
os.rename(d+'/.git', checkout_git_dir)
with in_dir(checkout_dir):
check_output(['git', 'reset', 'HEAD'])

Why the os.rename? Why even a temporary directory in the first place?

@Changaco
Copy link
Member

Creating a temporary file or directory, then renaming it, is a way of making changes atomically.

I don't remember if the code was written this way merely as a precaution or if I actually needed this “safety” at the time.

@bertsky
Copy link
Author

bertsky commented Apr 20, 2023

Understood. It would help if you could divulge one concrete example of a call (API or CLI) that used to succeed. I'm sure I can take it from there and reconstruct the intended implementation.

@Changaco
Copy link
Member

The call was python -m git_lfs -vv ~/git/$OPENSHIFT_APP_NAME.git $OPENSHIFT_REPO_DIR.

@bertsky
Copy link
Author

bertsky commented Apr 24, 2023

The call was python -m git_lfs -vv ~/git/$OPENSHIFT_APP_NAME.git $OPENSHIFT_REPO_DIR.

Oh, then my impression that this was also meant for remote repos (first cloning https or git URLs) was wrong to begin with?

@Changaco
Copy link
Member

The code was never meant to be invoked with URLs of remote repositories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants