summaryrefslogtreecommitdiff
path: root/git-difftool.perl
AgeCommit message (Collapse)AuthorFilesLines
2014-02-24difftool: support repositories with .git-filesLibravatar David Aguilar1-16/+2
Modern versions of "git submodule" use .git-files to setup the submodule directory. When run in a "git submodule"-created repository "git difftool --dir-diff" dies with the following error: $ git difftool -d HEAD~ fatal: This operation must be run in a work tree diff --raw --no-abbrev -z HEAD~: command returned error: 128 core.worktree is relative to the .git directory but the logic in find_worktree() does not account for it. Use `git rev-parse --show-toplevel` to find the worktree so that the dir-diff feature works inside a submodule. Reported-by: Gábor Lipták <gabor.liptak@gmail.com> Helped-by: Jens Lehmann <jens.lehmann@web.de> Helped-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-29difftool --dir-diff: allow changing any clean working tree fileLibravatar Kenichi Saita1-7/+2
The temporary directory prepared by "difftool --dir-diff" to show the result of a change can be modified by the user via the tree diff program, and we try hard not to lose changes to them after tree diff program returns to us. However, the set of files to be copied back is computed differently between --symlinks and --no-symlinks modes. The former checks all paths that start out as identical to the working tree file, while the latter checks paths that already had a local modification in the working tree, allowing changes made in the tree diff program to paths that did not have any local change to be lost. Signed-off-by: Kenichi Saita <nitoyon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-17difftool: fix dir-diff when file does not exist in working treeLibravatar John Keeping1-0/+6
Commit 02c5631 (difftool --dir-diff: symlink all files matching the working tree, 2013-03-14) does not handle the case where a file that is being compared does not exist in the working tree. Fix this by checking for existence explicitly before running git-hash-object. Reported-by: Kevin Bracey <kevin@bracey.fi> Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-29difftool: don't overwrite modified filesLibravatar John Keeping1-14/+71
After running the user's diff tool, git-difftool will copy any files that differ between the working tree and the temporary tree. This is useful when the user edits the file in their diff tool but is wrong if they edit the working tree file while examining the diff. Instead of copying unconditionally when the files differ, create and index from the working tree files and only copy the temporary file back if it was modified and the working tree file was not. If both files have been modified, print a warning and exit with an error. Note that we cannot use an existing index in git-difftool since those contain the modified files that need to be checked out but here we are looking at those files which are copied from the working tree and not checked out. These are precisely the files which are not in the existing indices. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-28Merge branch 'jk/difftool-dir-diff-edit-fix'Libravatar Junio C Hamano1-4/+21
"git difftool --dir-diff" made symlinks to working tree files when preparing a temporary directory structure, so that accidental edits of these files in the difftool are reflected back to the working tree, but the logic to decide when to do so was not quite right. * jk/difftool-dir-diff-edit-fix: difftool --dir-diff: symlink all files matching the working tree difftool: avoid double slashes in symlink targets git-difftool(1): fix formatting of --symlink description
2013-03-14difftool --dir-diff: symlink all files matching the working treeLibravatar John Keeping1-3/+18
Some users like to edit files in their diff tool when using "git difftool --dir-diff --symlink" to compare against the working tree but difftool currently only created symlinks when a file contains unstaged changes. Change this behaviour so that symlinks are created whenever the right-hand side of the comparison has the same SHA1 as the file in the working tree. Note that textconv filters are handled in the same way as by git-diff and if a clean filter is not the inverse of its smudge filter we already get a null SHA1 from "diff --raw" and will symlink the file without going through the new hash-object based check. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-14difftool: avoid double slashes in symlink targetsLibravatar John Keeping1-1/+3
When we add tests for symlinks in "git difftool --dir-diff" it's easier to check the target path if we don't have to worry about double slashes separating directories. Remove the trailing slash (if present) from $workdir before creating the symlinks in order to avoid this. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-17difftool: silence uninitialized variable warningLibravatar David Aguilar1-1/+1
Git::config() returns `undef` when given keys that do not exist. Check that the $guitool value is defined to prevent a noisy "Use of uninitialized variable $guitool in length" warning. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-25git-difftool: use git-mergetool--lib for "--tool-help"Libravatar John Keeping1-48/+7
The "--tool-help" option to git-difftool currently displays incorrect output since it uses the names of the files in "$GIT_EXEC_PATH/mergetools/" rather than the list of command names in git-mergetool--lib. Fix this by simply delegating the "--tool-help" argument to the show_tool_help function in git-mergetool--lib. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-21difftool: silence warningLibravatar Ross Lagerwall1-1/+1
Silence a warning given when running git difftool --dir-diff and there are no changes. This is because command_oneline returns undef when the command has no output, not ''. Signed-off-by: Ross Lagerwall <rosslagerwall@gmail.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-26difftool: Disable --symlinks on cygwinLibravatar David Aguilar1-1/+2
Symlinks are not ubiquitous on Windows so make --no-symlinks the default. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-26difftool: Handle compare() returning -1Libravatar David Aguilar1-31/+68
Keep the temporary directory around when compare() cannot read its input files, which is indicated by -1. Defer tempdir creation to allow an early exit in setup_dir_diff(). Wrap the rest of the entry points in an exit_cleanup() function to handle removing temporary files and error reporting. Print the temporary files' location so that the user can recover them. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-26difftool: Wrap long lines for readabilityLibravatar David Aguilar1-14/+32
Keep everything within 80 columns. Wrap the user-facing messages too. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-25difftool: Check all return codes from compare()Libravatar David Aguilar1-1/+10
Handle the case where compare() is unable to read its inputs. Emit a warning so that the user knows that something went wrong. We may later want to restructure the code so that we can inhibit tempdir cleanup when this condition is reached. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-25difftool: Handle finding mergetools/ in a path with spacesLibravatar David Aguilar1-6/+21
Use the original File::Find implementation from bf73fc2 (difftool: print list of valid tools with '--tool-help', 2012-03-29) so that we properly handle mergetools/ being located in a path containing spaces. One small difference is that we avoid using a global variable by passing a reference to the list of tools. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-23difftool: Use symlinks when diffing against the worktreeLibravatar David Aguilar1-10/+23
Teach difftool's --dir-diff mode to use symlinks to represent files from the working copy, and make it the default behavior for the non-Windows platforms. Using symlinks is simpler and safer since we do not need to worry about copying files back into the worktree. The old behavior is still available as --no-symlinks. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-22difftool: Call the temp directory "git-difftool"Libravatar David Aguilar1-1/+1
The "diffall" name was left over from when this functionality was part of the "git-diffall" script in contrib/. Make the naming consistent. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-22difftool: Move option values into a hashLibravatar David Aguilar1-24/+31
Shorten the "my" declaration for all of the option-specific variables by wrapping all of them in a hash. This also gives us a place to specify default values, should we need them. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-22difftool: Eliminate global variablesLibravatar David Aguilar1-53/+75
Organize the script so that it has a single main() function which calls out to dir_diff() and file_diff() functions. This eliminates "dir-diff"-specific variables that do not need to be calculated when performing a regular file-diff. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-22difftool: Simplify print_tool_help()Libravatar David Aguilar1-20/+5
Eliminate a global variable and File::Find usage by building upon basename() and glob() instead. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-19difftool: only copy back files modified during directory diffLibravatar Tim Henigan1-2/+5
When 'difftool --dir-diff' is used to compare working tree files, it always copies files from the tmp dir back to the working tree when the diff tool is closed, even if the files were not modified by the diff tool. This causes the file timestamp to change. Files should only be copied from the tmp dir back to the working copy if they were actually modified. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-23difftool: print list of valid tools with '--tool-help'Libravatar Tim Henigan1-2/+53
Since bc7a96a (mergetool--lib: Refactor tools into separate files, 2011-08-18), it is possible to add a new diff tool by creating a simple script in the '$(git --exec-path)/mergetools' directory. Updating the difftool help text is still a manual process, and the documentation can easily go out of sync. This commit teaches difftool the '--tool-help' option, which: - Reads the list of valid tools from 'mergetools/*' - Determines which of them are actually installed - Determines which are capable of diffing (i.e. not just a merge tool) - Prints the resulting list for the user Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-23difftool: teach difftool to handle directory diffsLibravatar Tim Henigan1-21/+245
When 'difftool' is called to compare a range of commits that modify more than one file, it opens a separate instance of the diff tool for each file that changed. The new '--dir-diff' option copies all the modified files to a temporary location and runs a directory diff on them in a single instance of the diff tool. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-23difftool: eliminate setup_environment functionLibravatar Tim Henigan1-7/+2
Removing this function shortens the code and makes it easier to read. Now all environment variables are set as part of procedural operation. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-23difftool: stop appending '.exe' to gitLibravatar Tim Henigan1-10/+1
The system call to Git works the same whether or not ".exe" is appended to "git". The extra code is not necessary. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-23difftool: remove explicit change of PATHLibravatar Tim Henigan1-4/+0
Adding the script directory to PATH is not needed. The script is located at '$(git --exec-path)', which is already on the PATH. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-23difftool: exit(0) when usage is printedLibravatar Tim Henigan1-4/+5
Prior to this commit, the script exited with an error whenever the usage string was printed, regardless of the reason it was done. In cases where usage was printed due to a user request (e.g. '-h' option), the script should exit without error (exit 0). This commit adds an argument to the usage function that allows the exit code to be specified when the function is called. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-23difftool: add '--no-gui' optionLibravatar Tim Henigan1-3/+4
This commit teaches difftool to handle the '--no-gui' option. This option negates the existing '--gui' option. The last setting given on the command line wins. This allows a user to configure "[alias] mdt = difftool --gui", but still have the ability to override the setting without error: $ git mdt --no-gui Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-23difftool: parse options using Getopt::LongLibravatar Tim Henigan1-65/+46
Replace custom option/argument parser with standard Getopt::Long module. This shortens the code and makes it easier to understand. Signed-off-by: Tim Henigan <tim.henigan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-05use -h for synopsis and --help for manpage consistentlyLibravatar Clemens Buchacher1-1/+1
A few scripted Porcelain implementations pretend as if the routine to show their own help messages are triggered upon "git cmd --help", but a command line parser of "git" will hijack such a request and shows the manpage for the cmd subcommand. Leaving the code to handle such input is simply misleading. Signed-off-by: Clemens Buchacher <drizzd@aon.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-12-14difftool: Fix failure on CygwinLibravatar Ramsay Jones1-4/+8
In particular, test 14 'difftool last flag wins' in t7800 fails. This is caused by git-difftool.perl passing both GIT_DIFFTOOL_NO_PROMPT (='true') and GIT_DIFFTOOL_PROMPT (='true') to the difftool helper script. Despite the appropriate key being deleted from the ENV hash, it seems that once a key has been set in the hash, it gets passed along to the system() call. (ie deleting the key does not do the equivalent of unsetenv()). In order to fix the problem, we keep track of the required prompt state while processing the arguments, and then set the relevant ENV hash key only once at the end. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-27perl: bump the required Perl version to 5.8 from 5.6.[21]Libravatar Ævar Arnfjörð Bjarmason1-0/+1
Formalize our dependency on perl 5.8, bumped from 5.6.[12]. We already used the three-arg form of open() which was introduced in 5.6.1, but t/t9700/test.pl explicitly depended on 5.6.2. However git-add--interactive.pl has been failing on the 5.6 line since it was introduced in v1.5.0-rc0~12^2~2 back in 2006 due to this open syntax: sub run_cmd_pipe { my $fh = undef; open($fh, '-|', @_) or die; return <$fh>; } Which when executed dies on "Can't use an undefined value as filehandle reference". Several of our tests also fail on 5.6 (even more when compiled with NO_PERL_MAKEMAKER=1): t2016-checkout-patch.sh t3904-stash-patch.sh t3701-add-interactive.sh t7105-reset-patch.sh t7501-commit.sh t9700-perl-git.sh Our code is bitrotting on 5.6 with no-one interested in fixing it, and pinning us to such an ancient release of Perl is keeping us from using useful features introduced in the 5.8 release. The 5.6 series is now over 10 years old, and the 5.6.2 maintenance release almost 7. 5.8 on the other hand is more than 8 years old. All the modern Unix-like operating systems have now upgraded to it or a later version, and 5.8 packages are available for old IRIX, AIX Solaris and Tru64 systems. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Acked-by: Tor Arntsen <tor@spacetec.no> Acked-by: Randal L. Schwartz <merlyn@stonehenge.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-28difftool: Fix '--gui' when diff.guitool is unconfiguredLibravatar David Aguilar1-5/+7
When diff.guitool is unconfigured and "--gui" is specified git-difftool dies with the following error message: config diff.guitool: command returned error: 1 Catch the error so that the "--gui" flag is a no-op when diff.guitool is unconfigured. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-15difftool: Add '-x' and as an alias for '--extcmd'Libravatar David Aguilar1-7/+14
This adds '-x' as a shorthand for the '--extcmd' option. Arguments to '--extcmd' can be specified separately, which was not originally possible. This also fixes the brief help text so that it mentions both '-x' and '--extcmd'. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-09difftool: Allow specifying unconfigured commands with --extcmdLibravatar David Aguilar1-0/+4
git-difftool requires difftool.<tool>.cmd configuration even when tools use the standard "$diffcmd $from $to" form. This teaches git-difftool to run these tools in lieu of configuration by allowing the command to be specified on the command line. Reference: http://article.gmane.org/gmane.comp.version-control.git/133377 Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-03git-difftool: Add '--gui' for selecting a GUI toolLibravatar David Aguilar1-1/+12
Users might prefer to have git-difftool use a different tool when run from a Git GUI. This teaches git-difftool to honor 'diff.guitool' when the '--gui' option is specified. This allows users to configure their preferred command-line diff tool in 'diff.tool' and a GUI diff tool in 'diff.guitool'. Reference: http://article.gmane.org/gmane.comp.version-control.git/133386 Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-24Explain seemingly pointless use of system in difftoolLibravatar Alex Riesen1-0/+6
Portability reasons. Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-22Wait for git diff to finish in git difftoolLibravatar Alex Riesen1-1/+2
In ActivetState Perl, exec does not wait for the started program. This breaks difftool tests and may cause unexpected behaviour: git difftool has returned, but the rest of code (diff and possibly the interactive program are still running in the background. Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-07difftool: add support for a difftool.prompt config variableLibravatar David Aguilar1-3/+12
difftool now supports difftool.prompt so that users do not have to pass --no-prompt or hit enter each time a diff tool is launched. The --prompt flag overrides the configuration variable. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-04-07difftool: move 'git-difftool' out of contribLibravatar David Aguilar1-0/+76
This prepares 'git-difftool' and its documentation for mainstream use. 'git-difftool-helper' became 'git-difftool--helper' since users should not use it directly. 'git-difftool' was added to the list of commands as an ancillaryinterrogator. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>