When the "--patch" option is supplied, the patch_update_cmd() function is
called bypassing the main_loop() and exits.
Seeing as builtin-add is the only caller of git-add--interactive we can
impose a strict requirement on the format of the arguments to avoid
possible ambiguity: an "--" argument must be used whenever any pathspecs
are passed, both with the "--patch" option and without it.
Signed-off-by: Wincent Colaiuta <win@wincent.com>
maint
Wincent Colaiuta17 years agocommitted byJunio C Hamano
@ -783,6 +794,20 @@ add untracked - add contents of untracked files to the staged set of changes
@@ -783,6 +794,20 @@ add untracked - add contents of untracked files to the staged set of changes
EOF
}
sub process_args {
return unless @ARGV;
my $arg = shift @ARGV;
if ($arg eq "--patch") {
$patch_mode = 1;
$arg = shift @ARGV or die "missing --";
die "invalid argument $arg, expecting --"
unless $arg eq "--";
}
elsif ($arg ne "--") {
die "invalid argument $arg, expecting --";
}
}
sub main_loop {
my @cmd = ([ 'status', \&status_cmd, ],
[ 'update', \&update_cmd, ],
@ -811,6 +836,12 @@ sub main_loop {
@@ -811,6 +836,12 @@ sub main_loop {