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

dulwich.porcelain.add() corrupts branch #1178

Open
tillias opened this issue May 16, 2023 · 3 comments
Open

dulwich.porcelain.add() corrupts branch #1178

tillias opened this issue May 16, 2023 · 3 comments
Labels

Comments

@tillias
Copy link

tillias commented May 16, 2023

Hello,

I have a repo inside c:/tmp/release-package-v0.0.1

When I run

local_path = 'c:/tmp/release-package-v0.0.1'
porcelain.add(local_path, local_path)
rst = status(local_path)
print(rst)

It shows some strange status:

GitStatus(staged={'add': [b'./'], 'delete': [], 'modify': []}, unstaged=[], untracked=['LICENSE', 'README.md', 'synchronizer.py'])

So my untracked files are not added to repo but some b'./' instead.

If I commit those changes, then git repository becomes corrupted and I can't run 'status' or standalone git commands inside it anymore.

It says 'Fatal: empty filename in tree'

Please help me how to add new files into repository, any working workaround will be much appreciated! It seems problem is with relpath in porcelain.py but I'm not sure how to fix it :(

        for p in paths:
            path = Path(p)
            relpath = str(path.resolve().relative_to(repo_path))
            # FIXME: Support patterns

Thank you!

@tillias
Copy link
Author

tillias commented May 16, 2023

Or here is source code: https://github.com/tillias/aws-code-commit-sync/blob/7639ccce5e15140bb086f06a2cbdb3f67d816b02/src/git_helper.py#L31
Please help, I'm completely stuck with it.

@jelmer
Copy link
Owner

jelmer commented Jun 3, 2023

local_path = 'c:/tmp/release-package-v0.0.1'

This is an odd local path - it's not a valid windows path IIUC, which should be using backslashes.

Any reason why you're passing in local_path twice, rather than just once? Does it work if you just specify it once, and with backslahses?

Dulwich should normally just scan directories recursively but not explicitly add them. This is exactly what Repo.stage() does.

@jelmer jelmer added the moreinfo label Jun 3, 2023
@tillias
Copy link
Author

tillias commented Jun 4, 2023

No, it doesn't work if I pass it only once or specify another valid folder. That is exactly what I'm trying to solve, it looks like current version of porcelain uses current working path (e.g. where caller script is located) instead of parameter I specify in porcelain.add()

I want to start script in one folder and pass another which I want to add into git repository.

E.g. script is located in /c/scipt_folder/script_using_porcelain_add.py and my repo is in /c/some_git_repo_i_want_to_add

If I call porcelain.add() with any combination of parameters (I really tried hard with all possible combinations before opening the ticket) it always adds /c/scipt_folder/

Please note that /c/scipt_folder/ is also versioned in git

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

No branches or pull requests

2 participants