dulwich
dulwich copied to clipboard
[FEATURE] Add walks from cwd and not repo root
This might not be a fix but an implementation choice, but given the change is simple I thought I'd open a PR and see what happens.
CONTEXT
Currently when using add and not passing any paths to add, we walk though the current working directory instead of the repo root. This means that we are basically doing a git add .
, assuming that the current working directory is in the repo, thus requiring to change the working directory if we are not located in it. It also means if we are using dulwich as an API in another git repo, let's say A, to modify B, then we will walk through A instead of our target B, even if the repo
argu point to B
.
CHANGES
I think one of three two can and should be done:
- If you think it is best to keep this behavior, I think adding an optional
all
argument to walk through the repo root would be useful, and better then forcing the user to switch working directory. - If you think that the logical thing would be to default to
all
, as the current doc implies, then switchingos.getcwd()
tor.path
like I did does the trick.
In general, "dulwich.porcelain.X" should work like the "git X" command, including behaviour around os.getcwd(). Users that don't want to change the cwd can specify absolute paths.
Obviously there are some exceptions to this, e.g. allowing richer data types for inputs/outputs.
Adding an "all" argument and not defaulting to adding everything seems reasonable to me.
Okay, so gonna add this functionality. Now if paths
is not specified add
will act like git add .
whereas if all
is specified it will act as git add --all
. Tests are still pending bbut this should be ready for review by noon.
@r0mainK ping