Commit Graph

96578 Commits

Author SHA1 Message Date
Johannes Schindelin
666ae6eea8 fixup! stash: make push -q quiet
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:15 +01:00
Johannes Schindelin
de276357c9 fixup! stash: convert save to builtin
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:14 +01:00
Johannes Schindelin
2b4813df50 fixup! stash: optimize get_untracked_files() and check_changes()
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:14 +01:00
Johannes Schindelin
7f224087fe fixup! stash: replace all write-tree child processes with API calls
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:14 +01:00
Johannes Schindelin
19ba7d4a3b fixup! stash: convert stash--helper.c into stash.c
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:13 +01:00
Johannes Schindelin
ab8c1b3341 fixup! stash: add back the original, scripted git stash
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:13 +01:00
Johannes Schindelin
1a179124f1 fixup! stash: optionally use the scripted version again
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:13 +01:00
Johannes Schindelin
1acb791d83 fixup! tests: add a special setup where stash.useBuiltin is off
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:12 +01:00
Johannes Schindelin
b95677fed3 fixup! stash: fix segmentation fault when files were added with intent
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:12 +01:00
Johannes Schindelin
017b95da39 fixup! strbuf_vinsertf: provide the correct buffer size to vsnprintf
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:12 +01:00
Johannes Schindelin
c6f8916538 fixup! stash: discard in-process cache after spawning index-changing processes
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:11 +01:00
Johannes Schindelin
41fef97f02 fixup! stash: avoid unnecessary reset_tree() call
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:11 +01:00
Johannes Schindelin
65de8ee891 stash: avoid unnecessary reset_tree() call
In 45c1389c31 (stash: convert apply to builtin, 2018-12-20), we
introduced code that is the equivalent of `git write-tree && git
read-tree`. But the original shell script only called `git write-tree`
(because the read-tree would obviously be a no-op). So let's skip the
reset_tree() call that is the equivalent that that `git read-tree`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-02-24 21:12:30 +01:00
Johannes Schindelin
e68e2a6ccb stash: discard in-process cache after spawning index-changing processes
In 9a67cb4f1f (stash: convert push to builtin, 2018-12-20), we started
to call `git apply -R --index` and `git reset --hard`, but held onto the
now-stale index in memory. Let's discard it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-02-24 21:12:29 +01:00
Johannes Sixt
3b1411413e strbuf_vinsertf: provide the correct buffer size to vsnprintf
strbuf_vinsertf inserts a formatted string in the middle of an existing
strbuf value. It makes room in the strbuf by moving existing string to
the back, then formats the string to insert directly into the hole.

It uses vsnprintf to format the string. The buffer size provided in the
invocation is the number of characters available in the allocated space
behind the final string. This does not make any sense at all.

Fix it to pass the length of the inserted string plus one for the NUL.
(The functions saves and restores the character that the NUL occupies.)

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:29 +01:00
Matthew Kraai
c99676afa8 stash: fix segmentation fault when files were added with intent
After `git add -N <file>`, the index is in a special state. A state for
which the built-in stash was not prepared, as it failed to initialize
the `rev` structure in that case before using `&rev.pending`.  If
`reset_tree()` returns a non-zero value, `stash_working_tree()`
calls `object_array_clear()` with `&rev.pending`.  If `rev` is not
initialized, this causes a segmentation fault.

Prevent this by initializing `rev` before calling `reset_tree()`.

This fixes https://github.com/git-for-windows/git/issues/2006.

[jes: modified the commit message in preparation for sending this patch
to the Git mailing list.]

