Commit Graph

96615 Commits

Author SHA1 Message Date
Paul-Sebastian Ungureanu
bef7e56075 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:55:40 +01:00
Paul-Sebastian Ungureanu
1e3b9c2135 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:55:39 +01:00
Joel Teichroeb
c85d792c29 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:55:39 +01:00
Joel Teichroeb
6fe783f5a6 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:55:39 +01:00
Joel Teichroeb
4d733c4f1d 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:55:39 +01:00
Johannes Schindelin
c58e38df53 fixup: stash: convert apply to builtin
This change was introduced upstream in an evil merge.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:55:37 +01:00
Johannes Schindelin
73f47ba2a0 fixup: stash: convert apply to builtin
This change was introduced upstream in an evil merge.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:55:14 +01:00
Joel Teichroeb
4f6218c91b 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:37:00 +01:00
Paul-Sebastian Ungureanu
58e1f63a9c 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:37:00 +01:00
Paul-Sebastian Ungureanu
9346a09195 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:37:00 +01:00
Paul-Sebastian Ungureanu
18d0c35a27 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:37:00 +01:00
Matthew Kraai
8ef273dc82 t3903: add test for --intent-to-add file
Add a test showing the 'git stash' behaviour with a file that has been
added with 'git add --intent-to-add'.  Stash fails to stash the file,
so the purpose of this test is mainly to make sure git doesn't crash,
but exits normally in this situation.

This is in preparation for converting stash into a builtin.

[tg: pulled the test out into a separate commit]

Signed-off-by: Matthew Kraai <mkraai@its.jnj.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:37:00 +01:00
Paul-Sebastian Ungureanu
f198a7097a t3903: modernize style
Remove whitespaces after redirection operators and wrap
long lines.

Signed-off-by: Paul-Sebastian Ungureanu <ungureanupaulsebastian@gmail.com>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:37:00 +01:00
Joel Teichroeb
dca0c78b75 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:36:59 +01:00
Thomas Gummerer
5061ec1072 ident: don't require calling prepare_fallback_ident first
In fd5a58477c ("ident: add the ability to provide a "fallback
identity"", 2019-02-25) I made it a requirement to call
prepare_fallback_ident as the first function in the ident API.
However in stash we didn't actually end up following that.

This leads to a BUG if user.email and user.name are set.  It was not
caught in the test suite because we only rely on environment variables
for setting the user name and email instead of the config.

Instead of making it a bug to call other functions in the ident API
first, just return silently if the identity of a user was already set
up.

Reported-by: Denton Liu <liu.denton@gmail.com>
Helped-by: Jeff King <peff@peff.net>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:36:59 +01:00
Johannes Schindelin
d3dc2ab2c0 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>
[tg: add docs; make it a bug to call the function before other
functions in the ident API]
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:36:59 +01:00
Paul-Sebastian Ungureanu
7cfbaa502a 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>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:36:59 +01:00
Paul-Sebastian Ungureanu
3422bdcfc3 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: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2019-03-11 16:36:59 +01:00
Paul-Sebastian Ungureanu
aaede5ca6a 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-03-11 16:36:59 +01:00
Johannes Schindelin
61e921a2a5 fixup! sha1-name.c: add get_oidf() which acts like get_oid()
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:21 +01:00
Johannes Schindelin
02f8005b67 fixup! strbuf.c: add strbuf_join_argv()
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:21 +01:00
Johannes Schindelin
dd1d9a52d3 fixup! strbuf.c: add strbuf_insertf() and strbuf_vinsertf()
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:20 +01:00
Johannes Schindelin
9902b5e6aa fixup! ident: add the ability to provide a "fallback identity"
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:20 +01:00
Johannes Schindelin
6210c671e4 fixup! stash: improve option parsing test coverage
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:20 +01:00
Johannes Schindelin
1acc1e9960 fixup! t3903: modernize style
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:19 +01:00
Johannes Schindelin
0e1bf9f413 fixup! stash: rename test cases to be more descriptive
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:19 +01:00
Johannes Schindelin
e4e2dfd6cd fixup! stash: add tests for git stash show config
In preparation for a newer patch series.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:18 +01:00
Johannes Schindelin
82de2cee8f fixup! stash: mention options in show synopsis
In preparation for a newer patch series.

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

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

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

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

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

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

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

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2019-03-11 16:36:16 +01:00
Johannes Schindelin
c341b4ea07 fixup! stash: convert create to builtin
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
ca9031fea0 fixup! stash: convert push to builtin
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
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