git-diff with stdin¶
Say you want to diff a local file with the contents of stdin.
Git has built-in support for that. A --no-index
(used to compare two non-git
things).
Example:
cat << EOF | git --no-pager diff --no-index -- - cf/types.go
package main
// these changes are from stdin
type DataRow struct {
stackName string
awsProfile string
awsRegion string
template string
local int
tag *string
drifted bool
err error
}
EOF
Output:
diff --git a/- b/cf/types.go
index 0000000..2857c53 100644
--- a/-
+++ b/cf/types.go
@@ -1,13 +1,14 @@
package main
-// these changes are from stdin
type DataRow struct {
stackName string
awsProfile string
awsRegion string
template string
- local int
+ local string
tag *string
+ fetching bool
+ fetched bool
drifted bool
err error
}