Merge branch 'tr/reset-checkout-patch'
* tr/reset-checkout-patch: stash: simplify defaulting to "save" and reject unknown options Make test case number unique tests: disable interactive hunk selection tests if perl is not available DWIM 'git stash save -p' for 'git stash -p' Implement 'git stash save --patch' Implement 'git checkout --patch' Implement 'git reset --patch' builtin-add: refactor the meat of interactive_add() Add a small patch-mode testing library git-apply--interactive: Refactor patch mode code Make 'git stash -k' a short form for 'git stash save --keep-index'
This commit is contained in:
@ -131,10 +131,37 @@ static const char **validate_pathspec(int argc, const char **argv, const char *p
|
||||
return pathspec;
|
||||
}
|
||||
|
||||
int run_add_interactive(const char *revision, const char *patch_mode,
|
||||
const char **pathspec)
|
||||
{
|
||||
int status, ac, pc = 0;
|
||||
const char **args;
|
||||
|
||||
if (pathspec)
|
||||
while (pathspec[pc])
|
||||
pc++;
|
||||
|
||||
args = xcalloc(sizeof(const char *), (pc + 5));
|
||||
ac = 0;
|
||||
args[ac++] = "add--interactive";
|
||||
if (patch_mode)
|
||||
args[ac++] = patch_mode;
|
||||
if (revision)
|
||||
args[ac++] = revision;
|
||||
args[ac++] = "--";
|
||||
if (pc) {
|
||||
memcpy(&(args[ac]), pathspec, sizeof(const char *) * pc);
|
||||
ac += pc;
|
||||
}
|
||||
args[ac] = NULL;
|
||||
|
||||
status = run_command_v_opt(args, RUN_GIT_CMD);
|
||||
free(args);
|
||||
return status;
|
||||
}
|
||||
|
||||
int interactive_add(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int status, ac;
|
||||
const char **args;
|
||||
const char **pathspec = NULL;
|
||||
|
||||
if (argc) {
|
||||
@ -143,21 +170,9 @@ int interactive_add(int argc, const char **argv, const char *prefix)
|
||||
return -1;
|
||||
}
|
||||
|
||||
args = xcalloc(sizeof(const char *), (argc + 4));
|
||||
ac = 0;
|
||||
args[ac++] = "add--interactive";
|
||||
if (patch_interactive)
|
||||
args[ac++] = "--patch";
|
||||
args[ac++] = "--";
|
||||
if (argc) {
|
||||
memcpy(&(args[ac]), pathspec, sizeof(const char *) * argc);
|
||||
ac += argc;
|
||||
}
|
||||
args[ac] = NULL;
|
||||
|
||||
status = run_command_v_opt(args, RUN_GIT_CMD);
|
||||
free(args);
|
||||
return status;
|
||||
return run_add_interactive(NULL,
|
||||
patch_interactive ? "--patch" : NULL,
|
||||
pathspec);
|
||||
}
|
||||
|
||||
static int edit_patch(int argc, const char **argv, const char *prefix)
|
||||
|
Reference in New Issue
Block a user