aboutsummaryrefslogtreecommitdiff
path: root/builtin-reset.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2009-09-07 15:24:38 -0700
committerJunio C Hamano <gitster@pobox.com>2009-09-07 15:24:38 -0700
commit54f0bdc81103f45f12978b385a9519a235b03cc2 (patch)
treeee239eeafe0f59af72eca683e5e264b0c2a6fff5 /builtin-reset.c
parent8e4384fd4438a143af7125eb0f03312a318319fb (diff)
parent3c2eb80fe3f3c7efbb25e929df9f70d7c896a5ef (diff)
downloadgit-54f0bdc81103f45f12978b385a9519a235b03cc2.tar.gz
git-54f0bdc81103f45f12978b385a9519a235b03cc2.tar.xz
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'
Diffstat (limited to 'builtin-reset.c')
-rw-r--r--builtin-reset.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/builtin-reset.c b/builtin-reset.c
index 0fc0b0743..73e60223d 100644
--- a/builtin-reset.c
+++ b/builtin-reset.c
@@ -143,6 +143,17 @@ static void update_index_from_diff(struct diff_queue_struct *q,
}
}
+static int interactive_reset(const char *revision, const char **argv,
+ const char *prefix)
+{
+ const char **pathspec = NULL;
+
+ if (*argv)
+ pathspec = get_pathspec(prefix, argv);
+
+ return run_add_interactive(revision, "--patch=reset", pathspec);
+}
+
static int read_from_tree(const char *prefix, const char **argv,
unsigned char *tree_sha1, int refresh_flags)
{
@@ -184,6 +195,7 @@ static void prepend_reflog_action(const char *action, char *buf, size_t size)
int cmd_reset(int argc, const char **argv, const char *prefix)
{
int i = 0, reset_type = NONE, update_ref_status = 0, quiet = 0;
+ int patch_mode = 0;
const char *rev = "HEAD";
unsigned char sha1[20], *orig = NULL, sha1_orig[20],
*old_orig = NULL, sha1_old_orig[20];
@@ -199,6 +211,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
"reset HEAD, index and working tree", MERGE),
OPT_BOOLEAN('q', NULL, &quiet,
"disable showing new HEAD in hard reset and progress message"),
+ OPT_BOOLEAN('p', "patch", &patch_mode, "select hunks interactively"),
OPT_END()
};
@@ -252,6 +265,12 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
die("Could not parse object '%s'.", rev);
hashcpy(sha1, commit->object.sha1);
+ if (patch_mode) {
+ if (reset_type != NONE)
+ die("--patch is incompatible with --{hard,mixed,soft}");
+ return interactive_reset(rev, argv + i, prefix);
+ }
+
/* git reset tree [--] paths... can be used to
* load chosen paths from the tree into the index without
* affecting the working tree nor HEAD. */