diff options
76 files changed, 576 insertions, 231 deletions
diff --git a/Documentation/RelNotes-1.7.1.2.txt b/Documentation/RelNotes-1.7.1.2.txt new file mode 100644 index 0000000000..46b6a960c7 --- /dev/null +++ b/Documentation/RelNotes-1.7.1.2.txt @@ -0,0 +1,19 @@ +Git v1.7.1.2 Release Notes +========================== + +Fixes since v1.7.1.1 +-------------------- + + * "git commit" did not honor GIT_REFLOG_ACTION environment variable, resulting + reflog messages for cherry-pick and revert actions to be recorded as "commit". + + * "git clone/fetch/pull" issued an incorrect error message when a ref and + a symref that points to the ref were updated at the same time. This + obviously would update them to the same value, and should not result in + an error condition. + + * "git diff" inside a tree with many pathnames that have certain + characters has become very slow in 1.7.0 by mistake. + + * "git rev-parse --parseopt --stop-at-non-option" did not stop at non option + when --keep-dashdash was in effect. diff --git a/Documentation/RelNotes-1.7.2.txt b/Documentation/RelNotes-1.7.2.txt index aa79f06851..f24b3876af 100644 --- a/Documentation/RelNotes-1.7.2.txt +++ b/Documentation/RelNotes-1.7.2.txt @@ -4,10 +4,13 @@ Git v1.7.2 Release Notes (draft) Updates since v1.7.1 -------------------- - * core.eol configuration and eol attribute are the new way to control - the end of line conventions for files in the working tree; - core.autocrlf overrides it, keeping the traditional behaviour by - default. + * core.eol configuration and text/eol attributes are the new way to control + the end of line conventions for files in the working tree. + + * core.autocrlf has been made safer - it will now only handle line + endings for new files and files that are LF-only in the + repository. To normalize content that has been checked in with + CRLF, use the new eol/text attributes. * The whitespace rules used in "git apply --whitespace" and "git diff" gained a new member in the family (tab-in-indent) to help projects with @@ -45,8 +48,12 @@ Updates since v1.7.1 commit. * "git cherry-pick" learned to pick a range of commits - (e.g. "cherry-pick A..B" and "cherry-pick --stdin"); this does not - have nicer sequencing control "rebase [-i]" has, though. + (e.g. "cherry-pick A..B" and "cherry-pick --stdin"), so did "git + revert"; these do not support the nicer sequencing control "rebase + [-i]" has, though. + + * "git cherry-pick" and "git revert" learned --strategy option to specify + the merge strategy to be used when performing three-way merges. * "git cvsserver" can be told to use pserver; its password file can be stored outside the repository. @@ -74,7 +81,7 @@ Updates since v1.7.1 * Various options to "git grep" (e.g. --count, --name-only) work better with binary files. - * "git grep" learned "-Ovi" to open the files with hits in yoru editor. + * "git grep" learned "-Ovi" to open the files with hits in your editor. * "git help -w" learned "chrome" and "chromium" browsers. @@ -96,8 +103,6 @@ Updates since v1.7.1 * "git remote" learned "set-branches" subcommand. - * "git revert" learned --strategy option to specify the merge strategy. - * "git rev-list A..B" learned --ancestry-path option to further limit the result to the commits that are on the ancestry chain between A and B (i.e. commits that are not descendants of A are excluded). @@ -116,6 +121,8 @@ Updates since v1.7.1 highlighting, "plackup" support for instaweb, .fcgi suffix to run it as FastCGI script, etc. + * The test harness has been updated to produce TAP-friendly output. + Fixes since v1.7.1 ------------------ @@ -124,37 +131,25 @@ All of the fixes in v1.7.1.X maintenance series are included in this release, unless otherwise noted. * We didn't URL decode "file:///path/to/repo" correctly when path/to/repo - had percent-encoded characters (638794c, 9d2e942). - - * "git commit" did not honor GIT_REFLOG_ACTION environment variable, resulting - reflog messages for cherry-pick and revert actions to be recorded as "commit". - - * "git clone/fetch/pull" issued an incorrect error message when a ref and - a symref that points to the ref were updated at the same time. This - obviously would update them to the same value, and should not result in - an error condition (0e71bc3). + had percent-encoded characters (638794c, 9d2e942, ce83eda, 3c73a1d). * "git clone" did not configure remote.origin.url correctly for bare clones (df61c889). - * "git diff" inside a tree with many pathnames that have certain - characters has become very slow in 1.7.0 by mistake (will merge - e53e6b443 to 'maint'). - * "git diff --graph" works better with "--color-words" and other options (81fa024..4297c0a). * "git diff" could show ambiguous abbreviation of blob object names on its "index" line (3e5a188). - * "git rebase" did not faithfully reproduce a malformed author ident, that - is often seen in a repository converted from foreign SCMs (43c23251). - * "git reset --hard" started from a wrong directory and a working tree in a nonstandard location is in use got confused (560fb6a1). + * "git read-tree -m A B" used to switch to branch B while retaining + local changes added an incorrect cache-tree information (b1f47514). + -- exec >/var/tmp/1 -O=v1.7.2-rc0-60-g2927a50 +O=v1.7.2-rc2-17-gc9a9766 echo O=$(git describe HEAD) git shortlog --no-merges HEAD ^maint ^$O diff --git a/Documentation/config.txt b/Documentation/config.txt index 72949e71ac..e75434b3ef 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -886,9 +886,11 @@ format.headers:: Additional email headers to include in a patch to be submitted by mail. See linkgit:git-format-patch[1]. +format.to:: format.cc:: - Additional "Cc:" headers to include in a patch to be submitted - by mail. See the --cc option in linkgit:git-format-patch[1]. + Additional recipients to include in a patch to be submitted + by mail. See the --to and --cc options in + linkgit:git-format-patch[1]. format.subjectprefix:: The default for format-patch is to output files with the '[PATCH]' @@ -1732,6 +1734,15 @@ status.submodulesummary:: summary of commits for modified submodules will be shown (see --summary-limit option of linkgit:git-submodule[1]). +submodule.<name>.path:: +submodule.<name>.url:: +submodule.<name>.update:: + The path within this project, URL, and the updating strategy + for a submodule. These variables are initially populated + by 'git submodule init'; edit them to override the + URL and other values found in the `.gitmodules` file. See + linkgit:git-submodule[1] and linkgit:gitmodules[5] for details. + tar.umask:: This variable can be used to restrict the permission bits of tar archive entries. The default is 0002, which turns off the diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index 044ec882cc..9333c42c55 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -34,6 +34,7 @@ ifndef::git-pull[] Allow several <repository> and <group> arguments to be specified. No <refspec>s may be specified. +-p:: --prune:: After fetching, remove any remote tracking branches which no longer exist on the remote. diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt index 261dd90c38..1bacd2e104 100644 --- a/Documentation/git-checkout.txt +++ b/Documentation/git-checkout.txt @@ -263,7 +263,7 @@ the above checkout would fail like this: + ------------ $ git checkout mytopic -fatal: Entry 'frotz' not uptodate. Cannot merge. +error: You have local changes to 'frotz'; not switching branches. ------------ + You can give the `-m` flag to the command, which would try a diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt index a9e0882e9b..315f07ef1c 100644 --- a/Documentation/git-gc.txt +++ b/Documentation/git-gc.txt @@ -137,6 +137,13 @@ If you are expecting some objects to be collected and they aren't, check all of those locations and decide whether it makes sense in your case to remove those references. +HOOKS +----- + +The 'git gc --auto' command will run the 'pre-auto-gc' hook. See +linkgit:githooks[5] for more information. + + SEE ALSO -------- linkgit:git-prune[1] diff --git a/Documentation/git-rerere.txt b/Documentation/git-rerere.txt index acc220a00f..db99d4786e 100644 --- a/Documentation/git-rerere.txt +++ b/Documentation/git-rerere.txt @@ -7,7 +7,7 @@ git-rerere - Reuse recorded resolution of conflicted merges SYNOPSIS -------- -'git rerere' ['clear'|'diff'|'status'|'gc'] +'git rerere' ['clear'|'forget' [<pathspec>]|'diff'|'status'|'gc'] DESCRIPTION ----------- @@ -40,6 +40,11 @@ This resets the metadata used by rerere if a merge resolution is to be aborted. Calling 'git am [--skip|--abort]' or 'git rebase [--skip|--abort]' will automatically invoke this command. +'forget' <pathspec>:: + +This resets the conflict resolutions which rerere has recorded for the current +conflict in <pathspec>. The <pathspec> is optional. + 'diff':: This displays diffs for the current state of the resolution. It is diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt index 5daf750d19..72a13d18e0 100644 --- a/Documentation/gitmodules.txt +++ b/Documentation/gitmodules.txt @@ -29,6 +29,9 @@ submodule.<name>.path:: submodule.<name>.url:: Defines an url from where the submodule repository can be cloned. + This may be either an absolute URL ready to be passed to + linkgit:git-clone[1] or (if it begins with ./ or ../) a location + relative to the superproject's origin repository. submodule.<name>.update:: Defines what to do when the submodule is updated by the superproject. diff --git a/Documentation/technical/protocol-capabilities.txt b/Documentation/technical/protocol-capabilities.txt index fd1a593149..b15517fa06 100644 --- a/Documentation/technical/protocol-capabilities.txt +++ b/Documentation/technical/protocol-capabilities.txt @@ -119,7 +119,7 @@ both. ofs-delta --------- -Server can send, and client understand PACKv2 with delta refering to +Server can send, and client understand PACKv2 with delta referring to its base by position in pack rather than by an obj-id. That is, they can send/read OBJ_OFS_DELTA (aka type 6) in a packfile. @@ -2079,19 +2079,19 @@ endif test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \ ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \ cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \ - { for p in $(BUILT_INS); do \ + for p in $(BUILT_INS); do \ $(RM) "$$execdir/$$p" && \ ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \ ln -s "git$X" "$$execdir/$$p" 2>/dev/null || \ cp "$$execdir/git$X" "$$execdir/$$p" || exit; \ - done; } && \ - { test x"$(REMOTE_CURL_ALIASES)" = x || \ - { for p in $(REMOTE_CURL_ALIASES); do \ + done && \ + remote_curl_aliases="$(REMOTE_CURL_ALIASES)" && \ + for p in $$remote_curl_aliases; do \ $(RM) "$$execdir/$$p" && \ ln "$$execdir/git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \ ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \ cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \ - done; } ; } && \ + done && \ ./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X" install-gitweb: diff --git a/builtin/read-tree.c b/builtin/read-tree.c index 8bdcab1138..9ad1e66916 100644 --- a/builtin/read-tree.c +++ b/builtin/read-tree.c @@ -219,14 +219,9 @@ int cmd_read_tree(int argc, const char **argv, const char *unused_prefix) * "-m ent" or "--reset ent" form), we can obtain a fully * valid cache-tree because the index must match exactly * what came from the tree. - * - * The same holds true if we are switching between two trees - * using read-tree -m A B. The index must match B after that. */ if (nr_trees == 1 && !opts.prefix) prime_cache_tree(&active_cache_tree, trees[0]); - else if (nr_trees == 2 && opts.merge) - prime_cache_tree(&active_cache_tree, trees[1]); if (write_cache(newfd, active_cache, active_nr) || commit_locked_index(&lock_file)) diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index b676e29635..a5a1c86e92 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -407,8 +407,8 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix) ALLOC_GROW(opts, onb + 1, osz); memset(opts + onb, 0, sizeof(opts[onb])); argc = parse_options(argc, argv, prefix, opts, usage, - keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0 | - stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0 | + (keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0) | + (stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0) | PARSE_OPT_SHELL_EVAL); strbuf_addf(&parsed, " --"); @@ -635,7 +635,7 @@ int parse_date_toffset(const char *date, unsigned long *timestamp, int *offset) /* mktime uses local timezone */ *timestamp = tm_to_time_t(&tm); if (*offset == -1) - *offset = (*timestamp - mktime(&tm)) / 60; + *offset = ((time_t)*timestamp - mktime(&tm)) / 60; if (*timestamp == -1) return -1; @@ -2627,8 +2627,7 @@ static void fill_metainfo(struct strbuf *msg, (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two))) abbrev = 40; } - strbuf_addf(msg, "%s%sindex %s..", set, - line_prefix, + strbuf_addf(msg, "%s%sindex %s..", line_prefix, set, find_unique_abbrev(one->sha1, abbrev)); strbuf_addstr(msg, find_unique_abbrev(two->sha1, abbrev)); if (one->mode == two->mode) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 9446376535..cedc357313 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1027,18 +1027,18 @@ sub dispatch { $actions{$action}->(); } -sub run_request { +sub reset_timer { our $t0 = [Time::HiRes::gettimeofday()] if defined $t0; + our $number_of_git_cmds = 0; +} + +sub run_request { + reset_timer(); evaluate_uri(); - evaluate_gitweb_config(); - evaluate_git_version(); check_loadavg(); - # $projectroot and $projects_list might be set in gitweb config file - $projects_list ||= $projectroot; - evaluate_query_params(); evaluate_path_info(); evaluate_and_validate_params(); @@ -1086,6 +1086,11 @@ sub evaluate_argv { sub run { evaluate_argv(); + evaluate_gitweb_config(); + evaluate_git_version(); + + # $projectroot and $projects_list might be set in gitweb config file + $projects_list ||= $projectroot; $pre_listen_hook->() if $pre_listen_hook; @@ -1322,8 +1327,7 @@ sub esc_param { sub esc_url { my $str = shift; return undef unless defined $str; - $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg; - $str =~ s/\+/%2B/g; + $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&= ]+)/CGI::escape($1)/eg; $str =~ s/ /\+/g; return $str; } @@ -1090,6 +1090,15 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt) return ret; } +/* + * People using contrib's git-new-workdir have .git/logs/refs -> + * /some/other/path/.git/logs/refs, and that may live on another device. + * + * IOW, to avoid cross device rename errors, the temporary renamed log must + * live into logs/refs. + */ +#define TMP_RENAMED_LOG "logs/refs/.tmp-renamed-log" + int rename_ref(const char *oldref, const char *newref, const char *logmsg) { static const char renamed_ref[] = "RENAMED-REF"; @@ -1123,8 +1132,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) if (write_ref_sha1(lock, orig_sha1, logmsg)) return error("unable to save current sha1 in %s", renamed_ref); - if (log && rename(git_path("logs/%s", oldref), git_path("tmp-renamed-log"))) - return error("unable to move logfile logs/%s to tmp-renamed-log: %s", + if (log && rename(git_path("logs/%s", oldref), git_path(TMP_RENAMED_LOG))) + return error("unable to move logfile logs/%s to "TMP_RENAMED_LOG": %s", oldref, strerror(errno)); if (delete_ref(oldref, orig_sha1, REF_NODEREF)) { @@ -1150,7 +1159,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) } retry: - if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) { + if (log && rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", newref))) { if (errno==EISDIR || errno==ENOTDIR) { /* * rename(a, b) when b is an existing @@ -1163,7 +1172,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) } goto retry; } else { - error("unable to move logfile tmp-renamed-log to logs/%s: %s", + error("unable to move logfile "TMP_RENAMED_LOG" to logs/%s: %s", newref, strerror(errno)); goto rollback; } @@ -1203,8 +1212,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg) error("unable to restore logfile %s from %s: %s", oldref, newref, strerror(errno)); if (!logmoved && log && - rename(git_path("tmp-renamed-log"), git_path("logs/%s", oldref))) - error("unable to restore logfile %s from tmp-renamed-log: %s", + rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", oldref))) + error("unable to restore logfile %s from "TMP_RENAMED_LOG": %s", oldref, strerror(errno)); return 1; @@ -323,7 +323,8 @@ const char *setup_git_directory_gently(int *nongit_ok) const char *gitdirenv; const char *gitfile_dir; int len, offset, ceil_offset, root_len; - int current_device = 0, one_filesystem = 1; + dev_t current_device = 0; + int one_filesystem = 1; struct stat buf; /* @@ -18,25 +18,48 @@ The easiest way to run tests is to say "make". This runs all the tests. *** t0000-basic.sh *** - * ok 1: .git/objects should be empty after git-init in an empty repo. - * ok 2: .git/objects should have 256 subdirectories. - * ok 3: git-update-index without --add should fail adding. + ok 1 - .git/objects should be empty after git init in an empty repo. + ok 2 - .git/objects should have 3 subdirectories. + ok 3 - success is reported like this ... - * ok 23: no diff after checkout and git-update-index --refresh. - * passed all 23 test(s) - *** t0100-environment-names.sh *** - * ok 1: using old names should issue warnings. - * ok 2: using old names but having new names should not issue warnings. - ... - -Or you can run each test individually from command line, like -this: - - $ sh ./t3001-ls-files-killed.sh - * ok 1: git-update-index --add to add various paths. - * ok 2: git-ls-files -k to show killed files. - * ok 3: validate git-ls-files -k output. - * passed all 3 test(s) + ok 43 - very long name in the index handled sanely + # fixed 1 known breakage(s) + # still have 1 known breakage(s) + # passed all remaining 42 test(s) + 1..43 + *** t0001-init.sh *** + ok 1 - plain + ok 2 - plain with GIT_WORK_TREE + ok 3 - plain bare + +Since the tests all output TAP (see http://testanything.org) they can +be run with any TAP harness. Here's an example of parallel testing +powered by a recent version of prove(1): + + $ prove --timer --jobs 15 ./t[0-9]*.sh + [19:17:33] ./t0005-signals.sh ................................... ok 36 ms + [19:17:33] ./t0022-crlf-rename.sh ............................... ok 69 ms + [19:17:33] ./t0024-crlf-archive.sh .............................. ok 154 ms + [19:17:33] ./t0004-unwritable.sh ................................ ok 289 ms + [19:17:33] ./t0002-gitfile.sh ................................... ok 480 ms + ===( 102;0 25/? 6/? 5/? 16/? 1/? 4/? 2/? 1/? 3/? 1... )=== + +prove and other harnesses come with a lot of useful options. The +--state option in particular is very useful: + + # Repeat until no more failures + $ prove -j 15 --state=failed,save ./t[0-9]*.sh + +You can also run each test individually from command line, like this: + + $ sh ./t3010-ls-files-killed-modified.sh + ok 1 - git update-index --add to add various paths. + ok 2 - git ls-files -k to show killed files. + ok 3 - validate git ls-files -k output. + ok 4 - git ls-files -m to show modified files. + ok 5 - validate git ls-files -m output. + # passed all 5 test(s) + 1..5 You can pass --verbose (or -v), --debug (or -d), and --immediate (or -i) command line argument to the test, or by setting GIT_TEST_OPTS @@ -198,15 +221,101 @@ This test harness library does the following things: - If the script is invoked with command line argument --help (or -h), it shows the test_description and exits. - - Creates an empty test directory with an empty .git/objects - database and chdir(2) into it. This directory is 't/trash directory' - if you must know, but I do not think you care. + - Creates an empty test directory with an empty .git/objects database + and chdir(2) into it. This directory is 't/trash + directory.$test_name_without_dotsh', with t/ subject to change by + the --root option documented above. - Defines standard test helper functions for your scripts to use. These functions are designed to make all scripts behave consistently when command line arguments --verbose (or -v), --debug (or -d), and --immediate (or -i) is given. +Do's, don'ts & things to keep in mind +------------------------------------- + +Here are a few examples of things you probably should and shouldn't do +when writing tests. + +Do: + + - Put all code inside test_expect_success and other assertions. + + Even code that isn't a test per se, but merely some setup code + should be inside a test assertion. + + - Chain your test assertions + + Write test code like this: + + git merge foo && + git push bar && + test ... + + Instead of: + + git merge hla + git push gh + test ... + + That way all of the commands in your tests will succeed or fail. If + you must ignore the return value of something (e.g. the return + value of export is unportable) it's best to indicate so explicitly + with a semicolon: + + export HLAGH; + git merge hla && + git push gh && + test ... + +Don't: + + - exit() within a <script> part. + + The harness will catch this as a programming error of the test. + Use test_done instead if you need to stop the tests early (see + "Skipping tests" below). + + - Break the TAP output + + The raw output from your test may be interpreted by a TAP harness. TAP + harnesses will ignore everything they don't know about, but don't step + on their toes in these areas: + + - Don't print lines like "$x..$y" where $x and $y are integers. + + - Don't print lines that begin with "ok" or "not ok". + + TAP harnesses expect a line that begins with either "ok" and "not + ok" to signal a test passed or failed (and our harness already + produces such lines), so your script shouldn't emit such lines to + their output. + + You can glean some further possible issues from the TAP grammar + (see http://search.cpan.org/perldoc?TAP::Parser::Grammar#TAP_Grammar) + but the best indication is to just run the tests with prove(1), + it'll complain if anything is amiss. + +Keep in mind: + + - Inside <script> part, the standard output and standard error + streams are discarded, and the test harness only reports "ok" or + "not ok" to the end user running the tests. Under --verbose, they + are shown to help debugging the tests. + + +Skipping tests +-------------- + +If you need to skip all the remaining tests you should set skip_all +and immediately call test_done. The string you give to skip_all will +be used as an explanation for why the test was skipped. for instance: + + if ! test_have_prereq PERL + then + skip_all='skipping perl interface tests, perl not available' + test_done + fi End with test_done ------------------ @@ -222,9 +331,9 @@ Test harness library There are a handful helper functions defined in the test harness library for your script to use. - - test_expect_success <message> <script> + - test_expect_success [<prereq>] <message> <script> - This takes two strings as parameter, and evaluates the + Usually takes two strings as parameter, and evaluates the <script>. If it yields success, test is considered successful. <message> should state what it is testing. @@ -234,7 +343,14 @@ library for your script to use. 'git-write-tree should be able to write an empty tree.' \ 'tree=$(git-write-tree)' - - test_expect_failure <message> <script> + If you supply three parameters the first will be taken to be a + prerequisite, see the test_set_prereq and test_have_prereq + documentation below: + + test_expect_success TTY 'git --paginate rev-list uses a pager' \ + ' ... ' + + - test_expect_failure [<prereq>] <message> <script> This is NOT the opposite of test_expect_success, but is used to mark a test that demonstrates a known breakage. Unlike @@ -243,6 +359,16 @@ library for your script to use. success and "still broken" on failure. Failures from these tests won't cause -i (immediate) to stop. + Like test_expect_success this function can optionally use a three + argument invocation with a prerequisite as the first argument. + + - test_expect_code [<prereq>] <code> <message> <script> + + Analogous to test_expect_success, but pass the test if it exits + with a given exit <code> + + test_expect_code 1 'Merge with d/f conflicts' 'git merge "merge msg" B master' + - test_debug <script> This takes a single argument, <script>, and evaluates it only @@ -275,6 +401,85 @@ library for your script to use. Merges the given rev using the given message. Like test_commit, creates a tag and calls test_tick before committing. + - test_set_prereq SOME_PREREQ + + Set a test prerequisite to be used later with test_have_prereq. The + test-lib will set some prerequisites for you, e.g. PERL and PYTHON + which are derived from ./GIT-BUILD-OPTIONS (grep test_set_prereq + test-lib.sh for more). Others you can set yourself and use later + with either test_have_prereq directly, or the three argument + invocation of test_expect_success and test_expect_failure. + + - test_have_prereq SOME PREREQ + + Check if we have a prerequisite previously set with + test_set_prereq. The most common use of this directly is to skip + all the tests if we don't have some essential prerequisite: + + if ! test_have_prereq PERL + then + skip_all='skipping perl interface tests, perl not available' + test_done + fi + + - test_external [<prereq>] <message> <external> <script> + + Execute a <script> with an <external> interpreter (like perl). This + was added for tests like t9700-perl-git.sh which do most of their + work in an external test script. + + test_external \ + 'GitwebCache::*FileCache*' \ + "$PERL_PATH" "$TEST_DIRECTORY"/t9503/test_cache_interface.pl + + If the test is outputting its own TAP you should set the + test_external_has_tap variable somewhere before calling the first + test_external* function. See t9700-perl-git.sh for an example. + + # The external test will outputs its own plan + test_external_has_tap=1 + + - test_external_without_stderr [<prereq>] <message> <external> <script> + + Like test_external but fail if there's any output on stderr, + instead of checking the exit code. + + test_external_without_stderr \ + 'Perl API' \ + "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl + + - test_must_fail <git-command> + + Run a git command and ensure it fails in a controlled way. Use + this instead of "! <git-command>" to fail when git commands + segfault. + + - test_might_fail <git-command> + + Similar to test_must_fail, but tolerate success, too. Use this + instead of "<git-command> || :" to catch failures due to segv. + + - test_cmp <expected> <actual> + + Check whether the content of the <actual> file matches the + <expected> file. This behaves like "cmp" but produces more + helpful output when the test is run with "-v" option. + + - test_when_finished <script> + + Prepend <script> to a list of commands to run to clean up + at the end of the current test. If some clean-up command + fails, the test will not pass. + + Example: + + test_expect_success 'branch pointing to non-commit' ' + git rev-parse HEAD^{tree} >.git/refs/heads/invalid && + test_when_finished "git update-ref -d refs/heads/invalid" && + ... + ' + + Tips for Writing Tests ---------------------- diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh index b70b891b62..81ef2a0969 100644 --- a/t/gitweb-lib.sh +++ b/t/gitweb-lib.sh @@ -76,12 +76,12 @@ gitweb_run () { . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping gitweb tests, perl not available' + skip_all='skipping gitweb tests, perl not available' test_done fi perl -MEncode -e 'decode_utf8("", Encode::FB_CROAK)' >/dev/null 2>&1 || { - say 'skipping gitweb tests, perl version is too old' + skip_all='skipping gitweb tests, perl version is too old' test_done } diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh index 4b3b793730..648d1619c8 100644 --- a/t/lib-cvs.sh +++ b/t/lib-cvs.sh @@ -9,7 +9,7 @@ export HOME if ! type cvs >/dev/null 2>&1 then - say 'skipping cvsimport tests, cvs not found' + skip_all='skipping cvsimport tests, cvs not found' test_done fi @@ -21,11 +21,11 @@ case "$cvsps_version" in 2.1 | 2.2*) ;; '') - say 'skipping cvsimport tests, cvsps not found' + skip_all='skipping cvsimport tests, cvsps not found' test_done ;; *) - say 'skipping cvsimport tests, unsupported cvsps version' + skip_all='skipping cvsimport tests, unsupported cvsps version' test_done ;; esac diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index 0f7f35ccc9..c3f6676ca2 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -5,11 +5,11 @@ git_svn_id=git""-svn-id if test -n "$NO_SVN_TESTS" then - say 'skipping git svn tests, NO_SVN_TESTS defined' + skip_all='skipping git svn tests, NO_SVN_TESTS defined' test_done fi if ! test_have_prereq PERL; then - say 'skipping git svn tests, perl not available' + skip_all='skipping git svn tests, perl not available' test_done fi @@ -21,7 +21,7 @@ PERL=${PERL:-perl} svn >/dev/null 2>&1 if test $? -ne 1 then - say 'skipping git svn tests, svn not found' + skip_all='skipping git svn tests, svn not found' test_done fi @@ -40,13 +40,12 @@ x=$? if test $x -ne 0 then if test $x -eq 42; then - err='Perl SVN libraries must be >= 1.1.0' + skip_all='Perl SVN libraries must be >= 1.1.0' elif test $x -eq 41; then - err='svnadmin failed to create fsfs repository' + skip_all='svnadmin failed to create fsfs repository' else - err='Perl SVN libraries not found or unusable, skipping test' + skip_all='Perl SVN libraries not found or unusable' fi - say "$err" test_done fi @@ -159,7 +158,7 @@ EOF require_svnserve () { if test -z "$SVNSERVE_PORT" then - say 'skipping svnserve test. (set $SVNSERVE_PORT to enable)' + skip_all='skipping svnserve test. (set $SVNSERVE_PORT to enable)' test_done fi } diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index da4b8d5a6f..71effc5bec 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -5,8 +5,7 @@ if test -z "$GIT_TEST_HTTPD" then - say "skipping test, network testing disabled by default" - say "(define GIT_TEST_HTTPD to enable)" + skip_all="Network testing disabled (define GIT_TEST_HTTPD to enable)" test_done fi @@ -46,7 +45,7 @@ HTTPD_DOCUMENT_ROOT_PATH=$HTTPD_ROOT_PATH/www if ! test -x "$LIB_HTTPD_PATH" then - say "skipping test, no web server found at '$LIB_HTTPD_PATH'" + skip_all="skipping test, no web server found at '$LIB_HTTPD_PATH'" test_done fi @@ -59,12 +58,12 @@ then then if ! test $HTTPD_VERSION -ge 2 then - say "skipping test, at least Apache version 2 is required" + skip_all="skipping test, at least Apache version 2 is required" test_done fi if ! test -d "$DEFAULT_HTTPD_MODULE_PATH" then - say "Apache module directory not found. Skipping tests." + skip_all="Apache module directory not found. Skipping tests." test_done fi @@ -119,7 +118,7 @@ start_httpd() { >&3 2>&4 if test $? -ne 0 then - say "skipping test, web server setup failed" + skip_all="skipping test, web server setup failed" trap 'die' EXIT test_done fi diff --git a/t/lib-patch-mode.sh b/t/lib-patch-mode.sh index ce36f34d03..375e248651 100644 --- a/t/lib-patch-mode.sh +++ b/t/lib-patch-mode.sh @@ -3,7 +3,7 @@ . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping --patch tests, perl not available' + skip_all='skipping --patch tests, perl not available' test_done fi diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh index 09f855af3e..93e58c00e8 100755 --- a/t/t0005-signals.sh +++ b/t/t0005-signals.sh @@ -13,6 +13,7 @@ test_expect_success 'sigchain works' ' test-sigchain >actual case "$?" in 143) true ;; # POSIX w/ SIGTERM=15 + 271) true ;; # ksh w/ SIGTERM=15 3) true ;; # Windows *) false ;; esac && diff --git a/t/t0006-date.sh b/t/t0006-date.sh index 75b02af86d..1d4d0a5c7d 100755 --- a/t/t0006-date.sh +++ b/t/t0006-date.sh @@ -28,8 +28,8 @@ check_show 31449600 '12 months ago' check_parse() { echo "$1 -> $2" >expect - test_expect_${3:-success} "parse date ($1)" " - test-date parse '$1' >actual && + test_expect_${4:-success} "parse date ($1${3:+ TZ=$3})" " + TZ=${3:-$TZ} test-date parse '$1' >actual && test_cmp expect actual " } @@ -38,6 +38,8 @@ check_parse 2008 bad check_parse 2008-02 bad check_parse 2008-02-14 bad check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 +0000' +check_parse '2008-02-14 20:30:45 -0500' '2008-02-14 20:30:45 -0500' +check_parse '2008-02-14 20:30:45' '2008-02-14 20:30:45 -0500' EST5 check_approxidate() { echo "$1 -> $2 +0000" >expect diff --git a/t/t1001-read-tree-m-2way.sh b/t/t1001-read-tree-m-2way.sh index 6327d205cb..0c562bb820 100755 --- a/t/t1001-read-tree-m-2way.sh +++ b/t/t1001-read-tree-m-2way.sh @@ -390,4 +390,20 @@ test_expect_success \ git ls-files --stage | tee >treeMcheck.out && test_cmp treeM.out treeMcheck.out' +test_expect_success '-m references the correct modified tree' ' + echo >file-a && + echo >file-b && + git add file-a file-b && + git commit -a -m "test for correct modified tree" + git branch initial-mod && + echo b >file-b && + git commit -a -m "B" && + echo a >file-a && + git add file-a && + git ls-tree $(git write-tree) file-a >expect && + git read-tree -m HEAD initial-mod && + git ls-tree $(git write-tree) file-a >actual && + test_cmp expect actual +' + test_done diff --git a/t/t1020-subdirectory.sh b/t/t1020-subdirectory.sh index 210e594f6f..56874996a6 100755 --- a/t/t1020-subdirectory.sh +++ b/t/t1020-subdirectory.sh @@ -24,18 +24,18 @@ test_expect_success 'update-index and ls-files' ' cd "$HERE" && git update-index --add one && case "`git ls-files`" in - one) echo ok one ;; + one) echo pass one ;; *) echo bad one; exit 1 ;; esac && cd dir && git update-index --add two && case "`git ls-files`" in - two) echo ok two ;; + two) echo pass two ;; *) echo bad two; exit 1 ;; esac && cd .. && case "`git ls-files`" in - dir/two"$LF"one) echo ok both ;; + dir/two"$LF"one) echo pass both ;; *) echo bad; exit 1 ;; esac ' @@ -58,17 +58,17 @@ test_expect_success 'diff-files' ' echo a >>one && echo d >>dir/two && case "`git diff-files --name-only`" in - dir/two"$LF"one) echo ok top ;; + dir/two"$LF"one) echo pass top ;; *) echo bad top; exit 1 ;; esac && # diff should not omit leading paths cd dir && case "`git diff-files --name-only`" in - dir/two"$LF"one) echo ok subdir ;; + dir/two"$LF"one) echo pass subdir ;; *) echo bad subdir; exit 1 ;; esac && case "`git diff-files --name-only .`" in - dir/two) echo ok subdir limited ;; + dir/two) echo pass subdir limited ;; *) echo bad subdir limited; exit 1 ;; esac ' diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh index 055ad00f77..97ab02aceb 100755 --- a/t/t1304-default-acl.sh +++ b/t/t1304-default-acl.sh @@ -15,9 +15,12 @@ umask 077 # is a good candidate: exists on all unices, and it has permission # anyway, so we don't create a security hole running the testsuite. -if ! setfacl -m u:root:rwx .; then - say "Skipping ACL tests: unable to use setfacl" - test_done +setfacl_out="$(setfacl -m u:root:rwx . 2>&1)" +setfacl_ret=$? + +if [ $setfacl_ret != 0 ]; then + skip_all="Skipping ACL tests: unable to use setfacl (output: '$setfacl_out'; return code: '$setfacl_ret')" + test_done fi check_perms_and_acl () { diff --git a/t/t1502-rev-parse-parseopt.sh b/t/t1502-rev-parse-parseopt.sh index 4346795855..b3195c4707 100755 --- a/t/t1502-rev-parse-parseopt.sh +++ b/t/t1502-rev-parse-parseopt.sh @@ -81,4 +81,22 @@ test_expect_success 'test --parseopt --keep-dashdash' ' test_cmp expect output ' +cat >expect <<EOF +set -- --foo -- '--' 'arg' '--spam=ham' +EOF + +test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option with --' ' + git rev-parse --parseopt --keep-dashdash --stop-at-non-option -- --foo -- arg --spam=ham <optionspec >output && + test_cmp expect output +' + +cat > expect <<EOF +set -- --foo -- 'arg' '--spam=ham' +EOF + +test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option without --' ' + git rev-parse --parseopt --keep-dashdash --stop-at-non-option -- --foo arg --spam=ham <optionspec >output && + test_cmp expect output +' + test_done diff --git a/t/t1509-root-worktree.sh b/t/t1509-root-worktree.sh index 5322a3bf97..7f60fd0b2e 100755 --- a/t/t1509-root-worktree.sh +++ b/t/t1509-root-worktree.sh @@ -99,17 +99,17 @@ test_foobar_foobar() { } if ! test_have_prereq POSIXPERM || ! [ -w / ]; then - say "Dangerous test skipped. Read this test if you want to execute it" + skip_all="Dangerous test skipped. Read this test if you want to execute it" test_done fi if [ "$IKNOWWHATIAMDOING" != "YES" ]; then - say "You must set env var IKNOWWHATIAMDOING=YES in order to run this test" + skip_all="You must set env var IKNOWWHATIAMDOING=YES in order to run this test" test_done fi if [ "$UID" = 0 ]; then - say "No you can't run this with root" + skip_all="No you can't run this with root" test_done fi diff --git a/t/t2007-checkout-symlink.sh b/t/t2007-checkout-symlink.sh index 27e2127afe..05cc8fdd01 100755 --- a/t/t2007-checkout-symlink.sh +++ b/t/t2007-checkout-symlink.sh @@ -8,7 +8,7 @@ test_description='git checkout to switch between branches with symlink<->dir' if ! test_have_prereq SYMLINKS then - say "symbolic links not supported - skipping tests" + skip_all="symbolic links not supported - skipping tests" test_done fi diff --git a/t/t2102-update-index-symlinks.sh b/t/t2102-update-index-symlinks.sh index 1ed44ee503..4d0d0a3515 100755 --- a/t/t2102-update-index-symlinks.sh +++ b/t/t2102-update-index-symlinks.sh @@ -24,7 +24,7 @@ git update-index symlink' test_expect_success \ 'the index entry must still be a symbolic link' ' case "`git ls-files --stage --cached symlink`" in -120000" "*symlink) echo ok;; +120000" "*symlink) echo pass;; *) echo fail; git ls-files --stage --cached symlink; (exit 1);; esac' diff --git a/t/t3300-funny-names.sh b/t/t3300-funny-names.sh index db46d53e82..a99e4d8b92 100755 --- a/t/t3300-funny-names.sh +++ b/t/t3300-funny-names.sh @@ -26,7 +26,7 @@ echo 'Foo Bar Baz' >"$p2" test -f "$p1" && cmp "$p0" "$p1" || { # since FAT/NTFS does not allow tabs in filenames, skip this test - say 'Your filesystem does not allow tabs in filenames, test skipped.' + skip_all='Your filesystem does not allow tabs in filenames, test skipped.' test_done } diff --git a/t/t3302-notes-index-expensive.sh b/t/t3302-notes-index-expensive.sh index ee84fc4884..361a10aeb1 100755 --- a/t/t3302-notes-index-expensive.sh +++ b/t/t3302-notes-index-expensive.sh @@ -8,7 +8,7 @@ test_description='Test commit notes index (expensive!)' . ./test-lib.sh test -z "$GIT_NOTES_TIMING_TESTS" && { - say Skipping timing tests + skip_all="Skipping timing tests" test_done exit } diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 0aaf0ad84b..b514cbb606 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -39,7 +39,7 @@ if test -f test-file then test_set_prereq RO_DIR else - say 'skipping removal failure test (perhaps running as root?)' + skip_all='skipping removal failure test (perhaps running as root?)' fi chmod 775 . rm -f test-file diff --git a/t/t3700-add.sh b/t/t3700-add.sh index 525c9a8fdf..6f031af9f3 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -26,7 +26,7 @@ test_expect_success \ chmod 755 xfoo1 && git add xfoo1 && case "`git ls-files --stage xfoo1`" in - 100644" "*xfoo1) echo ok;; + 100644" "*xfoo1) echo pass;; *) echo fail; git ls-files --stage xfoo1; (exit 1);; esac' @@ -35,7 +35,7 @@ test_expect_success SYMLINKS 'git add: filemode=0 should not get confused by sym ln -s foo xfoo1 && git add xfoo1 && case "`git ls-files --stage xfoo1`" in - 120000" "*xfoo1) echo ok;; + 120000" "*xfoo1) echo pass;; *) echo fail; git ls-files --stage xfoo1; (exit 1);; esac ' @@ -47,7 +47,7 @@ test_expect_success \ chmod 755 xfoo2 && git update-index --add xfoo2 && case "`git ls-files --stage xfoo2`" in - 100644" "*xfoo2) echo ok;; + 100644" "*xfoo2) echo pass;; *) echo fail; git ls-files --stage xfoo2; (exit 1);; esac' @@ -56,7 +56,7 @@ test_expect_success SYMLINKS 'git add: filemode=0 should not get confused by sym ln -s foo xfoo2 && git update-index --add xfoo2 && case "`git ls-files --stage xfoo2`" in - 120000" "*xfoo2) echo ok;; + 120000" "*xfoo2) echo pass;; *) echo fail; git ls-files --stage xfoo2; (exit 1);; esac ' @@ -67,7 +67,7 @@ test_expect_success SYMLINKS \ ln -s xfoo2 xfoo3 && git update-index --add xfoo3 && case "`git ls-files --stage xfoo3`" in - 120000" "*xfoo3) echo ok;; + 120000" "*xfoo3) echo pass;; *) echo fail; git ls-files --stage xfoo3; (exit 1);; esac' @@ -172,7 +172,7 @@ test_expect_success 'git add --refresh' ' test -z "`git diff-index HEAD -- foo`" && git read-tree HEAD && case "`git diff-index HEAD -- foo`" in - :100644" "*"M foo") echo ok;; + :100644" "*"M foo") echo pass;; *) echo fail; (exit 1);; esac && git add --refresh -- foo && diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index b6eba6a839..7ad8465f8f 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -4,7 +4,7 @@ test_description='add -i basic tests' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git add -i tests, perl not available' + skip_all='skipping git add -i tests, perl not available' test_done fi @@ -154,7 +154,7 @@ rm -f .gitignore if test "$(git config --bool core.filemode)" = false then - say 'skipping filemode tests (filesystem does not properly support modes)' + say '# skipping filemode tests (filesystem does not properly support modes)' else test_set_prereq FILEMODE fi diff --git a/t/t3902-quoted.sh b/t/t3902-quoted.sh index 29103f65dc..147e634cd6 100755 --- a/t/t3902-quoted.sh +++ b/t/t3902-quoted.sh @@ -17,7 +17,7 @@ DQ='"' echo foo 2>/dev/null > "Name and an${HT}HT" test -f "Name and an${HT}HT" || { # since FAT/NTFS does not allow tabs in filenames, skip this test - say 'Your filesystem does not allow tabs in filenames, test skipped.' + skip_all='Your filesystem does not allow tabs in filenames, test skipped.' test_done } diff --git a/t/t4004-diff-rename-symlink.sh b/t/t4004-diff-rename-symlink.sh index a4da1196a9..1a09e8db40 100755 --- a/t/t4004-diff-rename-symlink.sh +++ b/t/t4004-diff-rename-symlink.sh @@ -14,7 +14,7 @@ by an edit for them. if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi diff --git a/t/t4011-diff-symlink.sh b/t/t4011-diff-symlink.sh index e12fbea1b5..918a21a2f4 100755 --- a/t/t4011-diff-symlink.sh +++ b/t/t4011-diff-symlink.sh @@ -11,7 +11,7 @@ test_description='Test diff of symlinks. if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi diff --git a/t/t4016-diff-quote.sh b/t/t4016-diff-quote.sh index 55eb5f83f1..34e5144eed 100755 --- a/t/t4016-diff-quote.sh +++ b/t/t4016-diff-quote.sh @@ -14,7 +14,7 @@ P2='pathname with SP' P3='pathname with LF' : 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || { - say 'Your filesystem does not allow tabs in filenames, test skipped.' + skip_all='Your filesystem does not allow tabs in filenames, test skipped.' test_done } diff --git a/t/t4023-diff-rename-typechange.sh b/t/t4023-diff-rename-typechange.sh index 9bdf6596d8..40a95a149e 100755 --- a/t/t4023-diff-rename-typechange.sh +++ b/t/t4023-diff-rename-typechange.sh @@ -6,7 +6,7 @@ test_description='typechange rename detection' if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi diff --git a/t/t4114-apply-typechange.sh b/t/t4114-apply-typechange.sh index 99ec13dd53..164d58c222 100755 --- a/t/t4114-apply-typechange.sh +++ b/t/t4114-apply-typechange.sh @@ -11,7 +11,7 @@ test_description='git apply should not get confused with type changes. if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi diff --git a/t/t4115-apply-symlink.sh b/t/t4115-apply-symlink.sh index b852e58980..aff4348034 100755 --- a/t/t4115-apply-symlink.sh +++ b/t/t4115-apply-symlink.sh @@ -11,7 +11,7 @@ test_description='git apply symlinks and partial files if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi diff --git a/t/t4122-apply-symlink-inside.sh b/t/t4122-apply-symlink-inside.sh index 0d3c1d5dd5..923fcab7f9 100755 --- a/t/t4122-apply-symlink-inside.sh +++ b/t/t4122-apply-symlink-inside.sh @@ -5,7 +5,7 @@ test_description='apply to deeper directory without getting fooled with symlink' if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index 4360e77d31..fb3a270822 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -74,7 +74,7 @@ if msg=$(git verify-pack -v "test-3-${pack3}.pack" 2>&1) || then test_set_prereq OFF64_T else - say "skipping tests concerning 64-bit offsets" + say "# skipping tests concerning 64-bit offsets" fi test_expect_success OFF64_T \ diff --git a/t/t5503-tagfollow.sh b/t/t5503-tagfollow.sh index d5db75d826..bab1a536f5 100755 --- a/t/t5503-tagfollow.sh +++ b/t/t5503-tagfollow.sh @@ -6,7 +6,7 @@ test_description='test automatic tag following' case $(uname -s) in *MINGW*) - say "GIT_DEBUG_SEND_PACK not supported - skipping tests" + skip_all="GIT_DEBUG_SEND_PACK not supported - skipping tests" test_done esac diff --git a/t/t5522-pull-symlink.sh b/t/t5522-pull-symlink.sh index 7206817ca1..298200fa4c 100755 --- a/t/t5522-pull-symlink.sh +++ b/t/t5522-pull-symlink.sh @@ -6,7 +6,7 @@ test_description='pulling from symlinked subdir' if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi diff --git a/t/t5540-http-push.sh b/t/t5540-http-push.sh index 37fe875411..a266ca5636 100755 --- a/t/t5540-http-push.sh +++ b/t/t5540-http-push.sh @@ -11,7 +11,7 @@ This test runs various sanity checks on http-push.' if git http-push > /dev/null 2>&1 || [ $? -eq 128 ] then - say "skipping test, USE_CURL_MULTI is not defined" + skip_all="skipping test, USE_CURL_MULTI is not defined" test_done fi diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh index 17e1bdc5a8..504884b9f8 100755 --- a/t/t5541-http-push.sh +++ b/t/t5541-http-push.sh @@ -7,7 +7,7 @@ test_description='test smart pushing over http via http-backend' . ./test-lib.sh if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' + skip_all='skipping test, git built without http support' test_done fi diff --git a/t/t5550-http-fetch.sh b/t/t5550-http-fetch.sh index fc675b50ad..2fb48d09ed 100755 --- a/t/t5550-http-fetch.sh +++ b/t/t5550-http-fetch.sh @@ -4,7 +4,7 @@ test_description='test dumb fetching over http via static file' . ./test-lib.sh if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' + skip_all='skipping test, git built without http support' test_done fi diff --git a/t/t5551-http-fetch.sh b/t/t5551-http-fetch.sh index 7faa31a299..fd19121372 100755 --- a/t/t5551-http-fetch.sh +++ b/t/t5551-http-fetch.sh @@ -4,7 +4,7 @@ test_description='test smart fetching over http via http-backend' . ./test-lib.sh if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' + skip_all='skipping test, git built without http support' test_done fi diff --git a/t/t5561-http-backend.sh b/t/t5561-http-backend.sh index 8c6d0b2f20..b5d7fbc381 100755 --- a/t/t5561-http-backend.sh +++ b/t/t5561-http-backend.sh @@ -4,7 +4,7 @@ test_description='test git-http-backend' . ./test-lib.sh if test -n "$NO_CURL"; then - say 'skipping test, git built without http support' + skip_all='skipping test, git built without http support' test_done fi diff --git a/t/t5705-clone-2gb.sh b/t/t5705-clone-2gb.sh index 8afbdd4de2..e4d1b6a0fa 100755 --- a/t/t5705-clone-2gb.sh +++ b/t/t5705-clone-2gb.sh @@ -4,7 +4,7 @@ test_description='Test cloning a repository larger than 2 gigabyte' . ./test-lib.sh test -z "$GIT_TEST_CLONE_2GB" && -say "Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t" && +skip_all="Skipping expensive 2GB clone test; enable it with GIT_TEST_CLONE_2GB=t" && test_done && exit diff --git a/t/t5800-remote-helpers.sh b/t/t5800-remote-helpers.sh index 4ee7b65ce6..637d8e97ac 100755 --- a/t/t5800-remote-helpers.sh +++ b/t/t5800-remote-helpers.sh @@ -15,7 +15,7 @@ if sys.hexversion < 0x02040000: then : else - say 'skipping git remote-testgit tests: requires Python 2.4 or newer' + skip_all='skipping git remote-testgit tests: requires Python 2.4 or newer' test_done fi diff --git a/t/t6035-merge-dir-to-symlink.sh b/t/t6035-merge-dir-to-symlink.sh index 3202e1de6d..cd3190c4a6 100755 --- a/t/t6035-merge-dir-to-symlink.sh +++ b/t/t6035-merge-dir-to-symlink.sh @@ -5,7 +5,7 @@ test_description='merging when a directory was replaced with a symlink' if ! test_have_prereq SYMLINKS then - say 'Symbolic links not supported, skipping tests.' + skip_all='Symbolic links not supported, skipping tests.' test_done fi diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh index 73dbc4360b..ac943f5eee 100755 --- a/t/t7004-tag.sh +++ b/t/t7004-tag.sh @@ -583,7 +583,7 @@ test_expect_success \ # subsequent tests require gpg; check if it is available gpg --version >/dev/null 2>/dev/null if [ $? -eq 127 ]; then - say "gpg not found - skipping tag signing and verification tests" + say "# gpg not found - skipping tag signing and verification tests" else # As said here: http://www.gnupg.org/documentation/faqs.html#q6.19 # the gpg version 1.0.6 didn't parse trust packets correctly, so for diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh index fe60d699a3..26ddf9d496 100755 --- a/t/t7005-editor.sh +++ b/t/t7005-editor.sh @@ -113,7 +113,7 @@ done if ! echo 'echo space > "$1"' > "e space.sh" then - say "Skipping; FS does not support spaces in filenames" + skip_all="Skipping; FS does not support spaces in filenames" test_done fi diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh index c2a3c8e2e7..eb9651da89 100755 --- a/t/t7006-pager.sh +++ b/t/t7006-pager.sh @@ -37,7 +37,7 @@ then } test_set_prereq TTY else - say no usable terminal, so skipping some tests + say "# no usable terminal, so skipping some tests" fi test_expect_success 'setup' ' diff --git a/t/t7405-submodule-merge.sh b/t/t7405-submodule-merge.sh index 9a21f783d3..4a7b8933f4 100755 --- a/t/t7405-submodule-merge.sh +++ b/t/t7405-submodule-merge.sh @@ -45,7 +45,7 @@ test_expect_success setup ' git commit -m sub-b) && git add sub && test_tick && - git commit -m b + git commit -m b && git checkout -b c a && git merge -s ours b && diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh index 1de83ef98f..196827e7ea 100755 --- a/t/t7800-difftool.sh +++ b/t/t7800-difftool.sh @@ -11,7 +11,7 @@ Testing basic diff tool invocation . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping difftool tests, perl not available' + skip_all='skipping difftool tests, perl not available' test_done fi diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index 382ab6c98a..23597cc407 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -4,7 +4,7 @@ test_description='git send-email' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git send-email tests, perl not available' + skip_all='skipping git send-email tests, perl not available' test_done fi @@ -58,7 +58,7 @@ test_no_confirm () { # Exit immediately to prevent hang if a no-confirm test fails check_no_confirm () { test -f no_confirm_okay || { - say 'No confirm test failed; skipping remaining tests to prevent hanging' + skip_all='confirm test failed; skipping remaining tests to prevent hanging' test_done } } diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index 570e0359e4..13766ab160 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -15,7 +15,7 @@ case "$GIT_SVN_LC_ALL" in test_set_prereq UTF8 ;; *) - say "UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)" + say "# UTF-8 locale not set, some tests skipped ($GIT_SVN_LC_ALL)" ;; esac diff --git a/t/t9118-git-svn-funky-branch-names.sh b/t/t9118-git-svn-funky-branch-names.sh index 7d7acc30b4..63fc982c8c 100755 --- a/t/t9118-git-svn-funky-branch-names.sh +++ b/t/t9118-git-svn-funky-branch-names.sh @@ -28,48 +28,52 @@ test_expect_success 'setup svnrepo' ' svn_cmd cp -m "trailing .lock" "$svnrepo/pr ject/trunk" \ "$svnrepo/pr ject/branches/trailing_dotlock.lock" && svn_cmd cp -m "reflog" "$svnrepo/pr ject/trunk" \ - "$svnrepo/pr ject/branches/not-a@{0}reflog" && + "$svnrepo/pr ject/branches/not-a%40{0}reflog" && start_httpd ' test_expect_success 'test clone with funky branch names' ' git svn clone -s "$svnrepo/pr ject" project && - cd project && + ( + cd project && git rev-parse "refs/remotes/fun%20plugin" && git rev-parse "refs/remotes/more%20fun%20plugin!" && git rev-parse "refs/remotes/$scary_ref" && git rev-parse "refs/remotes/%2Eleading_dot" && git rev-parse "refs/remotes/trailing_dot%2E" && git rev-parse "refs/remotes/trailing_dotlock%2Elock" && - git rev-parse "refs/remotes/not-a%40{0}reflog" && - cd .. + git rev-parse "refs/remotes/not-a%40{0}reflog" + ) ' test_expect_success 'test dcommit to funky branch' " - cd project && - git reset --hard 'refs/remotes/more%20fun%20plugin!' && - echo hello >> foo && - git commit -m 'hello' -- foo && - git svn dcommit && - cd .. + ( + cd project && + git reset --hard 'refs/remotes/more%20fun%20plugin!' && + echo hello >> foo && + git commit -m 'hello' -- foo && + git svn dcommit + ) " test_expect_success 'test dcommit to scary branch' ' - cd project && - git reset --hard "refs/remotes/$scary_ref" && - echo urls are scary >> foo && - git commit -m "eep" -- foo && - git svn dcommit && - cd .. + ( + cd project && + git reset --hard "refs/remotes/$scary_ref" && + echo urls are scary >> foo && + git commit -m "eep" -- foo && + git svn dcommit + ) ' test_expect_success 'test dcommit to trailing_dotlock branch' ' - cd project && - git reset --hard "refs/remotes/trailing_dotlock%2Elock" && - echo who names branches like this anyway? >> foo && - git commit -m "bar" -- foo && - git svn dcommit && - cd .. + ( + cd project && + git reset --hard "refs/remotes/trailing_dotlock%2Elock" && + echo who names branches like this anyway? >> foo && + git commit -m "bar" -- foo && + git svn dcommit + ) ' stop_httpd diff --git a/t/t9119-git-svn-info.sh b/t/t9119-git-svn-info.sh index a9a558d292..5fb94fb3d6 100755 --- a/t/t9119-git-svn-info.sh +++ b/t/t9119-git-svn-info.sh @@ -13,7 +13,7 @@ case $v in 1.[456].*) ;; *) - say "skipping svn-info test (SVN version: $v not supported)" + skip_all="skipping svn-info test (SVN version: $v not supported)" test_done ;; esac diff --git a/t/t9129-git-svn-i18n-commitencoding.sh b/t/t9129-git-svn-i18n-commitencoding.sh index 1e9a2eb12b..8cfdfe790f 100755 --- a/t/t9129-git-svn-i18n-commitencoding.sh +++ b/t/t9129-git-svn-i18n-commitencoding.sh @@ -23,7 +23,7 @@ if test -n "$a_utf8_locale" then test_set_prereq UTF8 else - say "UTF-8 locale not available, some tests are skipped" + say "# UTF-8 locale not available, some tests are skipped" fi compare_svn_head_with () { diff --git a/t/t9143-git-svn-gc.sh b/t/t9143-git-svn-gc.sh index 99f69c6a0b..337ea59711 100755 --- a/t/t9143-git-svn-gc.sh +++ b/t/t9143-git-svn-gc.sh @@ -43,7 +43,7 @@ then gunzip .git/svn/refs/remotes/git-svn/unhandled.log.gz ' else - say "Perl Compress::Zlib unavailable, skipping gunzip test" + say "# Perl Compress::Zlib unavailable, skipping gunzip test" fi test_expect_success 'git svn gc does not change unhandled.log files' ' diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index 61bcb8fc86..ee39b36d78 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -7,14 +7,14 @@ test_description='Test export of commits to CVS' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git cvsexportcommit tests, perl not available' + skip_all='skipping git cvsexportcommit tests, perl not available' test_done fi cvs >/dev/null 2>&1 if test $? -ne 1 then - say 'skipping git cvsexportcommit tests, cvs not found' + skip_all='skipping git cvsexportcommit tests, cvs not found' test_done fi diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index 86395065cf..36c457e7f2 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -11,17 +11,17 @@ cvs CLI client via git-cvsserver server' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping git cvsserver tests, perl not available' + skip_all='skipping git cvsserver tests, perl not available' test_done fi cvs >/dev/null 2>&1 if test $? -ne 1 then - say 'skipping git-cvsserver tests, cvs not found' + skip_all='skipping git-cvsserver tests, cvs not found' test_done fi "$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { - say 'skipping git-cvsserver tests, Perl SQLite interface unavailable' + skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' test_done } diff --git a/t/t9401-git-cvsserver-crlf.sh b/t/t9401-git-cvsserver-crlf.sh index ed7b513f3e..925bd0fbed 100755 --- a/t/t9401-git-cvsserver-crlf.sh +++ b/t/t9401-git-cvsserver-crlf.sh @@ -41,16 +41,16 @@ not_present() { cvs >/dev/null 2>&1 if test $? -ne 1 then - say 'skipping git-cvsserver tests, cvs not found' + skip_all='skipping git-cvsserver tests, cvs not found' test_done fi if ! test_have_prereq PERL then - say 'skipping git-cvsserver tests, perl not available' + skip_all='skipping git-cvsserver tests, perl not available' test_done fi "$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || { - say 'skipping git-cvsserver tests, Perl SQLite interface unavailable' + skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable' test_done } diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh index b572ce3ab7..2eff9cd68c 100755 --- a/t/t9600-cvsimport.sh +++ b/t/t9600-cvsimport.sh @@ -4,7 +4,7 @@ test_description='git cvsimport basic tests' . ./lib-cvs.sh if ! test_have_prereq PERL; then - say 'skipping git cvsimport tests, perl not available' + skip_all='skipping git cvsimport tests, perl not available' test_done fi diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh index 8686086dde..3787186703 100755 --- a/t/t9700-perl-git.sh +++ b/t/t9700-perl-git.sh @@ -7,12 +7,12 @@ test_description='perl interface (Git.pm)' . ./test-lib.sh if ! test_have_prereq PERL; then - say 'skipping perl interface tests, perl not available' + skip_all='skipping perl interface tests, perl not available' test_done fi "$PERL_PATH" -MTest::More -e 0 2>/dev/null || { - say "Perl Test::More unavailable, skipping test" + skip_all="Perl Test::More unavailable, skipping test" test_done } @@ -46,6 +46,9 @@ test_expect_success \ git config --add test.int 2k ' +# The external test will outputs its own plan +test_external_has_tap=1 + test_external_without_stderr \ 'Perl API' \ "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl diff --git a/t/t9700/test.pl b/t/t9700/test.pl index 666722d9bf..671f38db2b 100755 --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@ -7,6 +7,13 @@ use strict; use Test::More qw(no_plan); +BEGIN { + # t9700-perl-git.sh kicks off our testing, so we have to go from + # there. + Test::More->builder->current_test(1); + Test::More->builder->no_ending(1); +} + use Cwd; use File::Basename; @@ -105,3 +112,8 @@ my $last_commit = $r2->command_oneline(qw(rev-parse --verify HEAD)); like($last_commit, qr/^[0-9a-fA-F]{40}$/, 'rev-parse returned hash'); my $dir_commit = $r2->command_oneline('log', '-n1', '--pretty=format:%H', '.'); isnt($last_commit, $dir_commit, 'log . does not show last commit'); + +printf "1..%d\n", Test::More->builder->current_test; + +my $is_passing = eval { Test::More->is_passing }; +exit($is_passing ? 0 : 1) unless $@ =~ /Can't locate object method/; diff --git a/t/test-lib.sh b/t/test-lib.sh index 367f0537cd..db8371cb17 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -160,7 +160,7 @@ if test -n "$color"; then *) test -n "$quiet" && return;; esac shift - printf "* %s" "$*" + printf "%s" "$*" tput sgr0 echo ) @@ -169,7 +169,7 @@ else say_color() { test -z "$1" && test -n "$quiet" && return shift - echo "* $*" + echo "$*" } fi @@ -206,6 +206,8 @@ test_fixed=0 test_broken=0 test_success=0 +test_external_has_tap=0 + die () { code=$? if test -n "$GIT_EXIT_OK" @@ -339,25 +341,25 @@ test_have_prereq () { test_ok_ () { test_success=$(($test_success + 1)) - say_color "" " ok $test_count: $@" + say_color "" "ok $test_count - $@" } test_failure_ () { test_failure=$(($test_failure + 1)) - say_color error "FAIL $test_count: $1" + say_color error "not ok - $test_count $1" shift - echo "$@" | sed -e 's/^/ /' + echo "$@" | sed -e 's/^/# /' test "$immediate" = "" || { GIT_EXIT_OK=t; exit 1; } } test_known_broken_ok_ () { test_fixed=$(($test_fixed+1)) - say_color "" " FIXED $test_count: $@" + say_color "" "ok $test_count - $@ # TODO known breakage" } test_known_broken_failure_ () { test_broken=$(($test_broken+1)) - say_color skip " still broken $test_count: $@" + say_color skip "not ok $test_count - $@ # TODO known breakage" } test_debug () { @@ -369,6 +371,9 @@ test_run_ () { eval >&3 2>&4 "$1" eval_ret=$? eval >&3 2>&4 "$test_cleanup" + if test "$verbose" = "t" && test -n "$HARNESS_ACTIVE"; then + echo "" + fi return 0 } @@ -380,6 +385,7 @@ test_skip () { case $this_test.$test_count in $skp) to_skip=t + break esac done if test -z "$to_skip" && test -n "$prereq" && @@ -390,7 +396,7 @@ test_skip () { case "$to_skip" in t) say_color skip >&3 "skipping test: $@" - say_color skip "skip $test_count: $1" + say_color skip "ok $test_count # skip $1" : true ;; *) @@ -456,7 +462,7 @@ test_expect_code () { # test_external runs external test scripts that provide continuous # test output about their progress, and succeeds/fails on # zero/non-zero exit code. It outputs the test output on stdout even -# in non-verbose mode, and announces the external script with "* run +# in non-verbose mode, and announces the external script with "# run # <n>: ..." before running it. When providing relative paths, keep in # mind that all scripts run in "trash directory". # Usage: test_external description command arguments... @@ -471,7 +477,7 @@ test_external () { then # Announce the script to reduce confusion about the # test output that follows. - say_color "" " run $test_count: $descr ($*)" + say_color "" "# run $test_count: $descr ($*)" # Export TEST_DIRECTORY, TRASH_DIRECTORY and GIT_TEST_LONG # to be able to use them in script export TEST_DIRECTORY TRASH_DIRECTORY GIT_TEST_LONG @@ -481,9 +487,19 @@ test_external () { "$@" 2>&4 if [ "$?" = 0 ] then - test_ok_ "$descr" + if test $test_external_has_tap -eq 0; then + test_ok_ "$descr" + else + say_color "" "# test_external test $descr was ok" + test_success=$(($test_success + 1)) + fi else - test_failure_ "$descr" "$@" + if test $test_external_has_tap -eq 0; then + test_failure_ "$descr" "$@" + else + say_color error "# test_external test $descr failed: $@" + test_failure=$(($test_failure + 1)) + fi fi fi } @@ -499,19 +515,30 @@ test_external_without_stderr () { [ -f "$stderr" ] || error "Internal error: $stderr disappeared." descr="no stderr: $1" shift - say >&3 "expecting no stderr from previous command" + say >&3 "# expecting no stderr from previous command" if [ ! -s "$stderr" ]; then rm "$stderr" - test_ok_ "$descr" + + if test $test_external_has_tap -eq 0; then + test_ok_ "$descr" + else + say_color "" "# test_external_without_stderr test $descr was ok" + test_success=$(($test_success + 1)) + fi else if [ "$verbose" = t ]; then - output=`echo; echo Stderr is:; cat "$stderr"` + output=`echo; echo "# Stderr is:"; cat "$stderr"` else output= fi # rm first in case test_failure exits. rm "$stderr" - test_failure_ "$descr" "$@" "$output" + if test $test_external_has_tap -eq 0; then + test_failure_ "$descr" "$@" "$output" + else + say_color error "# test_external_without_stderr test $descr failed: $@: $output" + test_failure=$(($test_failure + 1)) + fi fi } @@ -620,18 +647,24 @@ test_done () { if test "$test_fixed" != 0 then - say_color pass "fixed $test_fixed known breakage(s)" + say_color pass "# fixed $test_fixed known breakage(s)" fi if test "$test_broken" != 0 then - say_color error "still have $test_broken known breakage(s)" + say_color error "# still have $test_broken known breakage(s)" msg="remaining $(($test_count-$test_broken)) test(s)" else msg="$test_count test(s)" fi case "$test_failure" in 0) - say_color pass "passed all $msg" + # Maybe print SKIP message + [ -z "$skip_all" ] || skip_all=" # SKIP $skip_all" + + if test $test_external_has_tap -eq 0; then + say_color pass "# passed all $msg" + say "1..$test_count$skip_all" + fi test -d "$remove_trash" && cd "$(dirname "$remove_trash")" && @@ -640,7 +673,11 @@ test_done () { exit 0 ;; *) - say_color error "failed $test_failure among $msg" + if test $test_external_has_tap -eq 0; then + say_color error "# failed $test_failure among $msg" + say "1..$test_count" + fi + exit 1 ;; esac @@ -793,18 +830,10 @@ this_test=${0##*/} this_test=${this_test%%-*} for skp in $GIT_SKIP_TESTS do - to_skip= - for skp in $GIT_SKIP_TESTS - do - case "$this_test" in - $skp) - to_skip=t - esac - done - case "$to_skip" in - t) + case "$this_test" in + $skp) say_color skip >&3 "skipping test $this_test altogether" - say_color skip "skip all tests in $this_test" + skip_all="skip all tests in $this_test" test_done esac done diff --git a/test-date.c b/test-date.c index a9e705f79a..6bcd5b03c0 100644 --- a/test-date.c +++ b/test-date.c @@ -20,13 +20,16 @@ static void parse_dates(char **argv, struct timeval *now) { for (; *argv; argv++) { char result[100]; - time_t t; + unsigned long t; + int tz; result[0] = 0; parse_date(*argv, result, sizeof(result)); - t = strtoul(result, NULL, 0); - printf("%s -> %s\n", *argv, - t ? show_date(t, 0, DATE_ISO8601) : "bad"); + if (sscanf(result, "%lu %d", &t, &tz) == 2) + printf("%s -> %s\n", + *argv, show_date(t, tz, DATE_ISO8601)); + else + printf("%s -> bad\n", *argv); } } diff --git a/xdiff/xutils.c b/xdiff/xutils.c index bc12f29895..22f9bd692c 100644 --- a/xdiff/xutils.c +++ b/xdiff/xutils.c @@ -190,8 +190,10 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags) { int i1, i2; + if (s1 == s2 && !memcmp(l1, l2, s1)) + return 1; if (!(flags & XDF_WHITESPACE_FLAGS)) - return s1 == s2 && !memcmp(l1, l2, s1); + return 0; i1 = 0; i2 = 0; |