diff, patch, merge
diff -u file-old.txt file-new.txt
patch
diff -u file-old.txt file-new.txt > file.patch
patch file-old.txt file.patch
patch -R file-new.txt file.patch
-R
=--reverse
merge
merge file-v1.txt file.txt file-v2.txt
语义上等效于
diff -u file.txt file-v2.txt > file-v2.patch
patch file-v1.txt file-v2.patch
Default Diff Output
234c239,244
< puts $s "Content-Type: [ContentType $mypath]"
---
> set mime [ContentType $mypath]
> switch -glob $mime "text/*" {
> puts $s "Content-Type: $mime;charset=utf-8"
> } default {
> puts $s "Content-Type: $mime"
> }
416a427,430
>
> encoding system utf-8
> uhttpd::create 8080 -root [pwd]
> vwait forever
Unified Diff Output
@@ -231,7 +236,12 @@
puts $s "HTTP/1.0 200 OK"
puts $s "Date: [Date]"
puts $s "Last-Modified: [Date [file mtime $mypath]]"
- puts $s "Content-Type: [ContentType $mypath]"
+ set mime [ContentType $mypath]
+ switch -glob $mime "text/*" {
+ puts $s "Content-Type: $mime;charset=utf-8"
+ } default {
+ puts $s "Content-Type: $mime"
+ }
puts $s "Content-Length: [file size $mypath]"
puts $s ""
fconfigure $s -translation binary -blocking 0
@@ -414,3 +424,7 @@
# tcl-basic-offset: 4
# End:
Context Diff Output
***************
*** 231,237 ****
puts $s "HTTP/1.0 200 OK"
puts $s "Date: [Date]"
puts $s "Last-Modified: [Date [file mtime $mypath]]"
! puts $s "Content-Type: [ContentType $mypath]"
puts $s "Content-Length: [file size $mypath]"
puts $s ""
fconfigure $s -translation binary -blocking 0
--- 236,247 ----
puts $s "HTTP/1.0 200 OK"
puts $s "Date: [Date]"
puts $s "Last-Modified: [Date [file mtime $mypath]]"
! set mime [ContentType $mypath]
! switch -glob $mime "text/*" {
! puts $s "Content-Type: $mime;charset=utf-8"
! } default {
! puts $s "Content-Type: $mime"
! }
puts $s "Content-Length: [file size $mypath]"
puts $s ""
fconfigure $s -translation binary -blocking 0
***************
*** 414,416 ****
--- 424,430 ----
# tcl-basic-offset: 4
# End:
Merge Text Format
<<<<<<<
Text from file A
=======
Text from file B
>>>>>>>