/* ** Copyright (c) 2007 D. Richard Hipp ** ** This program is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public ** License version 2 as published by the Free Software Foundation. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ** General Public License for more details. ** ** You should have received a copy of the GNU General Public ** License along with this library; if not, write to the ** Free Software Foundation, Inc., 59 Temple Place - Suite 330, ** Boston, MA 02111-1307, USA. ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** This file contains code used to implement the "diff" command */ #include "config.h" #include "diffcmd.h" #include /* ** Shell-escape the given string. Append the result to a blob. */ static void shell_escape(Blob *pBlob, const char *zIn){ int n = blob_size(pBlob); int k = strlen(zIn); int i; char *z; blob_appendf(pBlob, "\"%s\"", zIn); z = blob_buffer(pBlob); for(i=n+1; i<=n+k; i++){ if( z[i]=='"' ) z[i] = '_'; } } /* ** COMMAND: diff ** COMMAND: tkdiff ** ** Usage: %fossil diff|tkdiff FILE... ** Show the difference between the current version of a file (as it ** exists on disk) and that same file as it was checked out. Use ** either "diff -u" or "tkdiff". */ void diff_cmd(void){ const char *zFile; Blob cmd; Blob fname; int i; char *zV1 = 0; char *zV2 = 0; if( g.argc<3 ){ usage("?OPTIONS? FILE"); } db_must_be_within_tree(); blob_zero(&cmd); blob_appendf(&cmd, "%s ", g.argv[1]); for(i=2; i