is_ntfs_dotgit: match other .git files
[gitweb.git] / git-add--interactive.perl
index 395dd5eb4b83377f59b486f7b483bf2103efcdec..daef1c14fb099261a2ee49900c1434def9d7f415 100755 (executable)
@@ -3,7 +3,7 @@
 use 5.008;
 use strict;
 use warnings;
-use Git;
+use Git qw(unquote_path);
 use Git::I18N;
 
 binmode(STDOUT, ":raw");
@@ -47,7 +47,6 @@
 
 my $diff_algorithm = $repo->config('diff.algorithm');
 my $diff_indent_heuristic = $repo->config_bool('diff.indentheuristic');
-my $diff_compaction_heuristic = $repo->config_bool('diff.compactionheuristic');
 my $diff_filter = $repo->config('interactive.difffilter');
 
 my $use_readkey = 0;
@@ -93,7 +92,7 @@ sub colored {
 }
 
 # command line options
-my $cmd;
+my $patch_mode_only;
 my $patch_mode;
 my $patch_mode_revision;
 
@@ -176,47 +175,6 @@ sub run_cmd_pipe {
 }
 chomp($GIT_DIR);
 
-my %cquote_map = (
- "b" => chr(8),
- "t" => chr(9),
- "n" => chr(10),
- "v" => chr(11),
- "f" => chr(12),
- "r" => chr(13),
- "\\" => "\\",
- "\042" => "\042",
-);
-
-sub unquote_path {
-       local ($_) = @_;
-       my ($retval, $remainder);
-       if (!/^\042(.*)\042$/) {
-               return $_;
-       }
-       ($_, $retval) = ($1, "");
-       while (/^([^\\]*)\\(.*)$/) {
-               $remainder = $2;
-               $retval .= $1;
-               for ($remainder) {
-                       if (/^([0-3][0-7][0-7])(.*)$/) {
-                               $retval .= chr(oct($1));
-                               $_ = $2;
-                               last;
-                       }
-                       if (/^([\\\042btnvfr])(.*)$/) {
-                               $retval .= $cquote_map{$1};
-                               $_ = $2;
-                               last;
-                       }
-                       # This is malformed -- just return it as-is for now.
-                       return $_[0];
-               }
-               $_ = $remainder;
-       }
-       $retval .= $_;
-       return $retval;
-}
-
 sub refresh {
        my $fh;
        open $fh, 'git update-index --refresh |'
@@ -276,20 +234,11 @@ sub list_modified {
        my ($only) = @_;
        my (%data, @return);
        my ($add, $del, $adddel, $file);
-       my @tracked = ();
-
-       if (@ARGV) {
-               @tracked = map {
-                       chomp $_;
-                       unquote_path($_);
-               } run_cmd_pipe(qw(git ls-files --), @ARGV);
-               return if (!@tracked);
-       }
 
        my $reference = get_diff_reference($patch_mode_revision);
        for (run_cmd_pipe(qw(git diff-index --cached
                             --numstat --summary), $reference,
-                            '--', @tracked)) {
+                            '--', @ARGV)) {
                if (($add, $del, $file) =
                    /^([-\d]+)  ([-\d]+)        (.*)/) {
                        my ($change, $bin);
@@ -314,7 +263,7 @@ sub list_modified {
                }
        }
 
-       for (run_cmd_pipe(qw(git diff-files --numstat --summary --raw --), @tracked)) {
+       for (run_cmd_pipe(qw(git diff-files --numstat --summary --raw --), @ARGV)) {
                if (($add, $del, $file) =
                    /^([-\d]+)  ([-\d]+)        (.*)/) {
                        $file = unquote_path($file);
@@ -742,8 +691,6 @@ sub parse_diff {
        }
        if ($diff_indent_heuristic) {
                splice @diff_cmd, 1, 0, "--indent-heuristic";
-       } elsif ($diff_compaction_heuristic) {
-               splice @diff_cmd, 1, 0, "--compaction-heuristic";
        }
        if (defined $patch_mode_revision) {
                push @diff_cmd, get_diff_reference($patch_mode_revision);
@@ -1052,7 +999,7 @@ sub color_diff {
 marked for applying."),
        checkout_index => N__(
 "If the patch applies cleanly, the edited hunk will immediately be
-marked for discarding"),
+marked for discarding."),
        checkout_head => N__(
 "If the patch applies cleanly, the edited hunk will immediately be
 marked for discarding."),
@@ -1303,7 +1250,7 @@ sub patch_update_cmd {
                }
                return 0;
        }
-       if ($patch_mode) {
+       if ($patch_mode_only) {
                @them = @mods;
        }
        else {
@@ -1682,7 +1629,7 @@ sub help_cmd {
 update        - add working tree state to the staged set of changes
 revert        - revert staged set of changes back to the HEAD version
 patch         - pick hunks and update selectively
-diff         - view diff between HEAD and index
+diff          - view diff between HEAD and index
 add untracked - add contents of untracked files to the staged set of changes
 EOF
 }
@@ -1725,7 +1672,7 @@ sub process_args {
                die sprintf(__("invalid argument %s, expecting --"),
                               $arg) unless $arg eq "--";
                %patch_mode_flavour = %{$patch_modes{$patch_mode}};
-               $cmd = 1;
+               $patch_mode_only = 1;
        }
        elsif ($arg ne "--") {
                die sprintf(__("invalid argument %s, expecting --"), $arg);
@@ -1762,7 +1709,7 @@ sub main_loop {
 
 process_args();
 refresh();
-if ($cmd) {
+if ($patch_mode_only) {
        patch_update_cmd();
 }
 else {