{"thread":{"id":"28650","subject":"[RFC/WIP PATCH] Use config value rebase.editor as editor when starting git rebase -i","startedAt":"2011-10-11T17:56:08Z","lastAt":"2011-10-11T21:16:11Z","messageCount":4,"participants":["Peter Oberndorfer","Phil Hord","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"177386","messageId":"201110111956.08829.kumbayo84@arcor.de","threadId":"28650","inReplyTo":null,"subject":"[RFC/WIP PATCH] Use config value rebase.editor as editor when starting git rebase -i","fromName":"Peter Oberndorfer","fromEmail":"kumbayo84@arcor.de","sentAt":"2011-10-11T17:56:08Z","receivedAt":"2011-10-11T17:56:08Z","isPatch":true,"sender":{"key":"kumbayo84@arcor.de","avatar":"https://avatars.githubusercontent.com/u/1041267?v=4"},"body":"If rebase.editor is not set interactive rebase falls back\nto the default editor.\n\nWith this change is it possible to have a separate\n(possibly graphical) editor that helps the user\nduring a interactive rebase.\n\nUsing $GIT_EDITOR or core.editor config var for this is not possible\nsince it is also used to start the commit message editor for reword action.\n\nSigned-off-by: Peter Oberndorfer <kumbayo84@arcor.de>\n---\nHi,\n\ni wrote a (not yet released) git rebase -i helper that allows to order commits\nby drag/drop and allows to select the action from a combo box.\n(written in Qt)\nSee http://i55.tinypic.com/2d94gg0.jpg for how it currently looks like. :-)\nNo more typos, no more lost commit by cutting without pasting...\n\nTo integrate this properly into git i need something like this patch.\n\nOpen questions/problems:\n* GIT_EDITOR env var is not honored anymore after this change.\n  Help from somebody with more bash knowledge is highly appreciated!\n\n* Should git_rebase_editor be in git-rebase--interactive.sh instead\n  (since it is only used there)\n\n* How should the config be called?\n  It is not directly used during rebase, only during rebase -i\n  that might not be fully clear from the config name.\n\n* Better config.txt description?\n\nThanks,\nGreetings Peter\n\nPS: My tool will hopefully be released soon.\nCleanup code, test(lin/ win), write some doc (how to use with git),\nchoose name :-), choose license...\n\n Documentation/config.txt   |    6 ++++++\n git-rebase--interactive.sh |    2 +-\n git-sh-setup.sh            |   13 +++++++++++++\n 3 files changed, 20 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 03296b7..1d9ae79 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1591,6 +1591,12 @@ rebase.stat::\n \tWhether to show a diffstat of what changed upstream since the last\n \trebase. False by default.\n \n+rebase.editor::\n+\tText editor used by git rebase -i for editing the rebasse todo file.\n+\tThe value is meant to be interpreted by the shell when it is used.\n+\tWhen not configured the default commit message editor is used instead.\n+\tSee \"core.editor\"\n+\n rebase.autosquash::\n \tIf set to true enable '--autosquash' option by default.\n \ndiff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh\nindex 94f36c2..0f3b569 100644\n--- a/git-rebase--interactive.sh\n+++ b/git-rebase--interactive.sh\n@@ -832,7 +832,7 @@ has_action \"$todo\" ||\n \tdie_abort \"Nothing to do\"\n \n cp \"$todo\" \"$todo\".backup\n-git_editor \"$todo\" ||\n+git_rebase_editor \"$todo\" ||\n \tdie_abort \"Could not execute editor\"\n \n has_action \"$todo\" ||\ndiff --git a/git-sh-setup.sh b/git-sh-setup.sh\nindex 8e427da..303fb96 100644\n--- a/git-sh-setup.sh\n+++ b/git-sh-setup.sh\n@@ -113,6 +113,19 @@ git_editor() {\n \teval \"$GIT_EDITOR\" '\"$@\"'\n }\n \n+git_rebase_editor() {\n+\tif test -z \"${GIT_REBASEI_EDITOR:+set}\"\n+\tthen\n+\t\tGIT_REBASEI_EDITOR=\"$(git config rebase.editor)\"\n+\t\tif [ -z \"$GIT_REBASEI_EDITOR\" ]\n+\t\tthen\n+\t\t\tGIT_REBASEI_EDITOR=\"$(git var GIT_EDITOR)\" || return $?\n+\t\tfi\n+\tfi\n+\n+\teval \"$GIT_REBASEI_EDITOR\" '\"$@\"'\n+}\n+\n git_pager() {\n \tif test -t 1\n \tthen\n-- \n1.7.7.215.gfef80\n"},{"id":"177388","messageId":"CABURp0oQJ_rUQyOmm+CmZaqBp2mZYCwZRAz_mO5BshK4E+6eCA@mail.gmail.com","threadId":"28650","inReplyTo":"201110111956.08829.kumbayo84@arcor.de","subject":"Re: [RFC/WIP PATCH] Use config value rebase.editor as editor when starting git rebase -i","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2011-10-11T18:15:25Z","receivedAt":"2011-10-11T18:15:25Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Tue, Oct 11, 2011 at 1:56 PM, Peter Oberndorfer <kumbayo84@arcor.de> wrote:\n> i wrote a (not yet released) git rebase -i helper that allows to order commits\n> by drag/drop and allows to select the action from a combo box.\n> (written in Qt)\n> See http://i55.tinypic.com/2d94gg0.jpg for how it currently looks like. :-)\n> No more typos, no more lost commit by cutting without pasting...\n\n[+1]\n\n>\n> To integrate this properly into git i need something like this patch.\n>\n> Open questions/problems:\n> * GIT_EDITOR env var is not honored anymore after this change.\n>  Help from somebody with more bash knowledge is highly appreciated!\n>\n> * Should git_rebase_editor be in git-rebase--interactive.sh instead\n>  (since it is only used there)\n>\n> * How should the config be called?\n>  It is not directly used during rebase, only during rebase -i\n>  that might not be fully clear from the config name.\n>\n> * Better config.txt description?\n>\n> Thanks,\n> Greetings Peter\n>\n> PS: My tool will hopefully be released soon.\n> Cleanup code, test(lin/ win), write some doc (how to use with git),\n> choose name :-), choose license...\n>\n>  Documentation/config.txt   |    6 ++++++\n>  git-rebase--interactive.sh |    2 +-\n>  git-sh-setup.sh            |   13 +++++++++++++\n>  3 files changed, 20 insertions(+), 1 deletions(-)\n>\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 03296b7..1d9ae79 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -1591,6 +1591,12 @@ rebase.stat::\n>        Whether to show a diffstat of what changed upstream since the last\n>        rebase. False by default.\n>\n> +rebase.editor::\n> +       Text editor used by git rebase -i for editing the rebasse todo file.\ns/rebasse/rebase/\n\n>  cp \"$todo\" \"$todo\".backup\n> -git_editor \"$todo\" ||\n> +git_rebase_editor \"$todo\" ||\n>        die_abort \"Could not execute editor\"\n\nMaybe something like this would work:\n  git_rebase_editor \"$todo\" ||\n  git_editor \"$todo\" ||\n       die_abort \"Could not execute editor\"\n\nIf git_rebase_editor call returns an error (non-zero exit code), then\ngit_editor will be invoked. If that also returns an error, then the\ndie_abort is called.\n\nI think this will allow your env:GIT_EDITOR to work as expected.\n\nPhil\n"},{"id":"177391","messageId":"7vipnvfk70.fsf@alter.siamese.dyndns.org","threadId":"28650","inReplyTo":"201110111956.08829.kumbayo84@arcor.de","subject":"Re: [RFC/WIP PATCH] Use config value rebase.editor as editor when starting git rebase -i","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-10-11T18:37:55Z","receivedAt":"2011-10-11T18:37:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Peter Oberndorfer <kumbayo84@arcor.de> writes:\n\n> Using $GIT_EDITOR or core.editor config var for this is not possible\n> since it is also used to start the commit message editor for reword action.\n\nYour tool _could_ be smart about this issue and inspect the contents to\nlaunch a real editor when it is fed a material not for sequencing, but\nthat feels hacky.\n\n> * GIT_EDITOR env var is not honored anymore after this change.\n\nCare to explain?  \"git var\" knows magic about a few variables like\nGIT_EDITOR and GIT_PAGER.\n\n\t$ git config core.editor vim\n\t$ GIT_EDITOR=vi EDITOR=emacs git var GIT_EDITOR\n        vi\n\t$ unset GIT_EDITOR; EDITOR=emacs git var GIT_EDITOR\n        emacs\n\n> * Should git_rebase_editor be in git-rebase--interactive.sh instead\n\nProbably yes.\n\n> * How should the config be called?\n\nGiven that in the longer term we would be using a unified sequencer\nmachinery for not just rebase-i but for am and cherry-pick, I would advise\nagainst calling this anything \"rebase\".  How does \"sequence.edit\" sound?\n\nYou need to be prepared to adjust your code to deal with new kinds of\nsequencing insns in the insn sheet and possibly a format change of the\ninsn sheet itself.\n"},{"id":"177398","messageId":"201110112316.11738.kumbayo84@arcor.de","threadId":"28650","inReplyTo":"7vipnvfk70.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/WIP PATCH] Use config value rebase.editor as editor when starting git rebase -i","fromName":"Peter Oberndorfer","fromEmail":"kumbayo84@arcor.de","sentAt":"2011-10-11T21:16:11Z","receivedAt":"2011-10-11T21:16:11Z","isPatch":true,"sender":{"key":"kumbayo84@arcor.de","avatar":"https://avatars.githubusercontent.com/u/1041267?v=4"},"body":"On Dienstag, 11. Oktober 2011, Junio C Hamano wrote:\n> Peter Oberndorfer <kumbayo84@arcor.de> writes:\n> \n> > Using $GIT_EDITOR or core.editor config var for this is not possible\n> > since it is also used to start the commit message editor for reword action.\n> \n> Your tool _could_ be smart about this issue and inspect the contents to\n> launch a real editor when it is fed a material not for sequencing, but\n> that feels hacky.\n\nI already tried this, but my first version did not redirect stdin/stdout\nso vi stayed in background and the whole thing just hung.\nI did not try further because i assumed more problems would appear\nwhen redirecting stdin/stdout...\n\n> > * GIT_EDITOR env var is not honored anymore after this change.\n> \n> Care to explain?  \"git var\" knows magic about a few variables like\n> GIT_EDITOR and GIT_PAGER.\n> \n> \t$ git config core.editor vim\n> \t$ GIT_EDITOR=vi EDITOR=emacs git var GIT_EDITOR\n>         vi\n> \t$ unset GIT_EDITOR; EDITOR=emacs git var GIT_EDITOR\n>         emacs\n\nSorry i was wrong, i missed that git var looks at $GIT_EDITOR.\n\nSo the sequence for choosing the sequencer editor is:\n$GIT_SEQUENCE_EDITOR\nconfig sequence.editor\nvar GIT_EDITOR\n\nWhich looks OK to me.\n\n> > * Should git_rebase_editor be in git-rebase--interactive.sh instead\n> \n> Probably yes.\n\nOK, will do.\n\n> \n> > * How should the config be called?\n> \n> Given that in the longer term we would be using a unified sequencer\n> machinery for not just rebase-i but for am and cherry-pick, I would advise\n> against calling this anything \"rebase\".  How does \"sequence.edit\" sound?\n> \n\nI do not really care very much, but how about sequence.editor?\nSounds more similar to core.editor\n\n> You need to be prepared to adjust your code to deal with new kinds of\n> sequencing insns in the insn sheet and possibly a format change of the\n> insn sheet itself.\n\nI assume instruction sheet is the commented out part that looks like:\n# Commands:\n#  p, pick = use commit\n#  r, reword = use commit, but edit the commit message\n\nCurrently all lines starting with # are ignored.\n(They are also not written to the output when finished\nwhich is a point I might have to change...)\n\nAlso the instructions are currently not taken from this instruction sheet.\nThey are all hardcoded.\n\nThanks for the feedback\nGreetings Peter\n"}]}