Signed-off-by: Matthew Kraai <mkraai@its.jnj.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:29 +01:00
Johannes Schindelin
dc72b08653 tests: add a special setup where stash.useBuiltin is off
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
62c23938fa (tests: add a special setup where rebase.useBuiltin is off,
2018-11-14).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:29 +01:00
Johannes Schindelin
80590055ea stash: optionally use the scripted version again
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:28 +01:00
Johannes Schindelin
6111407370 stash: add back the original, scripted git stash
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 <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:28 +01:00
Paul-Sebastian Ungureanu
21a2d3d1a5 stash: convert stash--helper.c into stash.c
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 <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:27 +01:00
Paul-Sebastian Ungureanu
6ad339296c stash: replace all write-tree child processes with API calls
This commit replaces spawning `git write-tree` with API calls.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:27 +01:00
Paul-Sebastian Ungureanu
83458c3e0c stash: optimize get_untracked_files() and check_changes()
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.

https://public-inbox.org/git/20180818223329.GJ11326@hank.intra.tgummerer.com/

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:27 +01:00
Paul-Sebastian Ungureanu
6399f56d6d stash: convert save to builtin
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 <ungureanupaulsebastian@gmail.com>
2019-02-24 21:12:27 +01:00
Paul-Sebastian Ungureanu
bf7c09a07d stash: make push -q quiet
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 <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:26 +01:00
Paul-Sebastian Ungureanu
d01aed06cc stash: convert push to builtin
Add stash push to the helper.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:26 +01:00
Paul-Sebastian Ungureanu
bfdc3c6425 stash: convert create to builtin
Add stash create to the helper.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:26 +01:00
Paul-Sebastian Ungureanu
2516d6b944 stash: convert store to builtin
Add stash store to the helper and delete the store_stash function
from the shell script.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-02-24 21:12:25 +01:00
Paul-Sebastian Ungureanu
7d20ff6654 stash: convert show to builtin
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 <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:25 +01:00
Paul-Sebastian Ungureanu
fd997edb03 stash: convert list to builtin
Add stash list to the helper and delete the list_stash function
from the shell script.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:25 +01:00
Joel Teichroeb
990f3d5a25 stash: convert pop to builtin
Add stash pop to the helper and delete the pop_stash, drop_stash,
assert_stash_ref functions from the shell script now that they
are no longer needed.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:24 +01:00
Joel Teichroeb
9384306b4a stash: convert branch to builtin
Add stash branch to the helper and delete the apply_to_branch
function from the shell script.

Checkout does not currently provide a function for checking out
a branch as cmd_checkout does a large amount of sanity checks
first that we require here.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:24 +01:00
Joel Teichroeb
3b1c037e6f stash: convert drop and clear to builtin
Add the drop and clear commands to the builtin helper. These two
are each simple, but are being added together as they are quite
related.

We have to unfortunately keep the drop and clear functions in the
shell script as functions are called with parameters internally
that are not valid when the commands are called externally. Once
pop is converted they can both be removed.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:24 +01:00
Joel Teichroeb
7e880e9a6d stash: convert apply to builtin
Add a builtin helper for performing stash commands. Converting
all at once proved hard to review, so starting with just apply
lets conversion get started without the other commands being
finished.

The helper is being implemented as a drop in replacement for
stash so that when it is complete it can simply be renamed and
the shell script deleted.

Delete the contents of the apply_stash shell function and replace
it with a call to stash--helper apply until pop is also
converted.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-02-24 21:12:24 +01:00
Paul-Sebastian Ungureanu
5ebd74350f stash: mention options in show synopsis
Mention in the documentation, that `show` accepts any
option known to `git diff`.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:23 +01:00
Paul-Sebastian Ungureanu
801b18034b stash: add tests for git stash show config
This commit introduces tests for `git stash show`
config. It tests all the cases where `stash.showStat`
and `stash.showPatch` are unset or set to true / false.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:23 +01:00
Paul-Sebastian Ungureanu
1817cfadd8 stash: rename test cases to be more descriptive
Rename some test cases' labels to be more descriptive and under 80
characters per line.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:23 +01:00
Paul-Sebastian Ungureanu
270c6ac392 t3903: modernize style
Remove whitespaces after redirection operators and wrap
long lines.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:22 +01:00
Joel Teichroeb
2914c92db4 stash: improve option parsing test coverage
In preparation for converting the stash command incrementally to
a builtin command, this patch improves test coverage of the option
parsing. Both for having too many parameters, or too few.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:22 +01:00
Johannes Schindelin
e0f5d261e8 ident: add the ability to provide a "fallback identity"
In 3bc2111fc2 (stash: tolerate missing user identity, 2018-11-18),
`git stash` learned to provide a fallback identity for the case that no
proper name/email was given (and `git stash` does not really care about
a correct identity anyway, but it does want to create a commit object).

