6 my $repo = Git
->repository();
8 my $menu_use_color = $repo->get_colorbool('color.interactive');
9 my ($prompt_color, $header_color, $help_color) =
11 $repo->get_color('color.interactive.prompt', 'bold blue'),
12 $repo->get_color('color.interactive.header', 'bold'),
13 $repo->get_color('color.interactive.help', 'red bold'),
16 my $diff_use_color = $repo->get_colorbool('color.diff');
17 my ($fraginfo_color) =
19 $repo->get_color('color.diff.frag', 'cyan'),
21 my ($diff_plain_color) =
23 $repo->get_color('color.diff.plain', ''),
25 my ($diff_old_color) =
27 $repo->get_color('color.diff.old', 'red'),
29 my ($diff_new_color) =
31 $repo->get_color('color.diff.new', 'green'),
34 my $normal_color = $repo->get_color("", "reset");
38 my $string = join("", @_);
41 # Put a color code at the beginning of each line, a reset at the end
42 # color after newlines that are not at the end of the string
43 $string =~ s/(\n+)(.)/$1$color$2/g;
44 # reset before newlines
45 $string =~ s/(\n+)/$normal_color$1/g;
46 # codes at beginning and end (if necessary):
47 $string =~ s/^/$color/;
48 $string =~ s/$/$normal_color/ unless $string =~ /\n$/;
53 # command line options
57 if ($^O
eq 'MSWin32' || $^O
eq 'msys') {
58 my @invalid = grep {m/[":*]/} @_;
59 die "$^O does not support: @invalid\n" if @invalid;
60 my @args = map { m/ /o ?
"\"$_\"": $_ } @_;
64 open($fh, '-|', @_) or die;
69 my ($GIT_DIR) = run_cmd_pipe
(qw(git rev-parse --git-dir));
71 if (!defined $GIT_DIR) {
72 exit(1); # rev-parse would have already said "not a git repo"
78 open $fh, 'git update-index --refresh |'
81 ;# ignore 'needs update'
91 run_cmd_pipe
(qw(git ls-files --others --exclude-standard --), @ARGV);
94 my $status_fmt = '%12s %12s %s';
95 my $status_head = sprintf($status_fmt, 'staged', 'unstaged', 'path');
99 sub is_initial_commit
{
100 $initial = system('git rev-parse HEAD -- >/dev/null 2>&1') != 0
101 unless defined $initial;
107 return '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
110 # Returns list of hashes, contents of each of which are:
112 # BINARY: is a binary path
113 # INDEX: is index different from HEAD?
114 # FILE: is file different from index?
115 # INDEX_ADDDEL: is it add/delete between HEAD and index?
116 # FILE_ADDDEL: is it add/delete between index and file?
121 my ($add, $del, $adddel, $file);
127 } run_cmd_pipe
(qw(git ls-files --exclude-standard --), @ARGV);
128 return if (!@tracked);
131 my $reference = is_initial_commit
() ? get_empty_tree
() : 'HEAD';
132 for (run_cmd_pipe
(qw(git diff-index --cached
133 --numstat --summary), $reference,
135 if (($add, $del, $file) =
136 /^([-\d]+) ([-\d]+) (.*)/) {
138 if ($add eq '-' && $del eq '-') {
143 $change = "+$add/-$del";
151 elsif (($adddel, $file) =
152 /^ (create|delete) mode [0-7]+ (.*)$/) {
153 $data{$file}{INDEX_ADDDEL
} = $adddel;
157 for (run_cmd_pipe
(qw(git diff-files --numstat --summary --), @tracked)) {
158 if (($add, $del, $file) =
159 /^([-\d]+) ([-\d]+) (.*)/) {
160 if (!exists $data{$file}) {
162 INDEX
=> 'unchanged',
167 if ($add eq '-' && $del eq '-') {
172 $change = "+$add/-$del";
174 $data{$file}{FILE
} = $change;
176 $data{$file}{BINARY
} = 1;
179 elsif (($adddel, $file) =
180 /^ (create|delete) mode [0-7]+ (.*)$/) {
181 $data{$file}{FILE_ADDDEL
} = $adddel;
185 for (sort keys %data) {
189 if ($only eq 'index-only') {
190 next if ($it->{INDEX
} eq 'unchanged');
192 if ($only eq 'file-only') {
193 next if ($it->{FILE
} eq 'nothing');
205 my ($string, @stuff) = @_;
207 for (my $i = 0; $i < @stuff; $i++) {
211 if ((ref $it) eq 'ARRAY') {
219 if ($it =~ /^$string/) {
223 if (defined $hit && defined $found) {
233 # inserts string into trie and updates count for each character
235 my ($trie, $string) = @_;
236 foreach (split //, $string) {
237 $trie = $trie->{$_} ||= {COUNT
=> 0};
242 # returns an array of tuples (prefix, remainder)
243 sub find_unique_prefixes
{
247 # any single prefix exceeding the soft limit is omitted
248 # if any prefix exceeds the hard limit all are omitted
249 # 0 indicates no limit
253 # build a trie modelling all possible options
255 foreach my $print (@stuff) {
256 if ((ref $print) eq 'ARRAY') {
257 $print = $print->[0];
259 elsif ((ref $print) eq 'HASH') {
260 $print = $print->{VALUE
};
262 update_trie
(\
%trie, $print);
263 push @return, $print;
266 # use the trie to find the unique prefixes
267 for (my $i = 0; $i < @return; $i++) {
268 my $ret = $return[$i];
269 my @letters = split //, $ret;
271 my ($prefix, $remainder);
273 for ($j = 0; $j < @letters; $j++) {
274 my $letter = $letters[$j];
275 if ($search{$letter}{COUNT
} == 1) {
276 $prefix = substr $ret, 0, $j + 1;
277 $remainder = substr $ret, $j + 1;
281 my $prefix = substr $ret, 0, $j;
283 if ($hard_limit && $j + 1 > $hard_limit);
285 %search = %{$search{$letter}};
287 if ($soft_limit && $j + 1 > $soft_limit) {
291 $return[$i] = [$prefix, $remainder];
296 # filters out prefixes which have special meaning to list_and_choose()
297 sub is_valid_prefix
{
299 return (defined $prefix) &&
300 !($prefix =~ /[\s,]/) && # separators
301 !($prefix =~ /^-/) && # deselection
302 !($prefix =~ /^\d+/) && # selection
303 ($prefix ne '*') && # "all" wildcard
304 ($prefix ne '?'); # prompt help
307 # given a prefix/remainder tuple return a string with the prefix highlighted
308 # for now use square brackets; later might use ANSI colors (underline, bold)
309 sub highlight_prefix
{
311 my $remainder = shift;
313 if (!defined $prefix) {
317 if (!is_valid_prefix
($prefix)) {
318 return "$prefix$remainder";
321 if (!$menu_use_color) {
322 return "[$prefix]$remainder";
325 return "$prompt_color$prefix$normal_color$remainder";
328 sub list_and_choose
{
329 my ($opts, @stuff) = @_;
330 my (@chosen, @return);
332 my @prefixes = find_unique_prefixes
(@stuff) unless $opts->{LIST_ONLY
};
338 if ($opts->{HEADER
}) {
339 if (!$opts->{LIST_FLAT
}) {
342 print colored
$header_color, "$opts->{HEADER}\n";
344 for ($i = 0; $i < @stuff; $i++) {
345 my $chosen = $chosen[$i] ?
'*' : ' ';
346 my $print = $stuff[$i];
347 my $ref = ref $print;
348 my $highlighted = highlight_prefix
(@
{$prefixes[$i]})
350 if ($ref eq 'ARRAY') {
351 $print = $highlighted || $print->[0];
353 elsif ($ref eq 'HASH') {
354 my $value = $highlighted || $print->{VALUE
};
355 $print = sprintf($status_fmt,
361 $print = $highlighted || $print;
363 printf("%s%2d: %s", $chosen, $i+1, $print);
364 if (($opts->{LIST_FLAT
}) &&
365 (($i + 1) % ($opts->{LIST_FLAT
}))) {
378 return if ($opts->{LIST_ONLY
});
380 print colored
$prompt_color, $opts->{PROMPT
};
381 if ($opts->{SINGLETON
}) {
390 $opts->{ON_EOF
}->() if $opts->{ON_EOF
};
397 singleton_prompt_help_cmd
() :
401 for my $choice (split(/[\s,]+/, $line)) {
405 # Input that begins with '-'; unchoose
406 if ($choice =~ s/^-//) {
409 # A range can be specified like 5-7 or 5-.
410 if ($choice =~ /^(\d+)-(\d*)$/) {
411 ($bottom, $top) = ($1, length($2) ?
$2 : 1 + @stuff);
413 elsif ($choice =~ /^\d+$/) {
414 $bottom = $top = $choice;
416 elsif ($choice eq '*') {
421 $bottom = $top = find_unique
($choice, @stuff);
422 if (!defined $bottom) {
423 print "Huh ($choice)?\n";
427 if ($opts->{SINGLETON
} && $bottom != $top) {
428 print "Huh ($choice)?\n";
431 for ($i = $bottom-1; $i <= $top-1; $i++) {
432 next if (@stuff <= $i || $i < 0);
433 $chosen[$i] = $choose;
436 last if ($opts->{IMMEDIATE
} || $line eq '*');
438 for ($i = 0; $i < @stuff; $i++) {
440 push @return, $stuff[$i];
446 sub singleton_prompt_help_cmd
{
447 print colored
$help_color, <<\EOF
;
449 1 - select a numbered item
450 foo
- select item based on unique prefix
451 - (empty
) select nothing
455 sub prompt_help_cmd
{
456 print colored
$help_color, <<\EOF
;
458 1 - select a single item
459 3-5 - select a range of items
460 2-3,6-9 - select multiple ranges
461 foo
- select item based on unique prefix
462 -... - unselect specified items
464 - (empty
) finish selecting
469 list_and_choose
({ LIST_ONLY
=> 1, HEADER
=> $status_head },
479 print "$cnt paths\n";
487 my @mods = list_modified
('file-only');
490 my @update = list_and_choose
({ PROMPT
=> 'Update',
491 HEADER
=> $status_head, },
494 system(qw(git update-index --add --remove --),
495 map { $_->{VALUE
} } @update);
496 say_n_paths
('updated', @update);
502 my @update = list_and_choose
({ PROMPT
=> 'Revert',
503 HEADER
=> $status_head, },
506 if (is_initial_commit
()) {
507 system(qw(git rm --cached),
508 map { $_->{VALUE
} } @update);
511 my @lines = run_cmd_pipe
(qw(git ls-tree HEAD --),
512 map { $_->{VALUE
} } @update);
514 open $fh, '| git update-index --index-info'
521 if ($_->{INDEX_ADDDEL
} &&
522 $_->{INDEX_ADDDEL
} eq 'create') {
523 system(qw(git update-index --force-remove --),
525 print "note: $_->{VALUE} is untracked now.\n";
530 say_n_paths
('reverted', @update);
535 sub add_untracked_cmd
{
536 my @add = list_and_choose
({ PROMPT
=> 'Add untracked' },
539 system(qw(git update-index --add --), @add);
540 say_n_paths
('added', @add);
547 my @diff = run_cmd_pipe
(qw(git diff-files -p --), $path);
549 if ($diff_use_color) {
550 @colored = run_cmd_pipe
(qw(git diff-files -p --color --), $path);
552 my (@hunk) = { TEXT
=> [], DISPLAY
=> [] };
554 for (my $i = 0; $i < @diff; $i++) {
555 if ($diff[$i] =~ /^@@ /) {
556 push @hunk, { TEXT
=> [], DISPLAY
=> [] };
558 push @
{$hunk[-1]{TEXT
}}, $diff[$i];
559 push @
{$hunk[-1]{DISPLAY
}},
560 ($diff_use_color ?
$colored[$i] : $diff[$i]);
565 sub parse_diff_header
{
568 my $head = { TEXT
=> [], DISPLAY
=> [] };
569 my $mode = { TEXT
=> [], DISPLAY
=> [] };
571 for (my $i = 0; $i < @
{$src->{TEXT
}}; $i++) {
572 my $dest = $src->{TEXT
}->[$i] =~ /^(old|new) mode (\d+)$/ ?
574 push @
{$dest->{TEXT
}}, $src->{TEXT
}->[$i];
575 push @
{$dest->{DISPLAY
}}, $src->{DISPLAY
}->[$i];
577 return ($head, $mode);
580 sub hunk_splittable
{
583 my @s = split_hunk
($text);
587 sub parse_hunk_header
{
589 my ($o_ofs, $o_cnt, $n_ofs, $n_cnt) =
590 $line =~ /^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/;
591 $o_cnt = 1 unless defined $o_cnt;
592 $n_cnt = 1 unless defined $n_cnt;
593 return ($o_ofs, $o_cnt, $n_ofs, $n_cnt);
597 my ($text, $display) = @_;
599 if (!defined $display) {
602 # If there are context lines in the middle of a hunk,
603 # it can be split, but we would need to take care of
606 my ($o_ofs, undef, $n_ofs) = parse_hunk_header
($text->[0]);
611 my $next_hunk_start = undef;
612 my $i = $hunk_start - 1;
625 while (++$i < @
$text) {
626 my $line = $text->[$i];
627 my $display = $display->[$i];
629 if ($this->{ADDDEL
} &&
630 !defined $next_hunk_start) {
631 # We have seen leading context and
632 # adds/dels and then here is another
633 # context, which is trailing for this
634 # split hunk and leading for the next
636 $next_hunk_start = $i;
638 push @
{$this->{TEXT
}}, $line;
639 push @
{$this->{DISPLAY
}}, $display;
642 if (defined $next_hunk_start) {
649 if (defined $next_hunk_start) {
650 # We are done with the current hunk and
651 # this is the first real change for the
653 $hunk_start = $next_hunk_start;
654 $o_ofs = $this->{OLD
} + $this->{OCNT
};
655 $n_ofs = $this->{NEW
} + $this->{NCNT
};
656 $o_ofs -= $this->{POSTCTX
};
657 $n_ofs -= $this->{POSTCTX
};
661 push @
{$this->{TEXT
}}, $line;
662 push @
{$this->{DISPLAY
}}, $display;
676 for my $hunk (@split) {
677 $o_ofs = $hunk->{OLD
};
678 $n_ofs = $hunk->{NEW
};
679 my $o_cnt = $hunk->{OCNT
};
680 my $n_cnt = $hunk->{NCNT
};
682 my $head = ("@@ -$o_ofs" .
683 (($o_cnt != 1) ?
",$o_cnt" : '') .
685 (($n_cnt != 1) ?
",$n_cnt" : '') .
687 my $display_head = $head;
688 unshift @
{$hunk->{TEXT
}}, $head;
689 if ($diff_use_color) {
690 $display_head = colored
($fraginfo_color, $head);
692 unshift @
{$hunk->{DISPLAY
}}, $display_head;
700 colored
((/^@/ ?
$fraginfo_color :
701 /^\+/ ?
$diff_new_color :
702 /^-/ ?
$diff_old_color :
708 sub edit_hunk_manually
{
711 my $hunkfile = $repo->repo_path . "/addp-hunk-edit.diff";
713 open $fh, '>', $hunkfile
714 or die "failed to open hunk edit file for writing: " . $!;
715 print $fh "# Manual hunk edit mode -- see bottom for a quick guide\n";
719 # To remove '-' lines, make them ' ' lines (context).
720 # To remove '+' lines, delete them.
721 # Lines starting with # will be removed.
723 # If the patch applies cleanly, the edited hunk will immediately be
724 # marked for staging. If it does not apply cleanly, you will be given
725 # an opportunity to edit again. If all lines of the hunk are removed,
726 # then the edit is aborted and the hunk is left unchanged.
730 my $editor = $ENV{GIT_EDITOR
} || $repo->config("core.editor")
731 || $ENV{VISUAL
} || $ENV{EDITOR
} || "vi";
732 system('sh', '-c', $editor.' "$@"', $editor, $hunkfile);
734 open $fh, '<', $hunkfile
735 or die "failed to open hunk edit file for reading: " . $!;
736 my @newtext = grep { !/^#/ } <$fh>;
740 # Abort if nothing remains
741 if (!grep { /\S/ } @newtext) {
745 # Reinsert the first hunk header if the user accidentally deleted it
746 if ($newtext[0] !~ /^@/) {
747 unshift @newtext, $oldtext->[0];
754 open $fh, '| git apply --recount --cached --check';
756 print $fh @
{$h->{TEXT
}};
764 print colored
$prompt_color, $prompt;
766 return 0 if $line =~ /^n/i;
767 return 1 if $line =~ /^y/i;
772 my ($head, $hunk, $ix) = @_;
773 my $text = $hunk->[$ix]->{TEXT
};
776 $text = edit_hunk_manually
($text);
777 if (!defined $text) {
780 my $newhunk = { TEXT
=> $text, USE
=> 1 };
781 if (diff_applies
($head,
784 @
{$hunk}[$ix+1..$#{$hunk}])) {
785 $newhunk->{DISPLAY
} = [color_diff
(@
{$text})];
790 'Your edited hunk does not apply. Edit again '
791 . '(saying "no" discards!) [y/n]? '
798 print colored
$help_color, <<\EOF
;
800 n
- do not stage this hunk
801 a
- stage this
and all the remaining hunks
in the file
802 d
- do not stage this hunk nor any of the remaining hunks
in the file
803 g
- select a hunk to go to
804 / - search
for a hunk matching the
given regex
805 j
- leave this hunk undecided
, see
next undecided hunk
806 J
- leave this hunk undecided
, see
next hunk
807 k
- leave this hunk undecided
, see previous undecided hunk
808 K
- leave this hunk undecided
, see previous hunk
809 s
- split the current hunk into smaller hunks
810 e
- manually edit the current hunk
815 sub patch_update_cmd
{
816 my @all_mods = list_modified
('file-only');
817 my @mods = grep { !($_->{BINARY
}) } @all_mods;
822 print STDERR
"Only binary files changed.\n";
824 print STDERR
"No changes.\n";
832 @them = list_and_choose
({ PROMPT
=> 'Patch update',
833 HEADER
=> $status_head, },
837 patch_update_file
($_->{VALUE
});
841 # Generate a one line summary of a hunk.
844 my $summary = $rhunk->{TEXT
}[0];
846 # Keep the line numbers, discard extra context.
847 $summary =~ s/@@(.*?)@@.*/$1 /s;
848 $summary .= " " x
(20 - length $summary);
850 # Add some user context.
851 for my $line (@
{$rhunk->{TEXT
}}) {
852 if ($line =~ m/^[+-].*\w/) {
859 return substr($summary, 0, 80) . "\n";
863 # Print a one-line summary of each hunk in the array ref in
864 # the first argument, starting wih the index in the 2nd.
866 my ($hunks, $i) = @_;
869 for (; $i < @
$hunks && $ctr < 20; $i++, $ctr++) {
871 if (defined $hunks->[$i]{USE
}) {
872 $status = $hunks->[$i]{USE
} ?
"+" : "-";
877 summarize_hunk
($hunks->[$i]);
882 sub patch_update_file
{
885 my ($head, @hunk) = parse_diff
($path);
886 ($head, my $mode) = parse_diff_header
($head);
887 for (@
{$head->{DISPLAY
}}) {
891 if (@
{$mode->{TEXT
}}) {
893 print @
{$mode->{DISPLAY
}};
894 print colored
$prompt_color,
895 "Stage mode change [y/n/a/d/?]? ";
897 if ($line =~ /^y/i) {
901 elsif ($line =~ /^n/i) {
905 elsif ($line =~ /^a/i) {
906 $_->{USE
} = 1 foreach ($mode, @hunk);
909 elsif ($line =~ /^d/i) {
910 $_->{USE
} = 0 foreach ($mode, @hunk);
924 my ($prev, $next, $other, $undecided, $i);
930 for ($i = 0; $i < $ix; $i++) {
931 if (!defined $hunk[$i]{USE
}) {
940 for ($i = $ix + 1; $i < $num; $i++) {
941 if (!defined $hunk[$i]{USE
}) {
947 if ($ix < $num - 1) {
953 for ($i = 0; $i < $num; $i++) {
954 if (!defined $hunk[$i]{USE
}) {
959 last if (!$undecided);
961 if (hunk_splittable
($hunk[$ix]{TEXT
})) {
965 for (@
{$hunk[$ix]{DISPLAY
}}) {
968 print colored
$prompt_color, "Stage this hunk [y,n,a,d,/$other,?]? ";
971 if ($line =~ /^y/i) {
974 elsif ($line =~ /^n/i) {
977 elsif ($line =~ /^a/i) {
979 if (!defined $hunk[$ix]{USE
}) {
986 elsif ($other =~ /g/ && $line =~ /^g(.*)/) {
988 my $no = $ix > 10 ?
$ix - 10 : 0;
989 while ($response eq '') {
991 $no = display_hunks
(\
@hunk, $no);
993 $extra = " (<ret> to see more)";
995 print "go to which hunk$extra? ";
997 if (!defined $response) {
1002 if ($response !~ /^\s*\d+\s*$/) {
1003 print STDERR
"Invalid number: '$response'\n";
1004 } elsif (0 < $response && $response <= $num) {
1005 $ix = $response - 1;
1007 print STDERR
"Sorry, only $num hunks available.\n";
1011 elsif ($line =~ /^d/i) {
1012 while ($ix < $num) {
1013 if (!defined $hunk[$ix]{USE
}) {
1014 $hunk[$ix]{USE
} = 0;
1020 elsif ($line =~ m
|^/(.*)|) {
1023 $search_string = qr{$1}m;
1026 my ($err,$exp) = ($@
, $1);
1027 $err =~ s/ at .*git-add--interactive line \d+, <STDIN> line \d+.*$//;
1028 print STDERR
"Malformed search regexp $exp: $err\n";
1033 my $text = join ("", @
{$hunk[$iy]{TEXT
}});
1034 last if ($text =~ $search_string);
1036 $iy = 0 if ($iy >= $num);
1038 print STDERR
"No hunk matches the given pattern\n";
1045 elsif ($line =~ /^K/) {
1046 if ($other =~ /K/) {
1050 print STDERR
"No previous hunk\n";
1054 elsif ($line =~ /^J/) {
1055 if ($other =~ /J/) {
1059 print STDERR
"No next hunk\n";
1063 elsif ($line =~ /^k/) {
1064 if ($other =~ /k/) {
1068 !defined $hunk[$ix]{USE
});
1072 print STDERR
"No previous hunk\n";
1076 elsif ($line =~ /^j/) {
1077 if ($other !~ /j/) {
1078 print STDERR
"No next hunk\n";
1082 elsif ($other =~ /s/ && $line =~ /^s/) {
1083 my @split = split_hunk
($hunk[$ix]{TEXT
}, $hunk[$ix]{DISPLAY
});
1085 print colored
$header_color, "Split into ",
1086 scalar(@split), " hunks.\n";
1088 splice (@hunk, $ix, 1, @split);
1089 $num = scalar @hunk;
1092 elsif ($line =~ /^e/) {
1093 my $newhunk = edit_hunk_loop
($head, \
@hunk, $ix);
1094 if (defined $newhunk) {
1095 splice @hunk, $ix, 1, $newhunk;
1099 help_patch_cmd
($other);
1105 last if ($ix >= $num ||
1106 !defined $hunk[$ix]{USE
});
1114 push @result, @
{$mode->{TEXT
}};
1118 push @result, @
{$_->{TEXT
}};
1125 open $fh, '| git apply --cached --recount';
1126 for (@
{$head->{TEXT
}}, @result) {
1130 for (@
{$head->{TEXT
}}, @result) {
1141 my @mods = list_modified
('index-only');
1142 @mods = grep { !($_->{BINARY
}) } @mods;
1144 my (@them) = list_and_choose
({ PROMPT
=> 'Review diff',
1146 HEADER
=> $status_head, },
1149 my $reference = is_initial_commit
() ? get_empty_tree
() : 'HEAD';
1150 system(qw(git diff -p --cached), $reference, '--',
1151 map { $_->{VALUE
} } @them);
1160 print colored
$help_color, <<\EOF
;
1161 status
- show paths with changes
1162 update
- add working tree
state to the staged set of changes
1163 revert
- revert staged set of changes back to the HEAD version
1164 patch
- pick hunks
and update selectively
1165 diff
- view diff between HEAD
and index
1166 add untracked
- add contents of untracked files to the staged set of changes
1171 return unless @ARGV;
1172 my $arg = shift @ARGV;
1173 if ($arg eq "--patch") {
1175 $arg = shift @ARGV or die "missing --";
1176 die "invalid argument $arg, expecting --"
1177 unless $arg eq "--";
1179 elsif ($arg ne "--") {
1180 die "invalid argument $arg, expecting --";
1185 my @cmd = ([ 'status', \
&status_cmd
, ],
1186 [ 'update', \
&update_cmd
, ],
1187 [ 'revert', \
&revert_cmd
, ],
1188 [ 'add untracked', \
&add_untracked_cmd
, ],
1189 [ 'patch', \
&patch_update_cmd
, ],
1190 [ 'diff', \
&diff_cmd
, ],
1191 [ 'quit', \
&quit_cmd
, ],
1192 [ 'help', \
&help_cmd
, ],
1195 my ($it) = list_and_choose
({ PROMPT
=> 'What now',
1198 HEADER
=> '*** Commands ***',
1199 ON_EOF
=> \
&quit_cmd
,
1200 IMMEDIATE
=> 1 }, @cmd);