]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/patch-mode-in-others-in-c'
authorJunio C Hamano <gitster@pobox.com>
Wed, 5 Feb 2020 22:34:58 +0000 (14:34 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Feb 2020 22:34:58 +0000 (14:34 -0800)
The effort to move "git-add--interactive" to C continues.

* js/patch-mode-in-others-in-c:
  commit --interactive: make it work with the built-in `add -i`
  built-in add -p: implement the "worktree" patch modes
  built-in add -p: implement the "checkout" patch modes
  built-in stash: use the built-in `git add -p` if so configured
  legacy stash -p: respect the add.interactive.usebuiltin setting
  built-in add -p: implement the "stash" and "reset" patch modes
  built-in add -p: prepare for patch modes other than "stage"

1  2 
add-interactive.c
builtin/add.c
builtin/commit.c
builtin/stash.c
git-legacy-stash.sh

Simple merge
diff --cc builtin/add.c
index 4c38aff41957a07cc52eee8ac64bbb4afe2969e4,b5927105aaae691246103dc6caeab7d63377db38..f7e627f3b9ba80ada06e988d89862996e5e0e72b
@@@ -29,8 -29,7 +29,9 @@@ static const char * const builtin_add_u
  static int patch_interactive, add_interactive, edit_interactive;
  static int take_worktree_changes;
  static int add_renormalize;
 +static int pathspec_file_nul;
 +static const char *pathspec_from_file;
+ static int legacy_stash_p; /* support for the scripted `git stash` */
  
  struct update_callback_data {
        int flags;
@@@ -327,8 -339,8 +341,10 @@@ static struct option builtin_add_option
                   N_("override the executable bit of the listed files")),
        OPT_HIDDEN_BOOL(0, "warn-embedded-repo", &warn_on_embedded_repo,
                        N_("warn when adding an embedded repository")),
+       OPT_HIDDEN_BOOL(0, "legacy-stash-p", &legacy_stash_p,
+                       N_("backend for `git stash -p`")),
 +      OPT_PATHSPEC_FROM_FILE(&pathspec_from_file),
 +      OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul),
        OPT_END(),
  };
  
@@@ -423,17 -435,22 +439,28 @@@ int cmd_add(int argc, const char **argv
                          builtin_add_usage, PARSE_OPT_KEEP_ARGV0);
        if (patch_interactive)
                add_interactive = 1;
 -      if (add_interactive)
 +      if (add_interactive) {
 +              if (pathspec_from_file)
 +                      die(_("--pathspec-from-file is incompatible with --interactive/--patch"));
                exit(interactive_add(argc - 1, argv + 1, prefix, patch_interactive));
 +      }
+       if (legacy_stash_p) {
+               struct pathspec pathspec;
+               parse_pathspec(&pathspec, 0,
+                       PATHSPEC_PREFER_FULL |
+                       PATHSPEC_SYMLINK_LEADING_PATH |
+                       PATHSPEC_PREFIX_ORIGIN,
+                       prefix, argv);
+               return run_add_interactive(NULL, "--patch=stash", &pathspec);
+       }
  
 -      if (edit_interactive)
 +      if (edit_interactive) {
 +              if (pathspec_from_file)
 +                      die(_("--pathspec-from-file is incompatible with --edit"));
                return(edit_patch(argc, argv, prefix));
 +      }
        argc--;
        argv++;
  
Simple merge
diff --cc builtin/stash.c
Simple merge
Simple merge