summaryrefslogtreecommitdiff
path: root/t/t7800-difftool.sh
AgeCommit message (Collapse)Author
2016-08-12Merge branch 'jk/difftool-in-subdir' into maintJunio C Hamano
"git difftool <paths>..." started in a subdirectory failed to interpret the paths relative to that directory, which has been fixed. * jk/difftool-in-subdir: difftool: use Git::* functions instead of passing around state difftool: avoid $GIT_DIR and $GIT_WORK_TREE difftool: fix argument handling in subdirs
2016-07-28difftool: avoid $GIT_DIR and $GIT_WORK_TREEDavid Aguilar
Environment variables are global and hard to reason about. Use the `--git-dir` and `--work-tree` arguments when invoking `git` instead of relying on the environment. Add a test to ensure that difftool's dir-diff feature works when these variables are present in the environment. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-07-11Merge branch 'ak/t7800-wo-readlink' into maintJunio C Hamano
One among four invocations of readlink(1) in our test suite has been rewritten so that the test can run on systems without the command (others are in valgrind test framework and t9802). * ak/t7800-wo-readlink: t7800: readlink may not be available
2016-06-21t7800: readlink may not be availableArmin Kunaschik
The readlink(1) command is not available on all platforms (notably not on AIX and HP-UX) and can be replaced in this test with the "workaround" ls -ld <name> | sed -e 's/.* -> //' This is no universal readlink replacement but works in the controlled test environment well enough. Signed-off-by: Armin Kunaschik <megabreit@googlemail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-23Merge branch 'da/difftool'Junio C Hamano
"git difftool" learned to handle unmerged paths correctly in dir-diff mode. * da/difftool: difftool: handle unmerged files in dir-diff mode difftool: initialize variables for readability
2016-05-16difftool: handle unmerged files in dir-diff modeDavid Aguilar
When files are unmerged they can show up as both unmerged and modified in the output of `git diff --raw`. This causes difftool's dir-diff to create filesystem entries for the same path twice, which fails when it encounters a duplicate path. Ensure that each worktree path is only processed once. Add a test to demonstrate the breakage. Reported-by: Jan Smets <jan@smets.cx> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-05-03Merge branch 'nf/mergetool-prompt'Junio C Hamano
UI consistency improvements. * nf/mergetool-prompt: difftool/mergetool: make the form of yes/no questions consistent
2016-04-25difftool/mergetool: make the form of yes/no questions consistentNikola Forró
Every yes/no question in difftool/mergetool scripts has slightly different form, and none of them is consistent with the form git itself uses. Make the form of all the questions consistent with the form used by git. Reviewed-by: John Keeping <john@keeping.me.uk> Signed-off-by: Nikola Forró <nforro@redhat.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-01-28mingw: work around pwd issues in the testsJohannes Schindelin
In Git for Windows' SDK, the tests are run using a Bash that relies on the POSIX emulation layer MSYS2 (itself a friendly fork of Cygwin). As such, paths in tests can be POSIX paths. As soon as those paths are passed to git.exe (which does *not* use the POSIX emulation layer), those paths are converted into Windows paths, though. This happens for command-line parameters, but not when reading, say, config variables. To help with that, the `pwd` command is overridden to return the Windows path of the current working directory when testing Git on Windows. However, when talking to anything using the POSIX emulation layer, it is really much better to use POSIX paths because Windows paths contain a colon after the drive letter that will easily be mistaken for the common separator in path lists. So let's just use the $PWD variable when the POSIX path is needed. This lets t7800-difftool.sh, t9400-git-cvsserver-server.sh, t9402-git-cvsserver-refs.sh and t9401-git-cvsserver-crlf.sh pass in Git for Windows' SDK. Note: the cvsserver tests require not only the `cvs` package (install it into Git for Windows' SDK via `pacman -S cvs`) but also the Perl SQLite bindings (install them into Git for Windows' SDK via `cpan DBD::SQLite`). This patch is based on earlier work by 마누엘 and Karsten Blees. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-12-11Merge branch 'jk/test-lint-forbid-when-finished-in-subshell' into maintJunio C Hamano
Because "test_when_finished" in our test framework queues the clean-up tasks to be done in a shell variable, it should not be used inside a subshell. Add a mechanism to allow 'bash' to catch such uses, and fix the ones that were found. * jk/test-lint-forbid-when-finished-in-subshell: test-lib-functions: detect test_when_finished in subshell t7800: don't use test_config in a subshell test-lib-functions: support "test_config -C <dir> ..." t5801: don't use test_when_finished in a subshell t7610: don't use test_config in a subshell
2015-11-03Merge branch 'da/difftool'Junio C Hamano
The code to prepare the working tree side of temporary directory for the "dir-diff" feature forgot that symbolic links need not be copied (or symlinked) to the temporary area, as the code already special cases and overwrites them. Besides, it was wrong to try computing the object name of the target of symbolic link, which may not even exist or may be a directory. * da/difftool: difftool: ignore symbolic links in use_wt_file
2015-10-29difftool: ignore symbolic links in use_wt_fileDavid Aguilar
The caller is preparing a narrowed-down copy of the working tree and this function is asked if the path should be included in that copy. If we say yes, the path from the working tree will be either symlinked or copied into the narrowed-down copy. For any path that is a symbolic link, the caller later fixes up the narrowed-down copy by unlinking the path and replacing it with a regular file it writes out that mimics the way how "git diff" compares symbolic links. Let's answer "no, you do not want to copy/symlink the working tree file" for all symbolic links from this function, as we know the result will not be used because it will be overwritten anyway. Incidentally, this also stops the function from feeding a symbolic link in the working tree to hash-object, which is a wrong thing to do to begin with. The link may be pointing at a directory, or worse may be dangling (both would be noticed as an error). Even if the link points at a regular file, hashing the contents of a file that is pointed at by the link is not correct (Git hashes the contents of the link itself, not the pointee). Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-09-08t7800: don't use test_config in a subshellJohn Keeping
Use the new "-C" option to test_config to change the configuration in the submodule from the top level of the test so that it can be unset correctly when the test finishes. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-11-14difftool: honor --trust-exit-code for builtin toolsDavid Aguilar
run_merge_tool() was not setting $status, which prevented the exit code for builtin tools from being forwarded to the caller. Capture the exit status and add a test to guarantee the behavior. Reported-by: Adria Farres <14farresa@gmail.com> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-10-28difftool: add support for --trust-exit-codeDavid Aguilar
Teach difftool to exit when a diff tool returns a non-zero exit code when either --trust-exit-code is specified or difftool.trustExitCode is true. Forward exit codes from invoked diff tools to the caller when --trust-exit-code is used. Suggested-by: Adri Farr <14farresa@gmail.com> Helped-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-10-27difftool--helper: exit when reading a prompt answer failsJohannes Sixt
An attempt to quit difftool by hitting Ctrl-D (EOF) at its prompt does not quit it, but is treated as if 'yes' was answered to the prompt and all following prompts, which is contrary to the user's intent. Fix the error check. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-21run_external_diff: clean up error handlingJeff King
When the external diff reports an error, we try to clean up and die. However, we can make this process a bit simpler: 1. We do not need to bother freeing memory, since we are about to exit. Nor do we need to clean up our tempfiles, since the atexit() handler will do it for us. So we can die as soon as we see the error. 3. We can just call die() rather than fprintf/exit. This does technically change our exit code, but the exit code of "1" is not meaningful here. In fact, it is probably wrong, since "1" from diff usually means "completed successfully, but there were differences". And while we're there, we can mark the error message for translation, and drop the full stop at the end to make it more like our other messages. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-03-05t7800: add a difftool test for .git-filesJunio C Hamano
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 fileKenichi Saita
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 treeJohn Keeping
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-29t7800: run --dir-diff tests with and without symlinksJohn Keeping
Currently the difftool --dir-diff tests may or may not use symlinks depending on the operating system on which they are run. In one case this has caused a test failure to be noticed only on Windows when the test also fails on Linux when difftool is invoked with --no-symlinks. Rewrite these tests so that they do not depend on the environment but run explicitly with both --symlinks and --no-symlinks, protecting the --symlinks version with a SYMLINKS prerequisite. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-29t7800: fix tests when difftool uses --no-symlinksJohn Keeping
When 'git difftool --dir-diff' is using --no-symlinks (either explicitly or implicitly because it's running on Windows), any working tree files that have been copied to the temporary directory are copied back after the difftool completes. Because an earlier test uses "git add .", the "output" file used by tests is tracked by Git and the following sequence occurs during some tests: 1) the shell opens "output" to redirect the difftool output 2) difftool copies the empty "output" to the temporary directory 3) difftool runs "ls" which writes to "output" 4) difftool copies the empty "output" file back over the output of the command 5) the output file doesn't contain the expected output, causing the test to fail Instead of adding all changes, explicitly add only the files that the test is using, allowing later tests to write their result files into the working tree. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-29t7800: don't hide grep outputJohn Keeping
Remove the stdin_contains and stdin_doesnt_contain helper functions which add nothing but hide the output of grep, hurting debugging. Suggested-by: Johannes Sixt <j.sixt@viscovery.net> 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 filesJohn Keeping
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-29t7800: move '--symlinks' specific test to the endJohn Keeping
This will group the tests more logically when we introduce a helper to run most --dir-diff tests with both --symlinks and --no-symlinks. 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'Junio C Hamano
"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 treeJohn Keeping
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-02-21t7800: "defaults" is no longer a builtin tool nameDavid Aguilar
073678b8e6324a155fa99f40eee0637941a70a34 reworked the mergetools/ directory so that every file corresponds to a difftool-supported tool. When this happened the "defaults" file went away as it was no longer needed by mergetool--lib. t7800 tests that configured commands can override builtins, but this test was not adjusted when the "defaults" file was removed because the test continued to pass. Adjust the test to use the everlasting "vimdiff" tool name instead of "defaults" so that it correctly tests against a tool that is known by mergetool--lib. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-21t7800: modernize testsDavid Aguilar
Eliminate a lot of redundant work by using test_config(). Catch more return codes by more use of temporary files and test_cmp. The original tests relied upon restore_test_defaults() from the previous test to provide the next test with a sane environment. Make the tests do their own setup so that they are not dependent on the success of the previous test. The end result is shorter tests and better test isolation. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-20t7800: update copyright noticeDavid Aguilar
Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-09-25mergetool--lib: Allow custom commands to override built-insDavid Aguilar
Allow users to override the default commands provided by the mergetools/* scriptlets. Users occasionally run into problems where they expect to be able to override the built-in tool names. The documentation does not explicitly mention that built-ins cannot be overridden, so it's easy to assume that it should work. Lift this restriction so that built-in tools are handled the same way as user-configured tools. Add tests to guarantee this behavior. A nice benefit of this change is that it protects users from having future versions of git trump their custom configuration with a new built-in tool. C.f.: http://stackoverflow.com/questions/7435002/mergetool-from-gitconfig-being-ignored http://thread.gmane.org/gmane.comp.version-control.msysgit/13188 http://thread.gmane.org/gmane.comp.version-control.git/148267 Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-05-07Merge branch 'th/difftool-diffall'Junio C Hamano
Rolls the two-directory-diff logic from diffall script (in contrib/) into "git difftool" framework. By Tim Henigan * th/difftool-diffall: difftool: print list of valid tools with '--tool-help' difftool: teach difftool to handle directory diffs difftool: eliminate setup_environment function difftool: stop appending '.exe' to git difftool: remove explicit change of PATH difftool: exit(0) when usage is printed difftool: add '--no-gui' option difftool: parse options using Getopt::Long
2012-04-23difftool: print list of valid tools with '--tool-help'Tim Henigan
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 diffsTim Henigan
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: add '--no-gui' optionTim Henigan
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-19t7800: Test difftool passing arguments to diffDavid Aguilar
git-difftool relies on the ability to forward unknown arguments to the git-diff command. Add a test to ensure that this works as advertised. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-14t7800: avoid arithmetic expansion notationJunio C Hamano
The construct "var=$(( something ..." is interpreted by some shells as arithmetic expansion, even when it clearly is not, e.g. var=$((foo; bar) | baz) Avoid the issue by giving an extra SP to help the parser, i.e. var=$( (foo; bar) | baz ) Noticed by Michael J Gruber. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-10-10git-difftool: allow skipping file by typing 'n' at promptSitaram Chamarty
This is useful if you forgot to restrict the diff to the paths you want to see, or selecting precisely the ones you want is too much typing. [jc: with a change to return from the function upon 'n' by Charles Bailey and a small tweak in stdin_doesnot_contain() in the test] Signed-off-by: Sitaram Chamarty <sitaram@atc.tcs.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-08-11test: consolidate definition of $LFJunio C Hamano
As we seem to need this variable that holds a single LF character in many places, define it in test-lib.sh and let the test scripts use it. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-06t7800 (difftool): add missing &&Elijah Newren
Also remove a call to 'git config --unset difftool.prompt', since that is already unset by restore_test_defaults. Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-08-18t/t7800-difftool.sh: Skip with prereq on no PERLÆvar Arnfjörð Bjarmason
Change t/t7800-difftool.sh to to skip with the the three-arg prereq form of test_expect_success instead of bailing out. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-06-25tests: Skip tests in a way that makes sense under TAPÆvar Arnfjörð Bjarmason
SKIP messages are now part of the TAP plan. A TAP harness now knows why a particular test was skipped and can report that information. The non-TAP harness built into Git's test-lib did nothing special with these messages, and is unaffected by these changes. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-03-28difftool: Fix '--gui' when diff.guitool is unconfiguredDavid Aguilar
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-23t7800-difftool.sh: Test mergetool.prompt fallbackDavid Aguilar
4cacc621 made difftool fall back to mergetool.prompt when difftool.prompt is unconfigured. This adds a test. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-16difftool: Update copyright notices to list each year separatelyDavid Aguilar
This is http://www.gnu.org/licenses/gpl-howto.html advises. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-15difftool: Use eval to expand '--extcmd' expressionsDavid Aguilar
It was not possible to pass quoted commands to '--extcmd'. By using 'eval' we ensure that expressions with spaces and quotes are supported. 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'David Aguilar
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-15t7800-difftool.sh: Simplify the --extcmd testDavid Aguilar
Instead of running 'grep', 'echo', and 'wc' we simply compare git-difftool's output against a known good value. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-10difftool: Allow specifying unconfigured commands with --extcmdDavid Aguilar
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-10difftool--helper: Remove use of the GIT_MERGE_TOOL variableDavid Aguilar
An undocumented mis-feature in git-difftool is that it allows you to specify a default difftool by setting GIT_MERGE_TOOL. This behavior was never documented and was included as an oversight back when git-difftool was maintained outside of git. git-mergetool never honored GIT_MERGE_TOOL so neither should git-difftool. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>