4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

patch - 普通の diff ファイルの使い方。

Posted at

ここの "app.psgi#1" から、ここの "diff#2" を使って、 "app.psgi#3" を作るのに。

準備

"app.psgi#1" がクリップボードにある状態で、保存

$ pbpaste > app.psgi

patch

patch を当てる。

"app.psgi" があるディレクトリで "diff#2" を適当(app.psgi.dif)に保存して

$ patch app.psgi < app.psgi.dif
patching file app.psgi
Hunk #1 succeeded at 17 (offset -1 lines).
Hunk #2 succeeded at 36 (offset -1 lines).

Hunk... のコメントは、この場合は、行は違うけどパッチは上手く当ったよ。ってコメント1

"app.psgi#3" を app.psgi.new って名前で保存して

$ diff app.psgi app.psgi.new

で、再現出来てるのが確認出来る。

reverse patch を当てる。

で、"app.psgi#3" を "app.psgi#1" に戻すには。
"diff#2" を再度適用する。

$ patch app.psgi < app.psgi.dif
patching file app.psgi
Reversed (or previously applied) patch detected!  Assume -R? [n] 

すると逆じゃねーの? と聞いてくるので y と答える。

もしくは最初から -R オプション付きでコマンドを実行する。

$ patch -R app.psgi < app.psgi.dif

ので、 Web に数多ある diff 結果は普通に野良 patch として使えるんですよ、、、と。

  1. このコメントを出させるために、数値を改変してる。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?