Correct command for diffmerge command line usage

Support for our DiffMerge utility.

Moderator: SourceGear


Posts: 5
Joined: Wed Aug 03, 2011 9:45 am
PostPosted: Wed Aug 03, 2011 10:08 am
I keep trying to diff to a file with diffmerge using the following command on the command line:

Code: Select all
sgdm.exe -diff C:\Documents and Settings\Owner\Desktop\ -unified DOCUMENT.txt DOCUMENT2.txt


but I keep getting unexpected parameter DOCUMENT2.TXT

what is the corrct way to do this?

Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
PostPosted: Wed Aug 03, 2011 10:29 am
If you're using sgdm, then that tells me you are trying to diff under Vault. Use the command of vault diff and follow the layout shown here: http://download.sourcegear.com/misc/vau ... c.htm#DIFF.

If you're trying to use the diff/merge tool that is it's own product downloaded from Vault, then your command would look like:
diffmerge.exe "full path to first item" "full path to second item"
Beth Kieler
SourceGear Technical Support

Posts: 5
Joined: Wed Aug 03, 2011 9:45 am
PostPosted: Wed Aug 03, 2011 10:54 am
The new version is sgdm.exe instead of diffmerge.exe so when I do it the way that you suggest I get diffmerge.exe not recognized and using the command you suggest with sgdm.exe does not result in an output file that is showing only the differences.

Posts: 8550
Joined: Wed Jun 21, 2006 8:24 pm
Location: SourceGear
PostPosted: Wed Aug 03, 2011 1:01 pm
Sorry about that. You are correct.

I can bring it up with a command like:
sgdm "C:\Documents and Settings\me\desktop\document.txt" "C:\Documents and Settings\me\desktop\document2.txt"

I will check a little further into the other options you have set and post again.
Beth Kieler
SourceGear Technical Support

Posts: 5
Joined: Wed Aug 03, 2011 9:45 am
PostPosted: Wed Aug 03, 2011 1:13 pm
Ok

Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
PostPosted: Wed Aug 03, 2011 3:59 pm
Yes, I changed the name of the .exe in the 3.3.1 release on windows
because of name conflict with a program called 'diffmerge.exe' in Microsoft's
Visual Studio package.

The problem first described in this thread is because of the spaces in
the pathnames; they should be quoted.

And the value associated with the --diff argument needs to be a
file name rather than a directory name.

If you installed the 3.3.1 MSI package, sgdm.exe should be in your PATH
so you could cd to your desktop directory and try it without the pathnames
(eliminate one issue as a first step).

cd c:\Documents and Settings\Owner\Desktop
sgdm.exe --diff=output.txt --unified DOCUMENT.txt DOCUMENT2.txt

jeff

Posts: 5
Joined: Wed Aug 03, 2011 9:45 am
PostPosted: Thu Aug 04, 2011 7:14 am
Thank you Jeff that command works. Is it possible for the output to only show differences only so that I can avoid stuff like @@ -1058,7 +1083,7 @@?

Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
PostPosted: Thu Aug 04, 2011 10:28 am
Are you asking if it is possible to just get the diffs without the per-change header lines ?
Or are you wanting to not get the ~3 lines of context before and after each change ?
Or both?

No we don't have command line options for either of those. Sorry.
Our command line output support is very minimal.

If you do a lot of command line diffing, you might install one of the gnu diff ports.
It has a lot of options to control the output.

jeff

Posts: 5
Joined: Wed Aug 03, 2011 9:45 am
PostPosted: Thu Aug 04, 2011 1:14 pm
Our command line output support is very minimal

But it does the job though.

Thanks for the assistance

Posts: 7
Joined: Wed Jul 20, 2011 2:58 pm
PostPosted: Fri Aug 12, 2011 1:26 pm
Hello folks:

I'm attempting something similar and running into problems. Directory diff with output to text file.

My command:
sgdm --diff=diff.txt expected actual

where 'expected' and 'actual' are intended to be existing directories. For the purposes of this exercise, I have made sure that there are differences between the two directories.

When run from a command shell there is no error reported and diff.txt is not created.

If I open the UI and do a folder diff, then I see what I expect to see

If I call a batch file that essentially does the same thing, and I trap ERRORCODE, I get back and error code of 3, which I believe is an error in the command line.

AdThanksVance,

Mike

Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
PostPosted: Fri Aug 12, 2011 1:46 pm
Sorry but the command line output option only works
for a pair of files. Not a pair of folders.

That's why you're getting the error code of 3. I would
have expected that it would have printed an error message
explaining that, but I guess not.

jeff

Posts: 7
Joined: Wed Jul 20, 2011 2:58 pm
PostPosted: Fri Aug 12, 2011 1:56 pm
Shucks....

Any suggestions? I have a handful of files (12). I guess I'll call sdgm for each file in expected and break out as soon as one results in a diff. When that happens, I launch sgdm via the UI on the pair of directories.

AdThanksVance

Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear
PostPosted: Fri Aug 12, 2011 2:18 pm
As I said earlier in this thread, our usage from the command line is quite limited.
It really wasn't designed as a scripting tool.

If you really want to drive things from a script, you might grab one
of the gnu diff ports (cygwin or a native one) and use it from the
script. They support diffing 2 directories quite nicely. They even
have an arg to just print the names of the files pairs that are different
and then you can use that info to launch diffmerge on each pair.

jeff

Posts: 7
Joined: Wed Jul 20, 2011 2:58 pm
PostPosted: Fri Aug 12, 2011 4:14 pm
Problem is I like your ruleset approach and have it working.

Almost got my batch script working too. So I'm good.

However, as time allows, I'll take a look at your recommendations.

Cheers,

Mike

Posts: 7
Joined: Wed Jul 20, 2011 2:58 pm
PostPosted: Tue Aug 16, 2011 1:58 pm
You were right.

Using diff with sed

Return to Support (DiffMerge)

Who is online

Users browsing this forum: No registered users and 6 guests

cron