In preparation for the same functionality in the upcoming built-in
version of `git stash`, let's offer the same functionality as an API
function.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:22 +01:00
Paul-Sebastian Ungureanu
3b901d672a strbuf.c: add strbuf_insertf() and strbuf_vinsertf()
Implement `strbuf_insertf()` and `strbuf_vinsertf()` to
insert data using a printf format string.

Original-idea-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:22 +01:00
Paul-Sebastian Ungureanu
f2113ce855 strbuf.c: add strbuf_join_argv()
Implement `strbuf_join_argv()` to join arguments
into a strbuf.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:21 +01:00
Paul-Sebastian Ungureanu
dee1c41ec6 sha1-name.c: add get_oidf() which acts like get_oid()
Compared to `get_oid()`, `get_oidf()` has as parameters
a pointer to `object_id`, a printf format string and
additional arguments. This will help simplify the code
in subsequent commits.

Original-idea-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-02-24 21:12:21 +01:00
Johannes Schindelin
7dcd3d86d4 Start the merging-rebase to v2.21.0
We use this opportunity to move the following topics into the
`ready-for-upstream` branch thicket: msvc, visual-studio,
no-perl-makemaker, program-data-config and ansi-unicode.

This commit starts the rebase of a4b818922f to 2bb64867dc

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-02-24 21:00:04 +01:00
Johannes Schindelin
169a70347b Merge remote-tracking branch 'origin/master' into rebase-to-v2.21.0
We accepted a Pull Request into `master`, but the main development
happens on the topic branch `rebase-to-v2.21.0` right now, leading
for the final v2.21.0 tag that was *just* published.

Since we just forward-ported the changes in c86d193e61 (Merge pull
request #2088 from dscho/test-oid-fix-windows, 2019-02-24), we can
safely pull in the commit history of origin/master in a fake merge (i.e.
with `-s ours`), to make `master` fast-forward to `rebase-to-v2.21.0`
again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-02-24 20:31:06 +01:00
Johannes Schindelin
51377a8ba8 Merge pull request #2088 from dscho/test-oid-fix-windows
Drop a redundant patch
2019-02-24 20:28:52 +01:00
Johannes Schindelin
c3e64bcd1f fixup! .gitattributes: ensure t/oid-info/* has eol=lf
This patch made it into git.git's `master` already, inserting the line
at a different spot, that's why we did not notice in Git for Windows why
it is no longer needed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-02-24 20:28:52 +01:00
Johannes Schindelin
c86d193e61 Merge pull request #2088 from dscho/test-oid-fix-windows
Drop a redundant patch
2019-02-24 19:44:29 +01:00
Junio C Hamano
8104ec994e Git 2.21
Signed-off-by: Junio C Hamano <gitster@pobox.com>
v2.21.0
2019-02-24 07:55:19 -08:00
Johannes Schindelin
f426f7aabb fixup! .gitattributes: ensure t/oid-info/* has eol=lf
This patch made it into git.git's `master` already, inserting the line
at a different spot, that's why we did not notice in Git for Windows why
it is no longer needed.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-02-24 16:43:08 +01:00
Junio C Hamano
572e460b7a Merge branch 'yn/checkout-doc-fix'
Doc fix.

* yn/checkout-doc-fix:
  checkout doc: fix an unmatched double-quote pair
2019-02-24 07:18:00 -08:00