remote: refactor some logic into get_stale_heads()
[gitweb.git] / git-add--interactive.perl
index 21746d5f2834833a49379b4f23160d65fe2501ba..392efb913f7c2ff13bbbb46e4414325b71e07676 100755 (executable)
@@ -76,6 +76,7 @@ sub colored {
 
 sub apply_patch;
 sub apply_patch_for_checkout_commit;
+sub apply_patch_for_stash;
 
 my %patch_modes = (
        'stage' => {
@@ -87,6 +88,15 @@ sub colored {
                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', @_; },
@@ -923,6 +933,10 @@ sub coalesce_overlapping_hunks {
        my ($last_o_ctx, $last_was_dirty);
 
        for (grep { $_->{USE} } @in) {
+               if ($_->{TYPE} ne 'hunk') {
+                       push @out, $_;
+                       next;
+               }
                my $text = $_->{TEXT};
                my ($o_ofs) = parse_hunk_header($text->[0]);
                if (defined $last_o_ctx &&
@@ -1493,8 +1507,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";