-
Notifications
You must be signed in to change notification settings - Fork 140
Turn git add-i into built-in #103
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
Conversation
3a0dfcc
to
e2040fb
Compare
/allow slavicaJd |
/allow slavicaDj |
User slavicaDj is now allowed to use GitGitGadget. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exciting. We're getting really close! I added a couple of suggestions, hopefully they help.
/submit |
Submitted as [email protected] |
e1f14e0
to
b946f45
Compare
How about using proper markup for the enumeration (GitGitGadget will render the Markdown format and wrap to the appropriate number of columns per row, no need to uglify the PR description here by doing that manually), and also maybe reinstating the overall description of the PR (I see that you removed it in favor of the |
/submit |
Submitted as [email protected] |
/submit |
Submitted as [email protected] |
bad9d5c
to
ca2a7c4
Compare
/submit |
Submitted as [email protected] |
On the Git mailing list, Phillip Wood wrote (reply to this):
|
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
The first part of the long journey to a fully built-in `git add -i`. It reflects the part that was submitted a couple of times (see gitgitgadget#103) during the Outreachy project by Slavica Đukić that continued the journey based on an initial patch series by Daniel Ferreira. This part only implements the `status` and the `help` part, like Slavica's last iteration did, in the interest of making the review remotely more reviewable. I fear that this attempt of making it a bit more reviewable is pretty futile, as so many things changed. So I will ask the reviewers for forgiveness: please be kind, and give this sort of a fresh review. I threw in a couple of major changes on top of that iteration, though: - The original plan was to add a helper (`git add--helper`) that takes over more and more responsibility from the Perl script over the course of the conversion. This plan is no longer in effect, as I encountered a serious problem with that: the MSYS2 runtime used by the Perl interpreter which Git for Windows employs to run `git add -i` has a curious bug (that is safely outside the purview of this here patch series) where it fails to read from standard input after it spawned a non-MSYS2 program that reads from standard input. To keep my `git add -i` in a working state, I therefore adopted a different strategy: Just like `git difftool` was converted by starting with a built-in that did nothing but handing off to the scripted version, guarded by the (opt-in) `difftool.useBuiltin` config setting, I start this patch series by a built-in `add -i` that does nothing else but state that it is not implemented yet, guarded by the (opt-in) `add.interactive.useBuiltin` config setting. In contrast to the `git difftool` situation, it is quite a bit easier here, as we do not even have to rename the script to `git-legacy-add--interactive.perl`: the `add--interactive` command is an implementation detail that users are not even supposed to know about. Therefore, we can implement that road fork between the built-in and the scripted version in `builtin/add.c`, i.e. in the user-facing `git add` command. This will also naturally help with the transition to a fully built-in `git add -i`/`git add -p`, as we saw with the built-in `git rebase` how important it is for end users to have an escape hatch (and for that reason, tried our best to provide the same with the built-in `git stash`). - The `help` command was actually not hooked up in `git add -i`, but was only available as a special option of the `git add--helper` command. As that command no longer exists, I kind of *had* to implement some way to let the built-in `git add -i` show the help text. - The main loop of `git add -i` (i.e. the thing that lets you choose `status` or `help`) is now implemented (but only lists `status` and `help`, of course), as it makes use of that feature that took the main chunk of the Outreachy project: the function to determine unique prefixes of a list of strings. - Speaking of the unique prefixes: the functionality to determine those is now encapsulated in the `prefix-map.c` file, and I also added a regression test. - Speaking of the tests: I also implemented support for the environment variable `GIT_TEST_ADD_I_USE_BUILTIN`: by setting it, the test suite can be forced to use the built-in, or the Perl script, version of `git add -i`. Needless to say: by the end of this patch series, running the test suite with `GIT_TEST_ADD_I_USE_BUILTIN=true` will still result in a ton of test failures due to not-yet-implemented commands, but it will also demonstrate what *already* works. - Since the main loop starts not only by showing the status, but refreshes the index before that, I added that, and I actually refactored that code into a new function (`repo_refresh_and_write_index()`), as it will be used a couple of times by the end of the complete conversion of `git add -i` into a built-in command. Signed-off-by: Johannes Schindelin <[email protected]>
This is the first version of a patch series to start porting
git-add--interactive from Perl to C.
Daniel Ferreira's patch series used as a head start:
https://public-inbox.org/git/[email protected]/t/#u
Changes since v4:
resulted in code refactoring, i.e. separating list_modified
and status_cmd and making status_cmd use both list_modified
and list_and_choose
data structure for list_and_choose
users
Note that authorship handling is slightly changed. In some of the commits, I used Original-patch-by instead of listing Daniel Ferreira as author.
Also, I would like to point out that my Outreachy internship is going to finish on March 4 and I would really appreciate reviews before it does.
Cc: Phillip Wood [email protected], Ævar Arnfjörð Bjarmason [email protected]