git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] add-interactive: shortcut for add hunk and quit

From
HGHermann Gausterer <git-mailinglist@mrq1.org>
Date
May 15, 2011, 12:55 UTC
Message-ID
<20110515125525.GA3014@mrq1.org>

combines the two commands "y"+"q" to one. i use this if i know that this is the last hunk to add.

Signed-off-by: Hermann Gausterer <git-git-2011@mrq1.org>
---
 Documentation/git-add.txt |    1 +
 git-add--interactive.perl |   15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
index 9c1d395..76ffd45 100644
--- a/Documentation/git-add.txt
+++ b/Documentation/git-add.txt
@@ -280,6 +280,7 @@ patch::
        y - stage this hunk
        n - do not stage this hunk
        q - quit; do not stage this hunk nor any of the remaining ones
+       Q - quit; stage this hunk but none of the remaining ones
        a - stage this hunk and all later hunks in the file
        d - do not stage this hunk nor any of the later hunks in the file
        g - select a hunk to go to
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 4f08fe7..db79556 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1123,6 +1123,7 @@ sub help_patch_cmd {
 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; $verb this hunk but none 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
 g - select a hunk to go to
@@ -1313,7 +1314,7 @@ sub patch_update_file {
 		   $hunk[$ix]{TYPE} eq 'deletion' ? ' deletion' :
 		   ' this hunk'),
 		  $patch_mode_flavour{TARGET},
-		  " [y,n,q,a,d,/$other,?]? ";
+		  " [y,n,q,Q,a,d,/$other,?]? ";
 		my $line = prompt_single_character;
 		if ($line) {
 			if ($line =~ /^y/i) {
@@ -1365,7 +1366,17 @@ sub patch_update_file {
 				}
 				next;
 			}
-			elsif ($line =~ /^q/i) {
+			elsif ($line =~ /^q/) {
+				for ($i = 0; $i < $num; $i++) {
+					if (!defined $hunk[$i]{USE}) {
+						$hunk[$i]{USE} = 0;
+					}
+				}
+				$quit = 1;
+				last;
+			}
+			elsif ($line =~ /^Q/) {
+				$hunk[$ix]{USE} = 1;
 				for ($i = 0; $i < $num; $i++) {
 					if (!defined $hunk[$i]{USE}) {
 						$hunk[$i]{USE} = 0;
-- 
1.7.0.4
Next: Junio C Hamano
Message 1 of 15 in “add-interactive: shortcut for add hunk and quit”
  1. add-interactive: shortcut for add hunk and quitHermann Gausterer, May 15, 2011
  2. Junio C HamanoMay 15, 2011
  3. add-interactive: shortcut to add hunk and quitHermann Gausterer, May 16, 2011
  4. Matthieu MoyMay 16, 2011
  5. Junio C HamanoMay 17, 2011
  6. add-interactive: shortcut to add hunk and quitHermann Gausterer, May 17, 2011
  7. Pete HarlanMay 18, 2011
  8. Jeff KingMay 18, 2011
  9. Michael J GruberMay 18, 2011
  10. Junio C HamanoMay 18, 2011
  11. Thomas RastMay 19, 2011
  12. Jeff KingMay 19, 2011
  13. Junio C HamanoMay 19, 2011
  14. Jeff KingMay 19, 2011
  15. Hermann GaustererMay 18, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.