{"thread":{"id":"26043","subject":"how to create a diff in old file new file format (for code reviews)","startedAt":"2010-12-14T00:07:37Z","lastAt":"2010-12-16T03:33:50Z","messageCount":5,"participants":["aerosmith","Michael J Gruber","Seshu Parvataneni"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"158011","messageId":"1292285257962-5832810.post@n2.nabble.com","threadId":"26043","inReplyTo":null,"subject":"how to create a diff in old file new file format (for code reviews)","fromName":"aerosmith","fromEmail":"parvata@rocketmail.com","sentAt":"2010-12-14T00:07:37Z","receivedAt":"2010-12-14T00:07:37Z","isPatch":false,"sender":{"key":"parvata@rocketmail.com","avatar":null},"body":"\nHi,\n\nI am trying to create a diff such that the original file (entire file) is\nsaved something like file1.h.old and the new modified file as file1.h.new. I\nhave read the various options for git-diff* tools but could not find one\nsuch utility. All I get is the removals and additions as a diff. Does anyone\nknow how to create one with the help the available git utils? The only\nmethod that I can think of is to do everything manually. Any help w.r.t.\nthis is really appreciated. Thanks in advance.\n-- \nView this message in context: http://git.661346.n2.nabble.com/how-to-create-a-diff-in-old-file-new-file-format-for-code-reviews-tp5832810p5832810.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"158040","messageId":"4D073619.2010103@drmicha.warpmail.net","threadId":"26043","inReplyTo":"1292285257962-5832810.post@n2.nabble.com","subject":"Re: how to create a diff in old file new file format (for code reviews)","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-14T09:17:13Z","receivedAt":"2010-12-14T09:17:13Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"aerosmith venit, vidit, dixit 14.12.2010 01:07:\n> \n> Hi,\n> \n> I am trying to create a diff such that the original file (entire file) is\n> saved something like file1.h.old and the new modified file as file1.h.new. I\n> have read the various options for git-diff* tools but could not find one\n> such utility. All I get is the removals and additions as a diff. Does anyone\n> know how to create one with the help the available git utils? The only\n> method that I can think of is to do everything manually. Any help w.r.t.\n> this is really appreciated. Thanks in advance.\n\nYou could script around this e.g. with an external diff-helper. The\neasiest way is to reuse difftool. For example,\n\ngit difftool -y -x echo <revexpression>\n\nwill give you pairs of names of temporary files for old/new, where\n<revexpression> is what you would give to \"git diff\" to specify what to\ndiff.\n\nWith the patch I'm sending in a minute, the helper you specify with \"-x\"\ncan also access the basename easily, so that you could use \"-x oldnew\"\nwith a script \"oldnew\" containing\n\n#!/bin/sh\ncp \"$1\" \"$BASE\".old\ncp \"$2\" \"$BASE\".new\n\nEven without the patch, you could use\n\ngit difftool -y -x 'cp \"$LOCAL\" \"$BASE\".old; cp \"$REMOTE\" \"$BASE.new\";\n#' <revexpression>\n\n(all on one line) directly. But this requires insider knowledge and may\nbreak some day.\n\nCheers,\nMichael\n"},{"id":"158042","messageId":"0833a4451b70db4c4e0be5753be53e262a9c5628.1292317348.git.git@drmicha.warpmail.net","threadId":"26043","inReplyTo":"4D073619.2010103@drmicha.warpmail.net","subject":"[PATCH 1/2] git-difftool.txt: correct the description of $BASE and describe $MERGED","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-14T09:18:34Z","receivedAt":"2010-12-14T09:18:34Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/git-difftool.txt |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt\nindex 6fffbc7..756d95d 100644\n--- a/Documentation/git-difftool.txt\n+++ b/Documentation/git-difftool.txt\n@@ -56,8 +56,9 @@ the configured command line will be invoked with the following\n variables available: `$LOCAL` is set to the name of the temporary\n file containing the contents of the diff pre-image and `$REMOTE`\n is set to the name of the temporary file containing the contents\n-of the diff post-image.  `$BASE` is provided for compatibility\n-with custom merge tool commands and has the same value as `$LOCAL`.\n+of the diff post-image.  `$MERGED` is the name of the file which is\n+being compared. `$BASE` is provided for compatibility\n+with custom merge tool commands and has the same value as `$MERGED`.\n \n -x <command>::\n --extcmd=<command>::\n-- \n1.7.3.3.739.g52f77.dirty\n"},{"id":"158041","messageId":"3a5944cb9af7b6b69dc0bdefdfd052b33fcd9a59.1292317348.git.git@drmicha.warpmail.net","threadId":"26043","inReplyTo":"4D073619.2010103@drmicha.warpmail.net","subject":"[PATCH 2/2] difftool: provide basename to external tools","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-12-14T09:18:35Z","receivedAt":"2010-12-14T09:18:35Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Currently, only configured diff helpers get the basename of the file\nbeing compared. Tools specified with \"git difftool -x\" only get the\nnames of temporary files for the different versions.\n\nExport BASE so that an external tool can read the name from the\nenvironment. Rather than using a third argument, this avoids breaking\nexisting scripts which may somewhat carelessly be using \"$@\" rather than\n\"$1\" \"$2\".\n\nSigned-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\n Documentation/git-difftool.txt |    1 +\n git-difftool--helper.sh        |    1 +\n 2 files changed, 2 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt\nindex 756d95d..db87f1d 100644\n--- a/Documentation/git-difftool.txt\n+++ b/Documentation/git-difftool.txt\n@@ -65,6 +65,7 @@ with custom merge tool commands and has the same value as `$MERGED`.\n \tSpecify a custom command for viewing diffs.\n \t'git-difftool' ignores the configured defaults and runs\n \t`$command $LOCAL $REMOTE` when this option is specified.\n+\tAdditionally, `$BASE` is set in the environment.\n \n -g::\n --gui::\ndiff --git a/git-difftool--helper.sh b/git-difftool--helper.sh\nindex 524f5ea..0594bf7 100755\n--- a/git-difftool--helper.sh\n+++ b/git-difftool--helper.sh\n@@ -49,6 +49,7 @@ launch_merge_tool () {\n \tfi\n \n \tif use_ext_cmd; then\n+\t\texport BASE\n \t\teval $GIT_DIFFTOOL_EXTCMD '\"$LOCAL\"' '\"$REMOTE\"'\n \telse\n \t\trun_merge_tool \"$merge_tool\"\n-- \n1.7.3.3.739.g52f77.dirty\n"},{"id":"158202","messageId":"415120.5940.qm@web34306.mail.mud.yahoo.com","threadId":"26043","inReplyTo":"4D073619.2010103@drmicha.warpmail.net","subject":"Re: [solved] how to create a diff in old file new file format (for code reviews)","fromName":"Seshu Parvataneni","fromEmail":"parvata@rocketmail.com","sentAt":"2010-12-16T03:33:50Z","receivedAt":"2010-12-16T03:33:50Z","isPatch":false,"sender":{"key":"parvata@rocketmail.com","avatar":null},"body":"Hi Michael,\n\nThanks very much for the reply. Your example with the difftool worked. This was what I was looking for.\n\n\n\n--- On Tue, 12/14/10, Michael J Gruber <git@drmicha.warpmail.net> wrote:\n\n> From: Michael J Gruber <git@drmicha.warpmail.net>\n> Subject: Re: how to create a diff in old file new file format (for code reviews)\n> To: \"aerosmith\" <parvata@rocketmail.com>\n> Cc: git@vger.kernel.org\n> Date: Tuesday, December 14, 2010, 1:17 AM\n> aerosmith venit, vidit, dixit\n> 14.12.2010 01:07:\n> > \n> > Hi,\n> > \n> > I am trying to create a diff such that the original\n> file (entire file) is\n> > saved something like file1.h.old and the new modified\n> file as file1.h.new. I\n> > have read the various options for git-diff* tools but\n> could not find one\n> > such utility. All I get is the removals and additions\n> as a diff. Does anyone\n> > know how to create one with the help the available git\n> utils? The only\n> > method that I can think of is to do everything\n> manually. Any help w.r.t.\n> > this is really appreciated. Thanks in advance.\n> \n> You could script around this e.g. with an external\n> diff-helper. The\n> easiest way is to reuse difftool. For example,\n> \n> git difftool -y -x echo <revexpression>\n> \n> will give you pairs of names of temporary files for\n> old/new, where\n> <revexpression> is what you would give to \"git diff\"\n> to specify what to\n> diff.\n> \n> With the patch I'm sending in a minute, the helper you\n> specify with \"-x\"\n> can also access the basename easily, so that you could use\n> \"-x oldnew\"\n> with a script \"oldnew\" containing\n> \n> #!/bin/sh\n> cp \"$1\" \"$BASE\".old\n> cp \"$2\" \"$BASE\".new\n> \n> Even without the patch, you could use\n> \n> git difftool -y -x 'cp \"$LOCAL\" \"$BASE\".old; cp \"$REMOTE\"\n> \"$BASE.new\";\n> #' <revexpression>\n> \n> (all on one line) directly. But this requires insider\n> knowledge and may\n> break some day.\n> \n> Cheers,\n> Michael\n> --\n> To unsubscribe from this list: send the line \"unsubscribe\n> git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n> \n\n\n      \n"}]}