Skip to content

Silently opens repo for ancestor directory #65

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

Closed
eyevz opened this issue Jul 3, 2012 · 8 comments
Closed

Silently opens repo for ancestor directory #65

eyevz opened this issue Jul 3, 2012 · 8 comments

Comments

@eyevz
Copy link

eyevz commented Jul 3, 2012

Let /git be a git repo, suppose path /git/foo/bar exists (file or directory).

>>> git.Repo('/git/foo/bar')
<git.Repo "/git/.git">

I think this is very dangerous behaviour. For example, in a testing environment one might use

shutil.rmtree(some_repo.working_dir)

where, if some_repo was subject to the behaviour above, created from a path in a project's working directory, unhappiness might ensue.

@Byron
Copy link
Member

Byron commented Jul 3, 2012

Thanks for raising this issue ! I absolutely agree.

This behavior should be made optional, and be off by default in future versions, stating the change clearly in the change-notes.

Besides, I do hope you didn't accidentally delete some of your data !

@eyevz
Copy link
Author

eyevz commented Jul 4, 2012

Nothing so serious - I only mangled a few refs!

Today I have to attend to something else, but tomorrow I will be back on a project where I'm using your library, so I will make the change as you suggest, with a note and some tests, and create a pull-request.

I'm thinking Repo.init should get a new keyword argument, maybe "aggressive=True", which retains the current behaviour. But if aggressive == False then only the parent of .git directory or .git itself are acceptable targets.

Your thoughts? I'm not 100% happy with the name "aggressive". Let me know if you think of a more natural name.

@eyevz
Copy link
Author

eyevz commented Jul 4, 2012

Please note additional comments hidden behind the "..." button in my previous message. I'm not sure how I did that :)

@Byron
Copy link
Member

Byron commented Jul 5, 2012

I would prefer a KW argument name too, maybe one which is more descriptive and precise, like search_parent_directories=True for instance. Its a long name, but it says what it does pretty well.
But, please pick one to your liking in case you find a shorter and equally descriptive name.
Cheers

@sigmavirus24
Copy link

Wouldn't legacy be more descriptive, i.e., this is the old behavior and if that's what you want to expect, than you want the Repo object to operate in "legacy mode"?

@eyevz
Copy link
Author

eyevz commented Jul 6, 2012

Okay, I will use search_parent_directories for now. The docs and change log will explain that default behaviour will change at some point. We can discuss further in the pull-request.

I see that master is quite different from 0.3 branch. Against which should I make the change? Both?

Finally, I am having trouble running the tests (in both branch of the mentioned branches). I will take that discussion to the mailing list.

@Byron
Copy link
Member

Byron commented Jul 11, 2012

I would recommend putting it into master, even though its rather far away from a release.
In 0.3, I wouldn't know if anyone would actually use it or require it. However, if you would like it there, as you would use it in 0.3, thats all I need to justify its presence in both branches.

Thank you.

@Byron Byron added this to the v0.3.5 - bugfixes milestone Nov 19, 2014
@Byron Byron self-assigned this Jan 10, 2015
@Byron Byron closed this as completed in 96c6ab4 Jan 10, 2015
@Byron
Copy link
Member

Byron commented Jan 10, 2015

The keyword was added as discussed.

Additionally, I recorded the process of fixing this one

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

No branches or pull requests

3 participants