Skip to content

Commit 52240eb

Browse files
committed
Merge branch 'make-builtin-stash-and-rebase-opt-ins'
This branch adds back the scripted versions, then adds the option to use the builtin versions of `stash` and `rebase` by setting `stash.useBuiltin=true` and `rebase.useBuiltin=true`, respectively, (the latter already worked for the top-level `git rebase` command and the `--am` backend, and now it also works for the interactive backend). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2 parents d1c9aba + cff1a96 commit 52240eb

12 files changed

+1139
-37
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
/git-interpret-trailers
8080
/git-instaweb
8181
/git-legacy-rebase
82+
/git-legacy-rebase--interactive
83+
/git-legacy-stash
8284
/git-log
8385
/git-ls-files
8486
/git-ls-remote

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,13 @@ SCRIPT_SH += git-merge-resolve.sh
615615
SCRIPT_SH += git-mergetool.sh
616616
SCRIPT_SH += git-quiltimport.sh
617617
SCRIPT_SH += git-legacy-rebase.sh
618+
SCRIPT_SH += git-legacy-stash.sh
618619
SCRIPT_SH += git-remote-testgit.sh
619620
SCRIPT_SH += git-request-pull.sh
620621
SCRIPT_SH += git-submodule.sh
621622
SCRIPT_SH += git-web--browse.sh
622623

624+
SCRIPT_LIB += git-legacy-rebase--interactive
623625
SCRIPT_LIB += git-mergetool--lib
624626
SCRIPT_LIB += git-parse-remote
625627
SCRIPT_LIB += git-rebase--am

builtin/rebase--interactive.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
141141
char *raw_strategies = NULL;
142142
enum {
143143
NONE = 0, CONTINUE, SKIP, EDIT_TODO, SHOW_CURRENT_PATCH,
144-
SHORTEN_OIDS, EXPAND_OIDS, CHECK_TODO_LIST, REARRANGE_SQUASH, ADD_EXEC
144+
SHORTEN_OIDS, EXPAND_OIDS, CHECK_TODO_LIST, REARRANGE_SQUASH, ADD_EXEC,
145+
MAKE_SCRIPT, SKIP_UNNECESSARY_PICKS,
145146
} command = 0;
146147
struct option options[] = {
147148
OPT_BOOL(0, "ff", &opts.allow_ff, N_("allow fast-forward")),
@@ -192,6 +193,10 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
192193
OPT_STRING(0, "onto-name", &onto_name, N_("onto-name"), N_("onto name")),
193194
OPT_STRING(0, "cmd", &cmd, N_("cmd"), N_("the command to run")),
194195
OPT_RERERE_AUTOUPDATE(&opts.allow_rerere_auto),
196+
OPT_CMDMODE(0, "make-script", &command,
197+
N_("make rebase script"), MAKE_SCRIPT),
198+
OPT_CMDMODE(0, "skip-unnecessary-picks", &command,
199+
N_("skip unnecessary picks"), SKIP_UNNECESSARY_PICKS),
195200
OPT_END()
196201
};
197202

@@ -263,6 +268,17 @@ int cmd_rebase__interactive(int argc, const char **argv, const char *prefix)
263268
case ADD_EXEC:
264269
ret = sequencer_add_exec_commands(cmd);
265270
break;
271+
case MAKE_SCRIPT:
272+
ret = sequencer_make_script(stdout, argc, argv, flags);
273+
break;
274+
case SKIP_UNNECESSARY_PICKS: {
275+
struct object_id oid;
276+
277+
ret = skip_unnecessary_picks(&oid);
278+
if (!ret)
279+
printf("%s\n", oid_to_hex(&oid));
280+
break;
281+
}
266282
default:
267283
BUG("invalid command '%d'", command);
268284
}

builtin/rebase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static int use_builtin_rebase(void)
5454
cp.git_cmd = 1;
5555
if (capture_command(&cp, &out, 6)) {
5656
strbuf_release(&out);
57-
return 1;
57+
return 0;
5858
}
5959

6060
strbuf_trim(&out);

builtin/stash.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "revision.h"
1414
#include "log-tree.h"
1515
#include "diffcore.h"
16+
#include "exec-cmd.h"
1617

1718
static const char * const git_stash_usage[] = {
1819
N_("git stash list [<options>]"),
@@ -1477,6 +1478,26 @@ static int save_stash(int argc, const char **argv, const char *prefix)
14771478
return ret;
14781479
}
14791480

1481+
static int use_builtin_stash(void)
1482+
{
1483+
struct child_process cp = CHILD_PROCESS_INIT;
1484+
struct strbuf out = STRBUF_INIT;
1485+
int ret;
1486+
1487+
argv_array_pushl(&cp.args,
1488+
"config", "--bool", "stash.usebuiltin", NULL);
1489+
cp.git_cmd = 1;
1490+
if (capture_command(&cp, &out, 6)) {
1491+
strbuf_release(&out);
1492+
return 0;
1493+
}
1494+
1495+
strbuf_trim(&out);
1496+
ret = !strcmp("true", out.buf);
1497+
strbuf_release(&out);
1498+
return ret;
1499+
}
1500+
14801501
int cmd_stash(int argc, const char **argv, const char *prefix)
14811502
{
14821503
int i = -1;
@@ -1488,6 +1509,20 @@ int cmd_stash(int argc, const char **argv, const char *prefix)
14881509
OPT_END()
14891510
};
14901511

1512+
if (!use_builtin_stash()) {
1513+
const char *path = mkpath("%s/git-legacy-stash",
1514+
git_exec_path());
1515+
1516+
if (sane_execvp(path, (char **)argv) < 0)
1517+
die_errno(_("could not exec %s"), path);
1518+
else
1519+
BUG("sane_execvp() returned???");
1520+
}
1521+
1522+
prefix = setup_git_directory();
1523+
trace_repo_setup(prefix);
1524+
setup_work_tree();
1525+
14911526
git_config(git_default_config, NULL);
14921527

14931528
argc = parse_options(argc, argv, prefix, options, git_stash_usage,

0 commit comments

Comments
 (0)