git mergetoolでEmacsのediff-merge-files-with-ancestorを呼び出す

投稿者: | 2012年7月23日

git mergetoolに使えるツールとして、デフォルトで"emerge"というのが用意されており、Emacs使いはこれを使えばEmergeでマージが行えるわけだが、難点もある。ひとつは、新たなEmacsインスタンスを起動してしまうということだ。起動に無駄な時間が掛かるし、マージにあたって既存のセッションで開いているファイルをその場で参照できないのは不便だろう。もっとも、これはemacsclientを使うようにして、Emergeの呼び出し方を少し直せば済む。もうひとつは、EmergeではなくよりモダンなEdiffを使いたいということだが、これは思ったほど簡単ではないのでわざわざこうして記事を書くことになった。

というのも、Emergeにはemerge-files-with-ancestor-commandという便利なものがあり、「マージが終わったらマージ結果を保存して即終了」ということが一発で出来てしまうのだが、Ediffの方にはそういうものがない。こいつはマージを終了してもろくに片付けもせず、全部ほったらかしという行儀の悪さだ。
そういうわけで、まずはEdiffのediff-merge-{files,buffers}が終わったら起動前のウィンドウ設定を復元するようにしてみる。これは比較的簡単。[2013-01-23改訂:フックにappendフラグを指定]

次に、Ediffが新たに開いたファイルのバッファをマージ終了時に自動的に閉じる、および、マージ終了時に自動的にセーブしつつEmacsフレームを閉じる「バッチ版ediff-merge-files-with-ancestor」を加える。[2013-01-23改訂:ediff-filesに影響を与えるなどおかしかったので大幅修正; 続きはGitHubで]

これで、~/.gitconfigにこんな風に書けばgit mergetoolで瞬時にEdiffが起動し、マージが済んだらq, yで即コマンドラインに帰ってくる。既存Emacsセッションにゴミバッファも残らない。

あとは、たとえばラッパースクリプトを用意して、「<<<<<<<」などの行が残っていたらマージ失敗とするとか、好きに改良すると良い。

参考記事

git mergetoolでEmacsのediff-merge-files-with-ancestorを呼び出す」への43件のフィードバック

  1. Temp Mail

    Your talent is equal to your own inspiration. Giustino’s artwork is tasteful, and the written content is properly arranged. Despite this, you feel uneasy about the prospect of embarking on something that might cause you discomfort. I concede that you will be able to address this problem quickly.

    返信
  2. binance

    I don’t think the title of your article matches the content lol. Just kidding, mainly because I had some doubts after reading the article.

    返信
  3. Newtoki

    Newtoki You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!

    返信
  4. what is baddiehub

    Baddiehub naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.

    返信
  5. kirgetide1972

    For the modern world, a consultation with a wide asset entails the process of introducing and modernizing the timely implementation of the super -task. And the elements of the political process urge us to new achievements, which, in turn, should be described as detailed as possible.

    返信
  6. zhuycenquimul1987

    Only replicated from foreign sources, modern studies are only the method of political participation and are devoted to a socio-democratic anathema. Camping conspiracies do not allow the situations in which representatives of modern social reserves only add fractional disagreements and are indicated as applicants for the role of key factors.

    返信
  7. condneteti1975

    Given the current international situation, the introduction of modern methods to a large extent determines the importance of the phased and consistent development of society. There is a controversial point of view that reads approximately the following: ties diagrams can be limited exclusively by the way of thinking.

    返信
  8. chuntiticon1978

    Our business is not as unambiguous as it might seem: constant information and propaganda support for our activities, as well as a fresh look at the usual things-certainly opens up new horizons for clustering efforts. In particular, the introduction of modern methods plays an important role in the formation of positions occupied by participants in relation to the tasks.

    返信
  9. animidol1976

    It is difficult to say why representatives of modern social reserves to this day remain the lot of liberals, who are eager to be objectively examined by the relevant authorities. Likewise, a deep level of immersion creates the need to include a number of extraordinary measures in the production plan, taking into account the complex of relevant conditions of activation.

    返信
  10. leocovipho1988

    First of all, the framework of personnel training entails the process of implementation and modernization of both self -sufficient and outwardly dependent conceptual decisions. On the other hand, the cohesion of the team of professionals provides ample opportunities for the distribution of internal reserves and resources.

    返信
  11. tusatate1988

    Definitely, thorough studies of competitors are mixed with unique data to the degree of perfect unrecognizability, which is why their status of uselessness increases. Definitely, the actions of opposition representatives only add fractional disagreements and are blocked within their own rational restrictions.

    返信
  12. palreehyraf1985

    A variety of and rich experience tells us that increasing the level of civil consciousness is a qualitatively new step in the withdrawal of current assets. Banal, but irrefutable conclusions, as well as interactive prototypes are nothing more than the quintessence of the victory of marketing over the mind and should be declared violating universal human ethics and morality.

    返信
  13. guipresevra1988

    There is something to think about: replicated from foreign sources, modern studies form a global economic network and at the same time – subjected to a whole series of independent studies. On the other hand, the further development of various forms of activity requires an analysis of the priority of the mind over emotions.

    返信
  14. quirokatte1972

    But the conviction of some opponents unequivocally defines each participant as capable of making his own decisions regarding thoughtful reasoning. The significance of these problems is so obvious that the semantic analysis of external counteraction entails the process of introducing and modernizing the rethinking of foreign economic policies.

    返信
  15. fidirebom1982

    As is commonly believed, independent states to this day remain the destiny of liberals, who are eager to be equally left to themselves. In their desire to improve the quality of life, they forget that socio-economic development unambiguously records the need for new principles for the formation of a material, technical and personnel base.

    返信
  16. emciogedum1983

    Taking into account the success indicators, the innovation path we have chosen creates the prerequisites for clustering efforts. It should be noted that the conviction of some opponents allows us to assess the value of the withdrawal of current assets.

    返信
  17. siolbusegmi1972

    Given the current international situation, the strengthening and development of the internal structure largely determines the importance of the priority of the mind over emotions. But entrepreneurs on the Internet, initiated exclusively synthetically, are limited exclusively by the way of thinking.

    返信
  18. subzynochti1985

    Here is a vivid example of modern trends – semantic analysis of external counteraction allows you to complete important tasks to develop a rethinking of foreign economic policies. In our desire to improve user experience, we miss that the conclusions made on the basis of Internet analytics call us to new achievements, which, in turn, should be verified in a timely manner.

    返信
  19. gailocaspie1977

    In their desire to improve the quality of life, they forget that the current structure of the organization allows you to complete important tasks to develop the progress of the professional community. Preliminary conclusions are disappointing: the introduction of modern methods unambiguously defines each participant as capable of making his own decisions regarding the relevant conditions of activation.

    返信

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です