Currently, I am editing files on vim by setting patchmode=.orig
and then, having two files:
file.txt.orig
<- backup without changesfile.txt
<- update file
However, I would like to generate a diff without having to rename the .orig
file, so patch
understands it is just file.txt
which has been updated.
Ideally I would really enjoy a workflow I could run
diff -u file.txt
which would automatically compare file.txt.orig
and file.txt
and output a .diff
containing
--- file.txt 2021-05-03 17:47:12.685416342 +0200
+++ file.txt 2021-05-03 17:47:30.538750593 +0200
@@ -1 +1,2 @@
foo bar
+bar baz
instead of diff -u file.txt.orig file.txt
--- file.txt.orig 2021-05-03 17:47:12.685416342 +0200
+++ file.txt 2021-05-03 17:47:30.538750593 +0200
@@ -1 +1,2 @@
foo bar
+bar baz
The above does require me to manually edit the .diff
file every time.
If using .orig
files automatically, would be possible at all, I would love to integrate vim patchmode with diff
and have a valid patch without extra effort.
Perhaps there's an even better approach to this? Any suggestions would be appreciated. Both diff
or git diff
would work for my case.
patch file.txt <file.diff
),patch
doesn't care about what file name is written insidefile.diff
.patch
andgit apply
. It makes more sense to me now.