test/send-email: --[no-]xmailer tests
[gitweb.git] / git-add--interactive.perl
index 51563840f49089cf250992fd47fe70a45cef0c52..1fadd69f8809f91337a27b98f244a3cf7183b23f 100755 (executable)
@@ -58,6 +58,9 @@
                Term::ReadKey->import;
                $use_readkey = 1;
        };
+       if (!$use_readkey) {
+               print STDERR "missing Term::ReadKey, disabling interactive.singlekey\n";
+       }
        eval {
                require Term::Cap;
                my $termcap = Term::Cap->Tgetent;
@@ -263,6 +266,17 @@ sub get_empty_tree {
        return '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
 }
 
+sub get_diff_reference {
+       my $ref = shift;
+       if (defined $ref and $ref ne 'HEAD') {
+               return $ref;
+       } elsif (is_initial_commit()) {
+               return get_empty_tree();
+       } else {
+               return 'HEAD';
+       }
+}
+
 # Returns list of hashes, contents of each of which are:
 # VALUE:       pathname
 # BINARY:      is a binary path
@@ -286,14 +300,7 @@ sub list_modified {
                return if (!@tracked);
        }
 
-       my $reference;
-       if (defined $patch_mode_revision and $patch_mode_revision ne 'HEAD') {
-               $reference = $patch_mode_revision;
-       } elsif (is_initial_commit()) {
-               $reference = get_empty_tree();
-       } else {
-               $reference = 'HEAD';
-       }
+       my $reference = get_diff_reference($patch_mode_revision);
        for (run_cmd_pipe(qw(git diff-index --cached
                             --numstat --summary), $reference,
                             '--', @tracked)) {
@@ -737,7 +744,7 @@ sub parse_diff {
                splice @diff_cmd, 1, 0, "--diff-algorithm=${diff_algorithm}";
        }
        if (defined $patch_mode_revision) {
-               push @diff_cmd, $patch_mode_revision;
+               push @diff_cmd, get_diff_reference($patch_mode_revision);
        }
        my @diff = run_cmd_pipe("git", @diff_cmd, "--", $path);
        my @colored = ();
@@ -1152,9 +1159,9 @@ sub help_patch_cmd {
        print colored $help_color, <<EOF ;
 y - $verb this hunk$target
 n - do not $verb this hunk$target
-q - quit; do not $verb this hunk nor any of the remaining ones
+q - quit; do not $verb this hunk or any of the remaining ones
 a - $verb this hunk and all later hunks in the file
-d - do not $verb this hunk nor any of the later hunks in the file
+d - do not $verb this hunk or any of the later hunks in the file
 g - select a hunk to go to
 / - search for a hunk matching the given regex
 j - leave this hunk undecided, see next undecided hunk