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

[PATCH 3/3] rebase: turn git-rebase--*.sh into separate programs

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Feb 17, 2016, 13:36 UTC
Message-ID
<1455716201-29784-4-git-send-email-pclouds@gmail.com>
In-Reply-To
<1455716201-29784-1-git-send-email-pclouds@gmail.com>

This is the first step of turning any of these scripts into C. We can see now what variables are exchanged between git-rebase.sh and the subscript (but we don't see all in this patch, variables may have been exported earlier in git-rebase.sh)

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Makefile                             |  6 +++---
 git-rebase--am.sh (mode +x)          | 23 ++++++++++++++---------
 git-rebase--interactive.sh (mode +x) | 15 +++++++++++++++
 git-rebase--merge.sh (mode +x)       | 14 ++++++++++++++
 git-rebase.sh                        | 23 ++++++++++++++++-------
 5 files changed, 62 insertions(+), 19 deletions(-)
 mode change 100644 => 100755 git-rebase--am.sh
 mode change 100644 => 100755 git-rebase--interactive.sh
 mode change 100644 => 100755 git-rebase--merge.sh
diff --git a/Makefile b/Makefile
index 1ee0ed3..ea636e6 100644
--- a/Makefile
+++ b/Makefile
@@ -486,6 +486,9 @@ SCRIPT_SH += git-mergetool.sh
 SCRIPT_SH += git-quiltimport.sh
 SCRIPT_SH += git-rebase.sh
 SCRIPT_SH += git-remote-testgit.sh
+SCRIPT_SH += git-rebase--am.sh
+SCRIPT_SH += git-rebase--interactive.sh
+SCRIPT_SH += git-rebase--merge.sh
 SCRIPT_SH += git-request-pull.sh
 SCRIPT_SH += git-stash.sh
 SCRIPT_SH += git-submodule.sh
@@ -493,9 +496,6 @@ SCRIPT_SH += git-web--browse.sh
 
 SCRIPT_LIB += git-mergetool--lib
 SCRIPT_LIB += git-parse-remote
-SCRIPT_LIB += git-rebase--am
-SCRIPT_LIB += git-rebase--interactive
-SCRIPT_LIB += git-rebase--merge
 SCRIPT_LIB += git-rebase--lib
 SCRIPT_LIB += git-sh-setup
 SCRIPT_LIB += git-sh-i18n
diff --git a/git-rebase--am.sh b/git-rebase--am.sh
old mode 100644
new mode 100755
index 9ae898b..3837f53
--- a/git-rebase--am.sh
+++ b/git-rebase--am.sh
@@ -4,15 +4,19 @@
 # Copyright (c) 2010 Junio C Hamano.
 #
 
-# The whole contents of this file is run by dot-sourcing it from
-# inside a shell function.  It used to be that "return"s we see
-# below were not inside any function, and expected to return
-# to the function that dot-sourced us.
-#
-# However, FreeBSD /bin/sh misbehaves on such a construct and
-# continues to run the statements that follow such a "return".
-# As a work-around, we introduce an extra layer of a function
-# here, and immediately call it after defining it.
+. git-sh-setup
+. git-sh-i18n
+. git-rebase--lib
+require_work_tree_exists
+
+GIT_QUIET=$git_quiet
+GIT_REFLOG_ACTION=$git_reflog_action
+resolvemsg="
+$(gettext 'When you have resolved this problem, run "git rebase --continue".
+If you prefer to skip this patch, run "git rebase --skip" instead.
+To check out the original branch and stop rebasing, run "git rebase --abort".')
+"
+
 git_rebase__am () {
 
 case "$action" in
@@ -99,3 +103,4 @@ move_to_original_branch
 }
 # ... and then we call the whole thing.
 git_rebase__am
+exit_rebase $?
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
old mode 100644
new mode 100755
index c0cfe88..1169920
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -7,6 +7,20 @@
 # The original idea comes from Eric W. Biederman, in
 # http://article.gmane.org/gmane.comp.version-control.git/22407
 #
+
+. git-sh-setup
+. git-sh-i18n
+. git-rebase--lib
+require_work_tree_exists
+
+GIT_QUIET=$git_quiet
+GIT_REFLOG_ACTION=$git_reflog_action
+resolvemsg="
+$(gettext 'When you have resolved this problem, run "git rebase --continue".
+If you prefer to skip this patch, run "git rebase --skip" instead.
+To check out the original branch and stop rebasing, run "git rebase --abort".')
+"
+
 # The file containing rebase commands, comments, and empty lines.
 # This file is created by "git rebase -i" then edited by the user.  As
 # the lines are processed, they are removed from the front of this
@@ -1294,3 +1308,4 @@ do_rest
 }
 # ... and then we call the whole thing.
 git_rebase__interactive
+exit_rebase $?
diff --git a/git-rebase--merge.sh b/git-rebase--merge.sh
old mode 100644
new mode 100755
index 2cc2a6d..f453d15
--- a/git-rebase--merge.sh
+++ b/git-rebase--merge.sh
@@ -5,6 +5,19 @@
 # Copyright (c) 2010 Junio C Hamano.
 #
 
+. git-sh-setup
+. git-sh-i18n
+. git-rebase--lib
+require_work_tree_exists
+
+GIT_QUIET=$git_quiet
+GIT_REFLOG_ACTION=$git_reflog_action
+resolvemsg="
+$(gettext 'When you have resolved this problem, run "git rebase --continue".
+If you prefer to skip this patch, run "git rebase --skip" instead.
+To check out the original branch and stop rebasing, run "git rebase --abort".')
+"
+
 prec=4
 
 read_state () {
@@ -165,3 +178,4 @@ finish_rb_merge
 }
 # ... and then we call the whole thing.
 git_rebase__merge
+exit_rebase $?
diff --git a/git-rebase.sh b/git-rebase.sh
index 0c70381..67b847f 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -54,11 +54,6 @@ cd_to_toplevel
 LF='
 '
 ok_to_skip_pre_rebase=
-resolvemsg="
-$(gettext 'When you have resolved this problem, run "git rebase --continue".
-If you prefer to skip this patch, run "git rebase --skip" instead.
-To check out the original branch and stop rebasing, run "git rebase --abort".')
-"
 unset onto
 unset restrict_revision
 cmd=
@@ -121,8 +116,22 @@ run_specific_rebase () {
 		export GIT_EDITOR
 		autosquash=
 	fi
-	. git-rebase--$type
-	exit_rebase $?
+	git_quiet=$GIT_QUIET
+	git_reflog_action=$GIT_REFLOG_ACTION
+	export GIT_PAGER
+	# these are for write_basic_state()
+	export allow_rerere_autoupdate gpg_sign_opt head_name onto
+	export orig_head state_dir strategy strategy_opts verbose
+	# common variables
+	export action git_reflog_action git_quiet keep_empty
+	export rebase_root restrict_revision revisions upstream
+	# git-rebase--am specific
+	export git_am_opt
+	# git-rebase--interactive specific
+	export autosquash cmd force_rebase onto_name preserve_merges
+	export squash_onto switch_to
+
+	exec git-rebase--$type
 }
 
 run_pre_rebase_hook () {
-- 
2.7.0.377.g4cd97dd
Previous: Matthieu MoyNext: Matthieu Moy
Message 18 of 67 in “GSoC 2016: applications open, deadline = Fri, 19/2”
  1. Matthieu MoyFeb 10, 2016
  2. Johannes SchindelinFeb 10, 2016
  3. Stefan BellerFeb 10, 2016
  4. Christian CouderFeb 11, 2016
  5. Matthieu MoyFeb 12, 2016
  6. Lars SchneiderFeb 12, 2016
  7. Matthieu MoyFeb 12, 2016
  8. Jeff KingFeb 12, 2016
  9. Jeff KingFeb 12, 2016
  10. Matthieu MoyFeb 13, 2016
  11. Stefan BellerFeb 16, 2016
  12. Matthieu MoyFeb 17, 2016
  13. Duy NguyenFeb 17, 2016
  14. 0/3 Turn git-rebase--*.sh to external helpersNguyễn Thái Ngọc Duy, Feb 17, 2016
  15. 1/3 rebase: move common functions to rebase--lib.shNguyễn Thái Ngọc Duy, Feb 17, 2016
  16. 2/3 rebase: move cleanup code to exit_rebase()Nguyễn Thái Ngọc Duy, Feb 17, 2016
  17. Matthieu MoyFeb 17, 2016
  18. 3/3 rebase: turn git-rebase--*.sh into separate programsNguyễn Thái Ngọc Duy, Feb 17, 2016
  19. Matthieu MoyFeb 17, 2016
  20. Johannes SchindelinFeb 17, 2016
  21. Duy NguyenFeb 17, 2016
  22. Johannes SchindelinFeb 17, 2016
  23. Christian CouderFeb 17, 2016
  24. Duy NguyenFeb 22, 2016
  25. Matthieu MoyFeb 22, 2016
  26. Jeff KingFeb 22, 2016
  27. Junio C HamanoFeb 22, 2016
  28. Jeff KingFeb 22, 2016
  29. Matthieu MoyFeb 23, 2016
  30. Jeff KingFeb 24, 2016
  31. Thomas GummererFeb 17, 2016
  32. Lars SchneiderFeb 17, 2016
  33. Matthieu MoyFeb 17, 2016
  34. Junio C HamanoFeb 17, 2016
  35. Matthieu MoyFeb 17, 2016
  36. Jeff KingFeb 17, 2016
  37. Junio C HamanoFeb 17, 2016
  38. Carlos Martín NietoFeb 18, 2016
  39. Matthieu MoyFeb 19, 2016
  40. Carlos Martín NietoFeb 19, 2016
  41. Git has been accepted as a GSoC 2016 mentor organization!Matthieu Moy, Feb 29, 2016
  42. Jeff KingMar 8, 2016
  43. Junio C HamanoMar 8, 2016
  44. Jeff KingMar 8, 2016
  45. Matthieu MoyMar 9, 2016
  46. Jeff KingMar 9, 2016
  47. Johannes SchindelinMar 9, 2016
  48. Jeff KingMar 9, 2016
  49. Matthieu MoyFeb 19, 2016
  50. Jeff KingFeb 19, 2016
  51. Matthieu MoyFeb 19, 2016
  52. Jeff KingFeb 19, 2016
  53. Lars SchneiderFeb 18, 2016
  54. Stefan BellerFeb 18, 2016
  55. Junio C HamanoFeb 18, 2016
  56. Matthieu MoyFeb 19, 2016
  57. Junio C HamanoFeb 19, 2016
  58. Johannes SchindelinFeb 20, 2016
  59. Lars SchneiderFeb 19, 2016
  60. Matthieu MoyFeb 19, 2016
  61. Junio C HamanoFeb 19, 2016
  62. Thomas GummererFeb 19, 2016
  63. Duy NguyenFeb 19, 2016
  64. Junio C HamanoFeb 19, 2016
  65. Duy NguyenFeb 19, 2016
  66. Matthieu MoyFeb 19, 2016
  67. Duy NguyenFeb 19, 2016

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.