• 请不要在回答技术问题时复制粘贴 AI 生成的内容
tywtyw2002
V2EX  ›  程序员

git commit 调用第三方编辑器是怎么实现的?

  •  
  •   tywtyw2002 · Jun 11, 2014 via iPhone · 5002 views
    This topic created in 4399 days ago, the information mentioned may be changed or developed.
    git在commit的时候会启动第三方编辑器去编辑commit。
    这时git是如何检查commit写好或者第三方编辑器被关闭了呢?
    6 replies    2014-06-12 12:53:20 +08:00
    robertlyc
        1
    robertlyc  
       Jun 11, 2014
    git config --global core.editor "mate -w"
    Mutoo
        2
    Mutoo  
       Jun 11, 2014
    还记得 c 的 hello world 那个不起眼的 return 0 么;

    http://en.wikipedia.org/wiki/Wait_(command)
    billlee
        3
    billlee  
       Jun 11, 2014
    man 2 waitpid
    xieranmaya
        4
    xieranmaya  
       Jun 12, 2014
    传给第三方编辑器的路径是.git目录下的COMMIT_EDITMSG这个文件,编辑器直接编辑这个文件,同时git也在监控这个文件,文件被关闭后就拿文件内容当ci msg
    robot9
        5
    robot9  
       Jun 12, 2014
    Fork一个process等它返回就好啦
    可以先指定写到一个临时生成的文件里 之后直接读那个文件
    kneep
        6
    kneep  
       Jun 12, 2014 via iPhone
    等待进程退出吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2994 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 09:28 · PVG 17:28 · LAX 02:28 · JFK 05:28
    ♥ Do have faith in what you're doing.