summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Johannes Schindelin <johannes.schindelin@gmx.de>2019-02-25 23:16:30 +0000
committerLibravatar Junio C Hamano <gitster@pobox.com>2019-03-07 09:41:40 +0900
commit90a462725ef3932a2408e78a47e3dfc1b8d445cf (patch)
treea6126954c52363bc9eaefebd5fc1f1a425abfe40 /builtin
parentstash: add back the original, scripted `git stash` (diff)
downloadtgif-90a462725ef3932a2408e78a47e3dfc1b8d445cf.tar.xz
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: Thomas Gummerer <t.gummerer@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/stash.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/builtin/stash.c b/builtin/stash.c
index d9f3956ef5..49c6d7948a 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -13,6 +13,7 @@
#include "revision.h"
#include "log-tree.h"
#include "diffcore.h"
+#include "exec-cmd.h"
#define INCLUDE_ALL_FILES 2
@@ -1510,6 +1511,26 @@ static int save_stash(int argc, const char **argv, const char *prefix)
return ret;
}
+static int use_builtin_stash(void)
+{
+ struct child_process cp = CHILD_PROCESS_INIT;
+ struct strbuf out = STRBUF_INIT;
+ int ret;
+
+ argv_array_pushl(&cp.args,
+ "config", "--bool", "stash.usebuiltin", NULL);
+ cp.git_cmd = 1;
+ if (capture_command(&cp, &out, 6)) {
+ strbuf_release(&out);
+ return 1;
+ }
+
+ strbuf_trim(&out);
+ ret = !strcmp("true", out.buf);
+ strbuf_release(&out);
+ return ret;
+}
+
int cmd_stash(int argc, const char **argv, const char *prefix)
{
int i = -1;
@@ -1521,6 +1542,20 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
OPT_END()
};
+ if (!use_builtin_stash()) {
+ const char *path = mkpath("%s/git-legacy-stash",
+ git_exec_path());
+
+ if (sane_execvp(path, (char **)argv) < 0)
+ die_errno(_("could not exec %s"), path);
+ else
+ BUG("sane_execvp() returned???");
+ }
+
+ prefix = setup_git_directory();
+ trace_repo_setup(prefix);
+ setup_work_tree();
+
git_config(git_diff_basic_config, NULL);
argc = parse_options(argc, argv, prefix, options, git_stash_usage,