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

[PATCH v2 4/4] git rebase -i: Use newly added --count-lines option for stripspace

From
Tobias Klauser <tklauser@distanz.ch>
Date
Oct 16, 2015, 15:16 UTC
Message-ID
<1445008605-16534-5-git-send-email-tklauser@distanz.ch>
In-Reply-To
<1445008605-16534-1-git-send-email-tklauser@distanz.ch>

Use the newly added --count-lines option for 'git stripspace' to count lines instead of piping the entire output to 'wc -l'.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
---

Implements the small project idea from https://git.wiki.kernel.org/index.php/SmallProjectsIdeas#implement_.27--count-lines.27_in_.27git_stripspace.27

 git-rebase--interactive.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index d65c06e..f80da30 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -120,9 +120,9 @@ mark_action_done () {
 	sed -e 1q < "$todo" >> "$done"
 	sed -e 1d < "$todo" >> "$todo".new
 	mv -f "$todo".new "$todo"
-	new_count=$(git stripspace --strip-comments <"$done" | wc -l)
+	new_count=$(git stripspace --strip-comments --count-lines <"$done")
 	echo $new_count >"$msgnum"
-	total=$(($new_count + $(git stripspace --strip-comments <"$todo" | wc -l)))
+	total=$(($new_count + $(git stripspace --strip-comments --count-lines <"$todo")))
 	echo $total >"$end"
 	if test "$last_count" != "$new_count"
 	then
@@ -1243,7 +1243,7 @@ test -s "$todo" || echo noop >> "$todo"
 test -n "$autosquash" && rearrange_squash "$todo"
 test -n "$cmd" && add_exec_commands "$todo"
 
-todocount=$(git stripspace --strip-comments <"$todo" | wc -l)
+todocount=$(git stripspace --strip-comments --count-lines <"$todo")
 todocount=${todocount##* }
 
 cat >>"$todo" <<EOF
-- 
2.6.1.148.g7927db1
Previous: Tobias KlauserNext: Junio C Hamano
Message 19 of 23 in “stripspace: Implement and use --count-lines option”
  1. 0/4 stripspace: Implement and use --count-lines optionTobias Klauser, Oct 16, 2015
  2. 1/4 strbuf: make stripspace() part of strbufTobias Klauser, Oct 16, 2015
  3. 2/4 stripspace: Use parse-options for command-line parsingTobias Klauser, Oct 16, 2015
  4. Junio C HamanoOct 16, 2015
  5. Junio C HamanoOct 16, 2015
  6. Tobias KlauserOct 17, 2015
  7. Junio C HamanoOct 17, 2015
  8. Tobias KlauserOct 20, 2015
  9. Junio C HamanoOct 20, 2015
  10. Tobias KlauserOct 17, 2015
  11. 3/4 stripspace: Implement --count-lines optionTobias Klauser, Oct 16, 2015
  12. Eric SunshineOct 17, 2015
  13. Junio C HamanoOct 18, 2015
  14. Tobias KlauserOct 19, 2015
  15. Christian CouderOct 19, 2015
  16. Eric SunshineOct 19, 2015
  17. Matthieu MoyOct 19, 2015
  18. Tobias KlauserOct 19, 2015
  19. 4/4 git rebase -i: Use newly added --count-lines option for stripspaceTobias Klauser, Oct 16, 2015
  20. Junio C HamanoOct 16, 2015
  21. Tobias KlauserOct 17, 2015
  22. Matthieu MoyOct 16, 2015
  23. Tobias KlauserOct 17, 2015

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.