summaryrefslogtreecommitdiff
path: root/git-add--interactive.perl
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2009-08-13 12:29:44 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-08-15 22:19:31 (GMT)
commitdda1f2a5c3aca5072aada32eef159067ba16f0e9 (patch)
tree02fc359424824fd005e183044e2bc2a9d14df930 /git-add--interactive.perl
parent4f353658b9c15e9188530fac5ae79d0aa1538e85 (diff)
downloadgit-dda1f2a5c3aca5072aada32eef159067ba16f0e9.zip
git-dda1f2a5c3aca5072aada32eef159067ba16f0e9.tar.gz
git-dda1f2a5c3aca5072aada32eef159067ba16f0e9.tar.bz2
Implement 'git stash save --patch'
This adds a hunk-based mode to git-stash. You can select hunks from the difference between HEAD and worktree, and git-stash will build a stash that reflects these changes. The index state of the stash is the same as your current index, and we also let --patch imply --keep-index. Note that because the selected hunks are rolled back from the worktree but not the index, the resulting state may appear somewhat confusing if you had also staged these changes. This is not entirely satisfactory, but due to the way stashes are applied, other solutions would require a change to the stash format. Signed-off-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-xgit-add--interactive.perl14
1 files changed, 12 insertions, 2 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 21746d5..8f66b82 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -76,6 +76,7 @@ my $patch_mode_revision;
sub apply_patch;
sub apply_patch_for_checkout_commit;
+sub apply_patch_for_stash;
my %patch_modes = (
'stage' => {
@@ -87,6 +88,15 @@ my %patch_modes = (
PARTICIPLE => 'staging',
FILTER => 'file-only',
},
+ 'stash' => {
+ DIFF => 'diff-index -p HEAD',
+ APPLY => sub { apply_patch 'apply --cached', @_; },
+ APPLY_CHECK => 'apply --cached',
+ VERB => 'Stash',
+ TARGET => '',
+ PARTICIPLE => 'stashing',
+ FILTER => undef,
+ },
'reset_head' => {
DIFF => 'diff-index -p --cached',
APPLY => sub { apply_patch 'apply -R --cached', @_; },
@@ -1493,8 +1503,8 @@ sub process_args {
'checkout_head' : 'checkout_nothead');
$arg = shift @ARGV or die "missing --";
}
- } elsif ($1 eq 'stage') {
- $patch_mode = 'stage';
+ } elsif ($1 eq 'stage' or $1 eq 'stash') {
+ $patch_mode = $1;
$arg = shift @ARGV or die "missing --";
} else {
die "unknown --patch mode: $1";