Skip to content

IndexFile._to_relative_path - fix case where absolute path gets stripped of trailing slash - #2012

Merged
Byron merged 1 commit into
gitpython-developers:mainfrom
kamilkozik7:fix-trailing-slash
Mar 12, 2025
Merged

IndexFile._to_relative_path - fix case where absolute path gets stripped of trailing slash#2012
Byron merged 1 commit into
gitpython-developers:mainfrom
kamilkozik7:fix-trailing-slash

Conversation

@kamilkozik7

@kamilkozik7 kamilkozik7 commented Mar 7, 2025

Copy link
Copy Markdown
Contributor

I encountered this issue on MacOS, python 3.7 and later

Added fix and appropriate unit test.

Stripping of trailing slash seems to be happening in os.path.relpath, altough I am not sure whether that is expected behaviour. In case it is not expected, and ever gets fixed, I added an additional check ( and not result.endswith(os.sep)) to make sure that the trailing slash doesn't get duplicated.

@kamilkozik7
kamilkozik7 force-pushed the fix-trailing-slash branch 3 times, most recently from 2bbb6ee to 3a40c1c Compare March 7, 2025 17:55
@kamilkozik7
kamilkozik7 marked this pull request as ready for review March 7, 2025 18:07

@kelibezhani kelibezhani left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@Byron
Byron force-pushed the fix-trailing-slash branch from 3a40c1c to 11f7faf Compare March 12, 2025 12:31

@Byron Byron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great, thanks a lot for the fix!
Looks good to me, too!

@Byron
Byron merged commit e85a895 into gitpython-developers:main Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants