summaryrefslogtreecommitdiff
path: root/t/t4012-diff-binary.sh
AgeCommit message (Collapse)AuthorFilesLines
2018-07-03t: use test_might_fail() instead of manipulating exit code manuallyLibravatar Eric Sunshine1-4/+2
These tests manually coerce the exit code of invoked commands to "success" when they don't care if the command succeeds or fails since failure of those commands should not cause the test to fail overall. In doing so, they intentionally break the &&-chain. Modernize by replacing manual exit code management with test_might_fail() and a normal &&-chain. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2016-08-11builtin/apply: make parse_single_patch() return -1 on errorLibravatar Christian Couder1-2/+2
To libify `git apply` functionality we have to signal errors to the caller instead of die()ing. To do that in a compatible manner with the rest of the error handling in builtin/apply.c, parse_single_patch() should return a negative integer instead of calling die(). Let's do that by using error() and let's adjust the related test cases accordingly. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-30t4012-diff-binary.sh: use the $( ... ) construct for command substitutionLibravatar Elia Pinto1-8/+8
The Git CodingGuidelines prefer the $(...) construct for command substitution instead of using the backquotes `...`. The backquoted form is the traditional method for command substitution, and is supported by POSIX. However, all but the simplest uses become complicated quickly. In particular, embedded command substitutions and/or the use of double quotes require careful escaping with the backslash character. The patch was generated by: for _f in $(find . -name "*.sh") do sed -i 's@`\(.*\)`@$(\1)@g' ${_f} done and then carefully proof-read. Signed-off-by: Elia Pinto <gitter.spiros@gmail.com> Reviewed-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-08-27Fix tests under GETTEXT_POISON on git-applyLibravatar Jiang Xin1-2/+2
Use the i18n-specific test functions in test scripts for git-apply. This issue was was introduced in the following commits: de373 i18n: apply: mark parseopt strings for translation 3638e i18n: apply: mark strings for translation and been broken under GETTEXT_POISON=YesPlease since. Signed-off-by: Jiang Xin <worldhello.net@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-16t4012: Use test_must_fail instead of if-elseLibravatar Alexander Strasser1-14/+2
Make the code less bulky and easier to read. Also do not overlook failures like e.g. git failing because of unexpected signals. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-16t4012: use 'printf' instead of 'dd' to generate a binary fileLibravatar Johannes Sixt1-1/+1
For some reason, 'echo X | dd bs=1k seek=1' creates a file with 2050 bytes on Windows instead of the expected 1026 bytes, so that a test fails. Since the actual contents of the file are irrelevant as long as there is at least one zero byte so that the diff machinery recognizes it as binary, use printf to generate it. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-16t4012: Re-indent test snippetsLibravatar Alexander Strasser1-34/+34
Most one-level indents were 1 HT (horizontal tab) followed by 1 SP. Remove the SP. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-16t4012: Make --shortstat test more robustLibravatar Alexander Strasser1-2/+2
The --shortstat test depends on the same scenario as the --stat test. Use the part of the same expected result for the --stat test to avoid duplicating it manually. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-16t4012: Break up pipe into serial redirectionsLibravatar Alexander Strasser1-1/+2
Do not hide possible git errors by masking its process exit status. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-16t4012: Actually quote the sed scriptLibravatar Alexander Strasser1-2/+2
The nested quoting is not needed in this cases, thus the previous version did work just fine. Nevertheless the usage is misleading, so just achieve nested quoting by using double quotes instead. Lower the probability of breakage in the future and make the code easier to read. NOTE: Just dropping the single quotes around the sed arguments would have also been possible. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-11t4012: Unquote git command fragment in test titleLibravatar Alexander Strasser1-1/+1
The command fragments are quoted nowhere else in title texts of this file, thus make this one consistent with all other titles. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-07-11t4012: modernize style for quotingLibravatar Alexander Strasser1-15/+20
This quoting style is used by all newly added test code. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-06-15Merge branch 'as/diff-shortstat-ignore-binary'Libravatar Junio C Hamano1-0/+12
# By Alexander Strasser * as/diff-shortstat-ignore-binary: diff: Only count lines in show_shortstats
2012-06-15diff: Only count lines in show_shortstatsLibravatar Alexander Strasser1-0/+12
Do not mix byte and line counts. Binary files have byte counts; skip them when accumulating line insertions/deletions. The regression was introduced in e18872b. Signed-off-by: Alexander Strasser <eclipse7@gmx.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-04-30diff --stat: use less columns for change countsLibravatar Zbigniew Jędrzejewski-Szmek1-0/+19
Number of columns required for change counts is now computed based on the maximum number of changed lines instead of being fixed. This means that usually a few more columns will be available for the filenames and the graph. The graph width logic is also modified to include enough space for "Bin XXX -> YYY bytes". If changes to binary files are mixed with changes to text files, change counts are padded to take at least three columns. And the other way around, if change counts require more than three columns, then "Bin"s are padded to align with the change count. This way, the +- part starts in the same column as "XXX -> YYY" part for binary files. This makes the graph easier to parse visually thanks to the empty column. This mimics the layout of diff --stat before this change. Tests and the tutorial are updated to reflect the new --stat output. This means either the removal of extra padding and/or the addition of up to three extra characters to truncated filenames. One test is added to check the graph alignment when a binary file change and text file change of more than 999 lines are committed together. Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-13test: use numstat instead of diffstat in binary-diff testLibravatar Jonathan Nieder1-6/+23
git's --stat output is intended for humans and since v1.7.9.2~13 (2012-02-01) varies by locale. The tests in this script using "apply --stat" are meant to check two things: - how binary file changes are accounted for and printed in git's diffstat format - that "git apply" can parse the various forms of binary diff Split these two kinds of check into separate tests, and use --numstat instead of --stat in the latter. This way, we lose less test coverage when git is being run without writing its output in the C locale (for example because GETTEXT_POISON is enabled) and there are fewer tests to change if the --stat output needs to be tweaked again. While at it, use commands separated by && that read and write to temporary files in place of pipelines so segfaults and other failures in the upstream of the processing pipeline don't get hidden. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-03-13test: use test_i18ncmp when checking --stat outputLibravatar Jonathan Nieder1-2/+2
Ever since v1.7.9.2~13 (2012-02-01), git's diffstat-style summary line produced by "git apply --stat", "git diff --stat", and "git commit" varies by locale, producing test failures when GETTEXT_POISON is set. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-07-19tests: cleanup binary test vector filesLibravatar Vitaliy Ivanov1-1/+1
The test4012.png test vector file that was originally used for t4012 to check operations on binary files was later reused in other tests, making it no longer consistent to name it after a specific test. Rename it to more generic "test-binary-1.png". While at it, rename test9200b to "test-binary-2.png" (even though it is only used by t9200). Signed-off-by: Vitaliy Ivanov <vitalivanov@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-13rev-list: handle %x00 NUL in user formatLibravatar Jeff King1-4/+0
The code paths for showing commits in "git log" and "git rev-list --graph" correctly handle embedded NULs by looking only at the resulting strbuf's length, and never treating it as a C string. The code path for regular rev-list, however, used printf("%s"), which resulted in truncated output. This patch uses fwrite instead, like the --graph code path. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-01-25tests: consolidate CR removal/addition functionsLibravatar Stephen Boyd1-4/+0
append_cr(), remove_cr(), q_to_nul() and q_to_cr() are defined in multiple tests. Consolidate them into test-lib.sh so we can stop redefining them. The use of remove_cr() in t0020 to test for a CR is replaced with a new function has_cr() to accurately reflect what is intended (the output of remove_cr() was being thrown away). Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-03-07MinGW: fix diff --no-index /dev/null ...Libravatar Johannes Schindelin1-1/+1
When launching "diff --no-index" with a parameter "/dev/null", the MSys bash converts the "/dev/null" to a "nul", which usually makes sense. But Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-10-18t4012: use test_cmp instead of cmpLibravatar Jeff King1-2/+2
This makes erroneous output slightly easier to see. We also flip the argument order to match our usual style. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-10-06Merge branch 'maint'Libravatar Shawn O. Pearce1-0/+21
* maint: Update release notes for 1.6.0.3 Teach rebase -i to honor pre-rebase hook docs: describe pre-rebase hook do not segfault if make_cache_entry failed make prefix_path() never return NULL fix bogus "diff --git" header from "diff --no-index" Fix fetch/clone --quiet when stdout is connected builtin-blame: Fix blame -C -C with submodules. bash: remove fetch, push, pull dashed form leftovers Conflicts: diff.c
2008-10-06fix bogus "diff --git" header from "diff --no-index"Libravatar Linus Torvalds1-0/+21
When "git diff --no-index" is given an absolute pathname, it would generate a diff header with the absolute path prepended by the prefix, like: diff --git a/dev/null b/foo Not only is this nonsensical, and not only does it violate the description of diffs given in git-diff(1), but it would produce broken binary diffs. Unlike text diffs, the binary diffs don't contain the filenames anywhere else, and so "git apply" relies on this header to figure out the filename. This patch just refuses to use an invalid name for anything visible in the diff. Now, this fixes the "git diff --no-index --binary a /dev/null" kind of case (and we'll end up using "a" as the basename), but some other insane cases are impossible to handle. If you do git diff --no-index --binary a /bin/echo you'll still get a patch like diff --git a/a b/bin/echo old mode 100644 new mode 100755 index ... and "git apply" will refuse to apply it for a couple of reasons, and the diff is simply bogus. And that, btw, is no longer a bug, I think. It's impossible to know whethe the user meant for the patch to be a rename or not. And as such, refusing to apply it because you don't know what name you should use is probably _exactly_ the right thing to do! Original problem reported by Imre Deak. Test script and problem description by Jeff King. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-09-03Merge branch 'maint'Libravatar Junio C Hamano1-2/+2
* maint: Start 1.6.0.2 maintenance cycle tests: use "git xyzzy" form (t7200 - t9001) tests: use "git xyzzy" form (t7000 - t7199) Fix passwd(5) ref and reflect that commit doens't use commit-tree improve handling of sideband message display tests: use "git xyzzy" form (t3600 - t6999) tests: use "git xyzzy" form (t0000 - t3599) checkout: fix message when leaving detached HEAD clone: fix creation of explicitly named target directory 'git foo' program identifies itself without dash in die() messages setup_git_directory(): fix move to worktree toplevel directory update-index: fix worktree setup Start conforming code to "git subcmd" style read-tree: setup worktree if merge is required grep: fix worktree setup diff*: fix worktree setup Conflicts: RelNotes t/t3900-i18n-commit.sh t/t7003-filter-branch.sh
2008-09-03tests: use "git xyzzy" form (t3600 - t6999)Libravatar Nanako Shiraishi1-2/+2
Converts tests between t3600-t6300. Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-08-17tests: use $TEST_DIRECTORY to refer to the t/ directoryLibravatar Junio C Hamano1-1/+1
Many test scripts assumed that they will start in a 'trash' subdirectory that is a single level down from the t/ directory, and referred to their test vector files by asking for files like "../t9999/expect". This will break if we move the 'trash' subdirectory elsewhere. To solve this, we earlier introduced "$TEST_DIRECTORY" so that they can refer to t/ directory reliably. This finally makes all the tests use it to refer to the outside environment. With this patch, and a one-liner not included here (because it would contradict with what Dscho really wants to do): | diff --git a/t/test-lib.sh b/t/test-lib.sh | index 70ea7e0..60e69e4 100644 | --- a/t/test-lib.sh | +++ b/t/test-lib.sh | @@ -485,7 +485,7 @@ fi | . ../GIT-BUILD-OPTIONS | | # Test repository | -test="trash directory" | +test="trash directory/another level/yet another" | rm -fr "$test" || { | trap - exit | echo >&5 "FATAL: Cannot prepare test area" all the tests still pass, but we would want extra sets of eyeballs on this type of change to really make sure. [jc: with help from Stephan Beyer on http-push tests I do not run myself; credits for locating silly quoting errors go to Olivier Marin.] Signed-off-by: Junio C Hamano <gitster@pobox.com>
2007-07-02Rewrite "git-frotz" to "git frotz"Libravatar Junio C Hamano1-13/+13
This uses the remove-dashes target to replace "git-frotz" to "git frotz". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2006-05-25tests: Remove heredoc usage inside quotesLibravatar Eric Wong1-11/+6
The use of heredoc inside quoted strings doesn't seem to be supported by dash. pdksh seems to handle it fine, however. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-05-06binary diff and apply: testsuite.Libravatar Junio C Hamano1-0/+85
Signed-off-by: Junio C Hamano <junkio@cox.net>