github.com/wmuizelaar/kpt@v0.0.0-20221018115725-bd564717b2ed/site/reference/cli/pkg/diff/README.md (about) 1 --- 2 title: "`diff`" 3 linkTitle: "diff" 4 type: docs 5 description: > 6 Show differences between a local package and upstream. 7 --- 8 9 <!--mdtogo:Short 10 Show differences between a local package and upstream. 11 --> 12 13 `diff` displays differences between upstream and local packages. 14 15 It can display differences between: 16 17 - The local package and the upstream version which the local package was based 18 on. 19 - The local package and the latest version of the upstream package. 20 21 `diff` fetches the versions of a package that are needed, but it delegates 22 displaying the differences to a command line diffing tool. By default, the 23 'diff' command line tool is used, but this can be changed with either the 24 `diff-tool` flag or the `KPT_EXTERNAL_DIFF` env variable. 25 26 ### Synopsis 27 28 <!--mdtogo:Long--> 29 30 ``` 31 kpt pkg diff [PKG_PATH@VERSION] [flags] 32 ``` 33 34 #### Args 35 36 ``` 37 PKG_PATH: 38 Local package path to compare. diff will fail if the directory doesn't exist, or does not 39 contain a Kptfile. Defaults to the current working directory. 40 41 VERSION: 42 A git tag, branch, or commit. Specified after the local_package with @, for 43 example my-package@master. 44 Defaults to the local package version that was last fetched. 45 ``` 46 47 #### Flags 48 49 ``` 50 --diff-type: 51 The type of changes to view (local by default). Following types are 52 supported: 53 54 local: Shows changes in local package relative to upstream source package 55 at original version. 56 remote: Shows changes in upstream source package at target version 57 relative to original version. 58 combined: Shows changes in local package relative to upstream source 59 package at target version. 60 3way: Shows changes in local package and source package at target version 61 relative to original version side by side. 62 63 --diff-tool: 64 Command line diffing tool ('diff' by default) for showing the changes. 65 Note that it overrides the KPT_EXTERNAL_DIFF environment variable. 66 67 # Show changes using 'meld' commandline tool. 68 kpt pkg diff @master --diff-tool meld 69 70 --diff-tool-opts: 71 Commandline options to use with the command line diffing tool. 72 Note that it overrides the KPT_EXTERNAL_DIFF_OPTS environment variable. 73 74 # Show changes using the diff command with recursive options. 75 kpt pkg diff @master --diff-tool meld --diff-tool-opts "-r" 76 ``` 77 78 #### Environment Variables 79 80 ``` 81 KPT_EXTERNAL_DIFF: 82 Commandline diffing tool ('diff; by default) that will be used to show 83 changes. 84 85 # Use meld to show changes 86 KPT_EXTERNAL_DIFF=meld kpt pkg diff 87 88 KPT_EXTERNAL_DIFF_OPTS: 89 Commandline options to use for the diffing tool. For ex. 90 # Using "-a" diff option 91 KPT_EXTERNAL_DIFF_OPTS="-a" kpt pkg diff --diff-tool meld 92 93 KPT_CACHE_DIR: 94 Controls where to cache remote packages when fetching them. 95 Defaults to <HOME>/.kpt/repos/ 96 On macOS and Linux <HOME> is determined by the $HOME env variable, while on 97 Windows it is given by the %USERPROFILE% env variable. 98 ``` 99 100 <!--mdtogo--> 101 102 ### Examples 103 104 {{% hide %}} 105 106 <!-- @makeWorkplace @verifyExamples--> 107 108 ``` 109 # Set up workspace for the test. 110 TEST_HOME=$(mktemp -d) 111 cd $TEST_HOME 112 ``` 113 114 <!-- @fetchPackage @verifyExamples--> 115 116 ```shell 117 export SRC_REPO=https://github.com/GoogleContainerTools/kpt.git 118 kpt pkg get $SRC_REPO/package-examples/helloworld-set hello-world 119 cd hello-world 120 ``` 121 122 {{% /hide %}} 123 124 <!--mdtogo:Examples--> 125 <!-- @pkgDiff @verifyExamples--> 126 127 ```shell 128 # Show changes in current package relative to upstream source package. 129 $ kpt pkg diff 130 ``` 131 132 <!--mdtogo-->