dulwich icon indicating copy to clipboard operation
dulwich copied to clipboard

[FEATURE] Add walks from cwd and not repo root

Open r0mainK opened this issue 6 years ago • 3 comments

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:

  1. 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.
  2. If you think that the logical thing would be to default to all, as the current doc implies, then switching os.getcwd() to r.path like I did does the trick.

r0mainK avatar Jun 25 '18 16:06 r0mainK

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.

jelmer avatar Jun 25 '18 18:06 jelmer

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 avatar Jun 26 '18 08:06 r0mainK

@r0mainK ping

vmarkovtsev avatar Aug 30 '18 09:08 vmarkovtsev