From c95c02486c4dd82f8910a8de1cb7c8f9db899995 Mon Sep 17 00:00:00 2001 From: Jean-Luc Herren Date: Wed, 26 Sep 2007 15:56:19 +0200 Subject: [PATCH 1/4] git-add--interactive: Allow Ctrl-D to exit Hitting Ctrl-D (EOF) is a common way to exit shell-like tools. When in a sub-menu it will still behave as if an empty line had been entered, carrying out the action on the selected items and returning to the previous menu. Signed-off-by: Jean-Luc Herren Signed-off-by: Junio C Hamano --- git-add--interactive.perl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 7921cde8cb..f9e9f02392 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -213,7 +213,11 @@ sub list_and_choose { print ">> "; } my $line = ; - last if (!$line); + if (!$line) { + print "\n"; + $opts->{ON_EOF}->() if $opts->{ON_EOF}; + last; + } chomp $line; my $donesomething = 0; for my $choice (split(/[\s,]+/, $line)) { @@ -791,6 +795,7 @@ sub main_loop { SINGLETON => 1, LIST_FLAT => 4, HEADER => '*** Commands ***', + ON_EOF => \&quit_cmd, IMMEDIATE => 1 }, @cmd); if ($it) { eval { From 6a6eb3d09fcbfae41978fb5223ae03e2d103968b Mon Sep 17 00:00:00 2001 From: Jean-Luc Herren Date: Wed, 26 Sep 2007 16:05:01 +0200 Subject: [PATCH 2/4] git-add--interactive: Improve behavior on bogus input 1) Previously, any menu would cause a perl error when entered '0', which is never a valid option. 2) Entering a bogus choice (like 998 or 4-2) surprisingly caused the same behavior as if the user had just hit 'enter', which means to carry out the selected action on the selected items. Entering such bogus input is now a no-op and the sub-menu doesn't exit. Signed-off-by: Jean-Luc Herren Signed-off-by: Junio C Hamano --- git-add--interactive.perl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/git-add--interactive.perl b/git-add--interactive.perl index f9e9f02392..be6881496c 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -219,7 +219,7 @@ sub list_and_choose { last; } chomp $line; - my $donesomething = 0; + last if $line eq ''; for my $choice (split(/[\s,]+/, $line)) { my $choose = 1; my ($bottom, $top); @@ -251,12 +251,11 @@ sub list_and_choose { next TOPLOOP; } for ($i = $bottom-1; $i <= $top-1; $i++) { - next if (@stuff <= $i); + next if (@stuff <= $i || $i < 0); $chosen[$i] = $choose; - $donesomething++; } } - last if (!$donesomething || $opts->{IMMEDIATE}); + last if ($opts->{IMMEDIATE}); } for ($i = 0; $i < @stuff; $i++) { if ($chosen[$i]) { From 81ab1cb43a872fc527b26388bc7e781c816d723b Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 30 Sep 2007 00:34:23 +0100 Subject: [PATCH 3/4] rebase -i: squash should retain the authorship of the _first_ commit It was determined on the mailing list, that it makes more sense for a "squash" to keep the author of the first commit as the author for the result of the squash. Make it so. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Documentation/git-rebase.txt | 2 +- git-rebase--interactive.sh | 2 +- t/t3404-rebase-interactive.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt index 61b1810dba..dfb8a0da5b 100644 --- a/Documentation/git-rebase.txt +++ b/Documentation/git-rebase.txt @@ -293,7 +293,7 @@ rebasing. If you want to fold two or more commits into one, replace the command "pick" with "squash" for the second and subsequent commit. If the commits had different authors, it will attribute the squashed commit to -the author of the last commit. +the author of the first commit. In both cases, or when a "pick" does not succeed (because of merge errors), the loop will stop to let you fix things, and you can continue diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index 2fa53fdaeb..653393d8c9 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -261,9 +261,9 @@ do_next () { esac failed=f + author_script=$(get_author_ident_from_commit HEAD) output git reset --soft HEAD^ pick_one -n $sha1 || failed=t - author_script=$(get_author_ident_from_commit $sha1) echo "$author_script" > "$DOTEST"/author-script case $failed in f) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 718c9c1fa3..6c92d61192 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -180,7 +180,7 @@ test_expect_success 'squash' ' ' test_expect_success 'retain authorship when squashing' ' - git show HEAD | grep "^Author: Nitfol" + git show HEAD | grep "^Author: Twerp Snog" ' test_expect_success 'preserve merges with -p' ' From f4bb20cc99fe18ba0e7dd421f1d95a05c1cbbc93 Mon Sep 17 00:00:00 2001 From: Jari Aalto Date: Sat, 29 Sep 2007 23:29:43 -0700 Subject: [PATCH 4/4] git-remote: exit with non-zero status after detecting errors. Some subcommands of "git-remote" detected and issued error messages but did not signal that to the calling process with exit status. Signed-off-by: Jari Aalto Signed-off-by: Junio C Hamano --- git-remote.perl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/git-remote.perl b/git-remote.perl index 01cf480221..8e2dc4de73 100755 --- a/git-remote.perl +++ b/git-remote.perl @@ -218,7 +218,7 @@ sub prune_remote { my ($name, $ls_remote) = @_; if (!exists $remote->{$name}) { print STDERR "No such remote $name\n"; - return; + return 1; } my $info = $remote->{$name}; update_ls_remote($ls_remote, $info); @@ -229,13 +229,14 @@ sub prune_remote { my @v = $git->command(qw(rev-parse --verify), "$prefix/$to_prune"); $git->command(qw(update-ref -d), "$prefix/$to_prune", $v[0]); } + return 0; } sub show_remote { my ($name, $ls_remote) = @_; if (!exists $remote->{$name}) { print STDERR "No such remote $name\n"; - return; + return 1; } my $info = $remote->{$name}; update_ls_remote($ls_remote, $info); @@ -265,6 +266,7 @@ sub show_remote { print " Local branch(es) pushed with 'git push'\n"; print " @pushed\n"; } + return 0; } sub add_remote { @@ -351,9 +353,11 @@ elsif ($ARGV[0] eq 'show') { print STDERR "Usage: git remote show \n"; exit(1); } + my $status = 0; for (; $i < @ARGV; $i++) { - show_remote($ARGV[$i], $ls_remote); + $status |= show_remote($ARGV[$i], $ls_remote); } + exit($status); } elsif ($ARGV[0] eq 'update') { if (@ARGV <= 1) { @@ -379,9 +383,11 @@ elsif ($ARGV[0] eq 'prune') { print STDERR "Usage: git remote prune \n"; exit(1); } + my $status = 0; for (; $i < @ARGV; $i++) { - prune_remote($ARGV[$i], $ls_remote); + $status |= prune_remote($ARGV[$i], $ls_remote); } + exit($status); } elsif ($ARGV[0] eq 'add') { my %opts = ();