* how to create a diff in old file new file format (for code reviews)
@ 2010-12-14 0:07 aerosmith
2010-12-14 9:17 ` Michael J Gruber
0 siblings, 1 reply; 5+ messages in thread
From: aerosmith @ 2010-12-14 0:07 UTC (permalink / raw)
To: git
Hi,
I am trying to create a diff such that the original file (entire file) is
saved something like file1.h.old and the new modified file as file1.h.new. I
have read the various options for git-diff* tools but could not find one
such utility. All I get is the removals and additions as a diff. Does anyone
know how to create one with the help the available git utils? The only
method that I can think of is to do everything manually. Any help w.r.t.
this is really appreciated. Thanks in advance.
--
View 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
Sent from the git mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: how to create a diff in old file new file format (for code reviews)
2010-12-14 0:07 how to create a diff in old file new file format (for code reviews) aerosmith
@ 2010-12-14 9:17 ` Michael J Gruber
2010-12-14 9:18 ` [PATCH 1/2] git-difftool.txt: correct the description of $BASE and describe $MERGED Michael J Gruber
2010-12-16 3:33 ` [solved] how to create a diff in old file new file format (for code reviews) Seshu Parvataneni
0 siblings, 2 replies; 5+ messages in thread
From: Michael J Gruber @ 2010-12-14 9:17 UTC (permalink / raw)
To: aerosmith; +Cc: git
aerosmith venit, vidit, dixit 14.12.2010 01:07:
>
> Hi,
>
> I am trying to create a diff such that the original file (entire file) is
> saved something like file1.h.old and the new modified file as file1.h.new. I
> have read the various options for git-diff* tools but could not find one
> such utility. All I get is the removals and additions as a diff. Does anyone
> know how to create one with the help the available git utils? The only
> method that I can think of is to do everything manually. Any help w.r.t.
> this is really appreciated. Thanks in advance.
You could script around this e.g. with an external diff-helper. The
easiest way is to reuse difftool. For example,
git difftool -y -x echo <revexpression>
will give you pairs of names of temporary files for old/new, where
<revexpression> is what you would give to "git diff" to specify what to
diff.
With the patch I'm sending in a minute, the helper you specify with "-x"
can also access the basename easily, so that you could use "-x oldnew"
with a script "oldnew" containing
#!/bin/sh
cp "$1" "$BASE".old
cp "$2" "$BASE".new
Even without the patch, you could use
git difftool -y -x 'cp "$LOCAL" "$BASE".old; cp "$REMOTE" "$BASE.new";
#' <revexpression>
(all on one line) directly. But this requires insider knowledge and may
break some day.
Cheers,
Michael
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] git-difftool.txt: correct the description of $BASE and describe $MERGED
2010-12-14 9:17 ` Michael J Gruber
@ 2010-12-14 9:18 ` Michael J Gruber
2010-12-14 9:18 ` [PATCH 2/2] difftool: provide basename to external tools Michael J Gruber
2010-12-16 3:33 ` [solved] how to create a diff in old file new file format (for code reviews) Seshu Parvataneni
1 sibling, 1 reply; 5+ messages in thread
From: Michael J Gruber @ 2010-12-14 9:18 UTC (permalink / raw)
To: git; +Cc: David Aguilar
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
Documentation/git-difftool.txt | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 6fffbc7..756d95d 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -56,8 +56,9 @@ the configured command line will be invoked with the following
variables available: `$LOCAL` is set to the name of the temporary
file containing the contents of the diff pre-image and `$REMOTE`
is set to the name of the temporary file containing the contents
-of the diff post-image. `$BASE` is provided for compatibility
-with custom merge tool commands and has the same value as `$LOCAL`.
+of the diff post-image. `$MERGED` is the name of the file which is
+being compared. `$BASE` is provided for compatibility
+with custom merge tool commands and has the same value as `$MERGED`.
-x <command>::
--extcmd=<command>::
--
1.7.3.3.739.g52f77.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] difftool: provide basename to external tools
2010-12-14 9:18 ` [PATCH 1/2] git-difftool.txt: correct the description of $BASE and describe $MERGED Michael J Gruber
@ 2010-12-14 9:18 ` Michael J Gruber
0 siblings, 0 replies; 5+ messages in thread
From: Michael J Gruber @ 2010-12-14 9:18 UTC (permalink / raw)
To: git; +Cc: David Aguilar
Currently, only configured diff helpers get the basename of the file
being compared. Tools specified with "git difftool -x" only get the
names of temporary files for the different versions.
Export BASE so that an external tool can read the name from the
environment. Rather than using a third argument, this avoids breaking
existing scripts which may somewhat carelessly be using "$@" rather than
"$1" "$2".
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
Documentation/git-difftool.txt | 1 +
git-difftool--helper.sh | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-difftool.txt b/Documentation/git-difftool.txt
index 756d95d..db87f1d 100644
--- a/Documentation/git-difftool.txt
+++ b/Documentation/git-difftool.txt
@@ -65,6 +65,7 @@ with custom merge tool commands and has the same value as `$MERGED`.
Specify a custom command for viewing diffs.
'git-difftool' ignores the configured defaults and runs
`$command $LOCAL $REMOTE` when this option is specified.
+ Additionally, `$BASE` is set in the environment.
-g::
--gui::
diff --git a/git-difftool--helper.sh b/git-difftool--helper.sh
index 524f5ea..0594bf7 100755
--- a/git-difftool--helper.sh
+++ b/git-difftool--helper.sh
@@ -49,6 +49,7 @@ launch_merge_tool () {
fi
if use_ext_cmd; then
+ export BASE
eval $GIT_DIFFTOOL_EXTCMD '"$LOCAL"' '"$REMOTE"'
else
run_merge_tool "$merge_tool"
--
1.7.3.3.739.g52f77.dirty
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [solved] how to create a diff in old file new file format (for code reviews)
2010-12-14 9:17 ` Michael J Gruber
2010-12-14 9:18 ` [PATCH 1/2] git-difftool.txt: correct the description of $BASE and describe $MERGED Michael J Gruber
@ 2010-12-16 3:33 ` Seshu Parvataneni
1 sibling, 0 replies; 5+ messages in thread
From: Seshu Parvataneni @ 2010-12-16 3:33 UTC (permalink / raw)
To: Michael J Gruber; +Cc: git
Hi Michael,
Thanks very much for the reply. Your example with the difftool worked. This was what I was looking for.
--- On Tue, 12/14/10, Michael J Gruber <git@drmicha.warpmail.net> wrote:
> From: Michael J Gruber <git@drmicha.warpmail.net>
> Subject: Re: how to create a diff in old file new file format (for code reviews)
> To: "aerosmith" <parvata@rocketmail.com>
> Cc: git@vger.kernel.org
> Date: Tuesday, December 14, 2010, 1:17 AM
> aerosmith venit, vidit, dixit
> 14.12.2010 01:07:
> >
> > Hi,
> >
> > I am trying to create a diff such that the original
> file (entire file) is
> > saved something like file1.h.old and the new modified
> file as file1.h.new. I
> > have read the various options for git-diff* tools but
> could not find one
> > such utility. All I get is the removals and additions
> as a diff. Does anyone
> > know how to create one with the help the available git
> utils? The only
> > method that I can think of is to do everything
> manually. Any help w.r.t.
> > this is really appreciated. Thanks in advance.
>
> You could script around this e.g. with an external
> diff-helper. The
> easiest way is to reuse difftool. For example,
>
> git difftool -y -x echo <revexpression>
>
> will give you pairs of names of temporary files for
> old/new, where
> <revexpression> is what you would give to "git diff"
> to specify what to
> diff.
>
> With the patch I'm sending in a minute, the helper you
> specify with "-x"
> can also access the basename easily, so that you could use
> "-x oldnew"
> with a script "oldnew" containing
>
> #!/bin/sh
> cp "$1" "$BASE".old
> cp "$2" "$BASE".new
>
> Even without the patch, you could use
>
> git difftool -y -x 'cp "$LOCAL" "$BASE".old; cp "$REMOTE"
> "$BASE.new";
> #' <revexpression>
>
> (all on one line) directly. But this requires insider
> knowledge and may
> break some day.
>
> Cheers,
> Michael
> --
> To unsubscribe from this list: send the line "unsubscribe
> git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-12-16 3:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-14 0:07 how to create a diff in old file new file format (for code reviews) aerosmith
2010-12-14 9:17 ` Michael J Gruber
2010-12-14 9:18 ` [PATCH 1/2] git-difftool.txt: correct the description of $BASE and describe $MERGED Michael J Gruber
2010-12-14 9:18 ` [PATCH 2/2] difftool: provide basename to external tools Michael J Gruber
2010-12-16 3:33 ` [solved] how to create a diff in old file new file format (for code reviews) Seshu Parvataneni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).