Skip to content

Update the built-in git stash to the latest version #2119

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

Merged
merged 63 commits into from
Mar 11, 2019

Conversation

dscho
Copy link
Member

@dscho dscho commented Mar 11, 2019

This brings Git for Windows' version up to date with what landed in git.git's pu. In particular, this closes #2037.

dscho added 30 commits March 11, 2019 16:36
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
…processes

In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <[email protected]>
ungps and others added 16 commits March 11, 2019 16:55
Add stash list to the helper and delete the list_stash function
from the shell script.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
Add stash show to the helper and delete the show_stash, have_stash,
assert_stash_like, is_stash_like and parse_flags_and_rev functions
from the shell script now that they are no longer needed.

In shell version, although `git stash show` accepts `--index` and
`--quiet` options, it ignores them. In C, both options are passed
further to `git diff`.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
Add stash store to the helper and delete the store_stash function
from the shell script.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
This change was introduced upstream in an evil merge.

Signed-off-by: Johannes Schindelin <[email protected]>
Add stash create to the helper.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Helped-by: Matthew Kraai <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
Add stash push to the helper.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
There is a change in behaviour with this commit. When there was
no initial commit, the shell version of stash would still display
a message. This commit makes `push` to not display any message if
`--quiet` or `-q` is specified. Add tests for `--quiet`.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
Add stash save to the helper and delete functions which are no
longer needed (`show_help()`, `save_stash()`, `push_stash()`,
`create_stash()`, `clear_stash()`, `untracked_files()` and
`no_changes()`).

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
This commits introduces a optimization by avoiding calling the
same functions again. For example, `git stash push -u`
would call at some points the following functions:

 * `check_changes()` (inside `do_push_stash()`)
 * `do_create_stash()`, which calls: `check_changes()` and
`get_untracked_files()`

Note that `check_changes()` also calls `get_untracked_files()`.
So, `check_changes()` is called 2 times and `get_untracked_files()`
3 times.

The old function `check_changes()` now consists of two functions:
`get_untracked_files()` and `check_changes_tracked_files()`.

These are the call chains for `push` and `create`:

 * `push_stash()` -> `do_push_stash()` -> `do_create_stash()`

 * `create_stash()` -> `do_create_stash()`

To prevent calling the same functions over and over again,
`check_changes()` inside `do_create_stash()` is now placed
in the caller functions (`create_stash()` and `do_push_stash()`).
This way `check_changes()` and `get_untracked files()` are called
only one time.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
Avoid spawning write-tree child processes by replacing the calls with
in-core API calls.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
The old shell script `git-stash.sh`  was removed and replaced
entirely by `builtin/stash.c`. In order to do that, `create` and
`push` were adapted to work without `stash.sh`. For example, before
this commit, `git stash create` called `git stash--helper create
--message "$*"`. If it called `git stash--helper create "$@"`, then
some of these changes wouldn't have been necessary.

This commit also removes the word `helper` since now stash is
called directly and not by a shell script.

Signed-off-by: Paul-Sebastian Ungureanu <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
This simply copies the version as of sd/stash-wo-user-name verbatim. As
of now, it is not hooked up.

The next commit will change the builtin `stash` to hand off to the
scripted `git stash` when `stash.useBuiltin=false`.

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
We recently converted the `git stash` command from Unix shell scripts
to builtins.

Let's end users a way out when they discover a bug in the
builtin command: `stash.useBuiltin`.

As the file name `git-stash` is already in use, let's rename the
scripted backend to `git-legacy-stash`.

To make the test suite pass with `stash.useBuiltin=false`, this commit
also backports rudimentary support for `-q` (but only *just* enough
to appease the test suite), and adds a super-ugly hack to force exit
code 129 for `git stash -h`.

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
Add a GIT_TEST_STASH_USE_BUILTIN=false test mode which is equivalent
to running with stash.useBuiltin=false. This is needed to spot that
we're not introducing any regressions in the legacy stash version
while we're carrying both it and the new built-in version.

This imitates the equivalent treatment for the built-in rebase in
62c2393 (tests: add a special setup where rebase.useBuiltin is off,
2018-11-14).

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Thomas Gummerer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
When this developer backported support for `--quiet` to the scripted
version of `git stash` in 8059005 (stash: optionally use the scripted
version again, 2018-12-20), it looked like a sane choice to use `eval`
to execute the command line passed in via the parameter list of
`maybe_quiet`.

However, that is not what we should have done, as that command-line was
already in the correct shape.

This can be seen very clearly when passing arguments with special
characters, like

	git stash -- ':(glob)**/*.txt'

Since this is exactly what we want to test in the next commit (where we
fix this very incantation with the built-in stash), let's fix the legacy
scripted version of `git stash` first.

Signed-off-by: Johannes Schindelin <[email protected]>
When passing a list of pathspecs to, say, `git add`, we need to be
careful to use the original form, not the parsed form of the pathspecs.

This makes a difference e.g. when calling

	git stash -- ':(glob)**/*.txt'

where the original form includes the `:(glob)` prefix while the parsed
form does not.

However, in the built-in `git stash`, we passed the parsed (i.e.
incorrect) form, and `git add` would fail with the error message:

	fatal: pathspec '**/*.txt' did not match any files

at the stage where `git stash` drops the changes from the worktree, even
if `refs/stash` has been actually updated successfully.

This fixes git-for-windows#2037

Signed-off-by: Johannes Schindelin <[email protected]>
@dscho dscho force-pushed the update-stash-to-current branch from 962cba7 to 66af0b6 Compare March 11, 2019 15:59
@dscho dscho merged commit dc2ae9a into git-for-windows:master Mar 11, 2019
@dscho dscho deleted the update-stash-to-current branch March 11, 2019 18:58
dscho added a commit that referenced this pull request Mar 11, 2019
Update the built-in `git stash` to the latest version
git-for-windows-ci pushed a commit that referenced this pull request Mar 20, 2019
Update the built-in `git stash` to the latest version
dscho added a commit to dscho/git that referenced this pull request May 13, 2019
…rrent

Update the built-in `git stash` to the latest version
dscho added a commit to dscho/git that referenced this pull request May 13, 2019
…rrent

Update the built-in `git stash` to the latest version
git-for-windows-ci pushed a commit that referenced this pull request May 14, 2019
Update the built-in `git stash` to the latest version
dscho added a commit that referenced this pull request May 21, 2019
Update the built-in `git stash` to the latest version
dscho added a commit that referenced this pull request May 22, 2019
Update the built-in `git stash` to the latest version
dscho added a commit that referenced this pull request May 25, 2019
Update the built-in `git stash` to the latest version
dscho added a commit that referenced this pull request Jun 8, 2019
Update the built-in `git stash` to the latest version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pathspec fatal git stash push keep-index with globs
5 participants