summaryrefslogtreecommitdiff
path: root/t/t4012-diff-binary.sh
AgeCommit message (Collapse)Author
2014-04-30t4012-diff-binary.sh: use the $( ... ) construct for command substitutionElia Pinto
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-applyJiang Xin
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-elseAlexander Strasser
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 fileJohannes Sixt
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 snippetsAlexander Strasser
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 robustAlexander Strasser
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 redirectionsAlexander Strasser
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 scriptAlexander Strasser
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 titleAlexander Strasser
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 quotingAlexander Strasser
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'Junio C Hamano
# By Alexander Strasser * as/diff-shortstat-ignore-binary: diff: Only count lines in show_shortstats
2012-06-15diff: Only count lines in show_shortstatsAlexander Strasser
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 countsZbigniew Jędrzejewski-Szmek
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 testJonathan Nieder
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 outputJonathan Nieder
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 filesVitaliy Ivanov
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-14rev-list: handle %x00 NUL in user formatJeff King
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-26tests: consolidate CR removal/addition functionsStephen Boyd
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-08MinGW: fix diff --no-index /dev/null ...Johannes Schindelin
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 cmpJeff King
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'Shawn O. Pearce
* 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"Linus Torvalds
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'Junio C Hamano
* 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)Nanako Shiraishi
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/ directoryJunio C Hamano
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-03Rewrite "git-frotz" to "git frotz"Junio C Hamano
This uses the remove-dashes target to replace "git-frotz" to "git frotz". Signed-off-by: Junio C Hamano <gitster@pobox.com>
2006-05-26tests: Remove heredoc usage inside quotesEric Wong
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.Junio C Hamano
Signed-off-by: Junio C Hamano <junkio@cox.net>