Skip to content

Conversation

@petrchmelar
Copy link

  • fix git-lfs smudge with special-characters path for non filter process code path

Fixes #1878

@petrchmelar petrchmelar requested a review from jelmer as a code owner September 4, 2025 06:27
Copy link
Owner

@jelmer jelmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Overalls looks good, one comment inline.

@petrchmelar petrchmelar force-pushed the quote-smudge-path branch 2 times, most recently from 7882bc7 to a7139bb Compare September 8, 2025 07:34
@jelmer jelmer enabled auto-merge (squash) September 8, 2025 11:37
@petrchmelar
Copy link
Author

I'm going to fix the CI


# Substitute %f placeholder with file path
cmd = self.smudge_cmd.replace("%f", path_str)
cmd = self.smudge_cmd.replace("%f", shlex.quote(path_str))
Copy link
Author

@petrchmelar petrchmelar Sep 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunatelly the shlex quoting does not produce a command compatible with subprocess.run(..., shell=True) on windows (see failed job). To do so I have two options:

  1. use barely documented list2cmdline for windows codepath
  2. change the subprocess call to be executed with shell=False - I'm really not sure if it is a right thing to do in context of the commands beeing called

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow reply.

I'm inclined to special-case Windows and use list2cmdline; using subprocess.run(shell=True) seems like the obvious correct thing to do on other platforms.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is OK, I tried to use the list2cmdline for windows. Unfortunately I do not have win machine to test the behavior. Could you launch the CI please?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done - unfortunately github doesn't give me a way to just approve all your CI runs upfront, but it will automatically whitelist you once your first PR lands.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, ok. Thanks

auto-merge was automatically disabled October 10, 2025 10:42

Head branch was pushed to by a user without write access

@petrchmelar petrchmelar force-pushed the quote-smudge-path branch 2 times, most recently from add270c to 7e653b3 Compare October 10, 2025 11:08
"""Implementation of Git filter drivers (clean/smudge filters)."""

import logging
import shlex

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed you are usually using lazy imports in methods themselves. Should I move the shlex to smudge method like I did with os?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine I think; I'm not super consistent either. Generally speaking, I try to lazily import to reduce startup times but some modules are unavoidable or minor in terms of overhead.

@petrchmelar petrchmelar force-pushed the quote-smudge-path branch 2 times, most recently from 0dcd524 to ce9b0c9 Compare October 10, 2025 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dulwich fails to clone lfs files having names with special character when using smudge command

3 participants