tests


Log

Author Commit Date CI Message
Edward Thomson 8d7717c4 2016-12-20T15:32:49 Merge pull request #4034 from libgit2/cmn/sysdir-no-reguess sysdir: don't re-guess when using variable substitution
Carlos Martín Nieto 410855fc 2016-12-17T18:18:30 sysdir: add failing test for variable substitution When given $PATH as part of a search path, we guess again instead of substituting what the user already set.
Carlos Martín Nieto f7dcd58c 2016-12-17T00:55:06 rebase: plug a leak in the tests
Edward Thomson c5e6ba28 2016-12-15T18:19:49 Merge pull request #4029 from libgit2/cmn/windows-no-concurrent-compress refdb: disable concurrent compress in the threading tests on Windows
Carlos Martín Nieto b31283a6 2016-12-12T17:09:12 refdb: disable concurrent compress in the threading tests on Windows This is far from an ideal situation, but this causes issues on Windows which make it harder to develop anything, as these tests hit issues which relate specifically to the Windows filesystem like permission errors for files we should be able to access. There is an issue likely related to the ordering of the repack, but there's enough noise that it does not currently help us to run this aspect of the test in CI.
Patrick Steinhardt ab0cc5a0 2016-11-25T14:58:16 clar: mark `cl_git_thread_check()` as inline The function `cl_git_thread_check()` is defined as static. As the function is defined in a header file which is included by our tests, this can result in warnings for every test file where `cl_git_thread_check` is never used. Fix the issue by marking it as inline instead.
David Turner 4db1fc7e 2016-12-01T23:06:41 git_rebase_init: correctly handle detached HEAD git_rebase_finish relies on head_detached being set, but rebase_init_merge was only setting it when branch->ref_name was unset. But branch->ref_name would be set to "HEAD" in the case of detached HEAD being either implicitly (NULL) or explicitly passed to git_rebase_init.
Edward Thomson 6367c58c 2016-11-18T18:30:20 tests: handle life without threads
Edward Thomson 6a05c7a0 2016-11-18T07:37:47 threads::refdb tests: use new threaded clar assert
Edward Thomson bbf22f82 2016-11-18T07:34:20 clar: Introduce assertion helpers for threads Don't `cl_git_pass` in a child thread. When the assertion fails, clar will `longjmp` to its error handler, but: > The effect of a call to longjmp() where initialization of the jmp_buf > structure was not performed in the calling thread is undefined. Instead, set up an error context that threads can populate, and the caller can check.
Edward Thomson 99479062 2016-11-18T16:50:34 core::init tests: reverse init/shutdown We want a predictable number of initializations in our multithreaded init test, but we also want to make sure that we have _actually_ initialized `git_libgit2_init` before calling `git_thread_create` (since it now has a sanity check that `git_libgit2_init` has been called). Since `git_thread_create` is internal-only, keep this sanity check. Flip the invocation so that we `git_libgit2_init` before our thread tests and `git_libgit2_shutdown` again after.
Edward Thomson 82f15896 2016-11-18T07:19:22 threads: introduce `git_thread_exit` Introduce `git_thread_exit`, which will allow threads to terminate at an arbitrary time, returning a `void *`. On Windows, this means that we need to store the current `git_thread` in TLS, so that we can set its `return` value when terminating. We cannot simply use `ExitThread`, since Win32 returns `DWORD`s from threads; we return `void *`.
Carlos Martín Nieto a39f18ac 2016-11-14T17:10:43 Merge pull request #3998 from pks-t/pks/repo-discovery Repository discovery starting from files
Edward Thomson df045cef 2016-11-14T12:12:38 Merge pull request #4003 from libgit2/cmn/tree-updater-ordering Use the sorted input in the tree updater
Carlos Martín Nieto 1d41b86c 2016-11-14T12:22:20 tree: add a failing test for unsorted input We do not currently use the sorted version of this input in the function, which means we produce bad results.
Carlos Martín Nieto aef54a46 2016-11-14T11:29:40 refdb: use a constant for the number of per-thread creations/deletes
Carlos Martín Nieto ce5553d4 2016-03-10T22:01:09 refdb: bubble up locked files on the read side On Windows we can find locked files even when reading a reference or the packed-refs file. Bubble up the error in this case as well to allow callers on Windows to retry more intelligently.
Carlos Martín Nieto 7c32d874 2016-03-10T12:27:07 refdb: expect threaded test deletes to race At times we may try to delete a reference which a different thread has already taken care of.
Carlos Martín Nieto 26416f6d 2015-12-24T17:51:19 refdb: add retry logic to the threaded tests The logic simply consists of retrying for as long as the library says the data is locked, but it eventually gets through.
Carlos Martín Nieto 7da4c429 2015-12-24T12:37:41 refdb: adjust the threading tests to what we promise We say it's going to work if you use a different repository in each thread. Let's do precisely that in our code instead of hoping re-using the refdb is going to work. This test does fail currently, surfacing existing bugs.
Patrick Steinhardt 0f316096 2016-11-11T16:55:33 repository: do not interpret all files as gitlinks in discovery When trying to find a discovery, we walk up the directory structure checking if there is a ".git" file or directory and, if so, check its validity. But in the case that we've got a ".git" file, we do not want to unconditionally assume that the file is in fact a ".git" file and treat it as such, as we would error out if it is not. Fix the issue by only treating a file as a gitlink file if it ends with "/.git". This allows users of the function to discover a repository by handing in any path contained inside of a git repository.
Patrick Steinhardt 4dbaf3cd 2016-11-14T10:52:37 test: discover: fix indentation
Patrick Steinhardt 5242c424 2016-11-11T16:43:37 test: discover: split up monolithic test into smaller ones
Patrick Steinhardt 07afeb23 2016-11-11T16:16:34 test: discover: pass constants to ensure_repository_discover
Patrick Steinhardt 2382b0f8 2016-11-11T15:50:14 test: discover: move layout creation into test initializer
Patrick Steinhardt 5fe5557e 2016-11-04T18:18:46 Merge pull request #3974 from libgit2/pks/synchronize-shutdown global: synchronize initialization and shutdown with pthreads
Patrick Steinhardt 6e2fab9e 2016-11-04T18:14:00 Merge pull request #3977 from jfultz/fix-forced-branch-creation-on-bare-repo
John Fultz f9793884 2016-10-28T14:32:01 branch: fix forced branch creation on HEAD of a bare repo The code correctly detects that forced creation of a branch on a nonbare repo should not be able to overwrite a branch which is the HEAD reference. But there's no reason to prevent this on a bare repo, and in fact, git allows this. I.e., git branch -f master new_sha works on a bare repo with HEAD set to master. This change fixes that problem, and updates tests so that, for this case, both the bare and nonbare cases are checked for correct behavior.
Patrick Steinhardt 1c33ecc4 2016-11-01T14:30:38 tests: core: test deinitialization and concurrent initialization Exercise the logic surrounding deinitialization of the libgit2 library as well as repeated concurrent de- and reinitialization. This tries to catch races and makes sure that it is possible to reinitialize libgit2 multiple times. After deinitializing libgit2, we have to make sure to setup options required for testing. Currently, this only includes setting up the configuration search path again. Before, this has been set up once in `tests/main.c`.
Patrick Steinhardt 95fa3880 2016-10-28T16:07:40 pqueue: resolve possible NULL pointer dereference The `git_pqueue` struct allows being fixed in its total number of entries. In this case, we simply throw away items that are inserted into the priority queue by examining wether the new item to be inserted has a higher priority than the previous smallest one. This feature somewhat contradicts our pqueue implementation in that it is allowed to not have a comparison function. In fact, we also fail to check if the comparison function is actually set in the case where we add a new item into a fully filled fixed-size pqueue. As we cannot determine which item is the smallest item in absence of a comparison function, we fix the `NULL` pointer dereference by simply dropping all new items which are about to be inserted into a full fixed-size pqueue.
Patrick Steinhardt 30a876cd 2016-10-27T11:29:15 tests: fetchhead: fix memory leak
Patrick Steinhardt 61ad9bcd 2016-10-27T11:26:52 tests: vector: fix memory leak
Edward Thomson 610cff13 2016-10-09T16:05:48 Merge branch 'pr/3809'
Sim Domingo dc5cfdba 2016-06-02T23:18:31 make git_diff_stats_to_buf not show 0 insertions or 0 deletions
Arthur Schreiber 36117978 2016-10-06T18:30:30 Fix the existence check for `regcomp_l`. `xlocale.h` only defines `regcomp_l` if `regex.h` was included as well. Also change the test cases to actually test `p_regcomp` works with a multibyte locale.
Edward Thomson 45dc219f 2016-10-07T16:01:28 Merge pull request #3921 from libgit2/cmn/walk-limit-enough Improve revision walk preparation logic
Arthur Schreiber ab96ca55 2016-10-06T13:15:31 Make sure we use the `C` locale for `regcomp` on macOS.
Carlos Martín Nieto 48c64362 2016-09-27T11:59:24 revwalk: port over the topological sorting After porting over the commit hiding and selection we were still left with mistmaching output due to the topologial sort. This ports the topological sorting code to make us match with our equivalent of `--date-order` and `--topo-order` against the output from `rev-list`.
Carlos Martín Nieto 0bd43371 2016-09-23T12:42:33 vector, pqueue: add git_vector_reverse and git_pqueue_reverse This is a convenience function to reverse the contents of a vector and a pqueue in-place. The pqueue function is useful in the case where we're treating it as a LIFO queue.
Carlos Martín Nieto 6708618c 2016-07-21T01:24:12 revwalk: get closer to git We had some home-grown logic to figure out which objects to show during the revision walk, but it was rather inefficient, looking over the same list multiple times to figure out when we had run out of interesting commits. We now use the lists in a smarter way. We also introduce the slop mechanism to determine when to stpo looking. When we run out of interesting objects, we continue preparing the walk for another 5 rounds in order to make it less likely that we miss objects in situations with complex graphs.
Edward Thomson 565fb8dc 2016-06-25T20:02:45 revwalk: introduce tests that hide old commits Introduce some tests that show some commits, while hiding some commits that have a timestamp older than the common ancestors of these two commits.
Edward Thomson 9ad07fc0 2016-09-06T10:43:21 Merge pull request #3923 from libgit2/ethomson/diff-read-empty-binary Read binary patches (with no binary data)
Patrick Steinhardt 46035d98 2016-09-06T11:21:29 Merge pull request #3882 from pks-t/pks/fix-fetch-refspec-dst-parsing refspec: do not set empty rhs for fetch refspecs
Edward Thomson adedac5a 2016-09-02T02:03:45 diff: treat binary patches with no data special When creating and printing diffs, deal with binary deltas that have binary data specially, versus diffs that have a binary file but lack the actual binary data.
Carlos Martín Nieto 40b08124 2016-08-30T12:11:02 Merge pull request #3915 from pks-t/pks/index-collision-test-leak tests: index: do not re-allocate index
Stefan Huber 88cfe614 2016-08-24T01:20:39 git_checkout_tree options fix According to the reference the git_checkout_tree and git_checkout_head functions should accept NULL in the opts field This was broken since the opts field was dereferenced and thus lead to a crash.
Patrick Steinhardt 86e88534 2016-08-29T13:09:58 tests: index: do not re-allocate index Plug a memory leak caused by re-allocating a `git_index` structure which has already been allocated by the test suite's initializer.
Edward Thomson b859faa6 2016-08-23T23:38:39 Teach `git_patch_from_diff` about parsed diffs Ensure that `git_patch_from_diff` can return the patch for parsed diffs, not just generate a patch for a generated diff.
Edward Thomson c1b370e9 2016-08-17T09:24:44 Merge pull request #3837 from novalis/dturner/indexv4 Support index v4
Edward Thomson 635a9222 2016-08-17T08:54:48 Merge pull request #3895 from pks-t/pks/negate-basename-in-subdirs ignore: allow unignoring basenames in subdirectories
Patrick Steinhardt fcb2c1c8 2016-08-12T09:06:15 ignore: allow unignoring basenames in subdirectories The .gitignore file allows for patterns which unignore previous ignore patterns. When unignoring a previous pattern, there are basically three cases how this is matched when no globbing is used: 1. when a previous file has been ignored, it can be unignored by using its exact name, e.g. foo/bar !foo/bar 2. when a file in a subdirectory has been ignored, it can be unignored by using its basename, e.g. foo/bar !bar 3. when all files with a basename are ignored, a specific file can be unignored again by specifying its path in a subdirectory, e.g. bar !foo/bar The first problem in libgit2 is that we did not correctly treat the second case. While we verified that the negative pattern matches the tail of the positive one, we did not verify if it only matches the basename of the positive pattern. So e.g. we would have also negated a pattern like foo/fruz_bar !bar Furthermore, we did not check for the third case, where a basename is being unignored in a certain subdirectory again. Both issues are fixed with this commit.
David Turner 5625d86b 2016-05-17T15:40:32 index: support index v4 Support reading and writing index v4. Index v4 uses a very simple compression scheme for pathnames, but is otherwise similar to index v3. Signed-off-by: David Turner <dturner@twitter.com>
David Turner aeb5ee5a 2016-05-17T15:40:46 varint: Add varint encoding/decoding This code is ported from git.git Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: David Turner <dturner@twopensource.com>
Edward Thomson 5961face 2016-08-09T08:07:10 Merge pull request #3893 from pks-t/pks/remove-unused-test-cb tests: blob: remove unused callback function
Patrick Steinhardt 4006455f 2016-08-09T10:09:23 tests: blob: remove unused callback function
Edward Thomson 9bc8c80f 2016-08-05T20:34:19 odb: actually insert the empty blob in tests
Edward Thomson becadafc 2016-08-05T19:30:56 odb: only provide the empty tree Only provide the empty tree internally, which matches git's behavior. If we provide the empty blob then any users trying to write it with libgit2 would omit it from actually landing in the odb, which appear to git proper as a broken repository (missing that object).
Carlos Martín Nieto c550c922 2016-08-05T18:24:28 Merge pull request #3881 from pks-t/pks/fix-clar-suite-prefix-computation clar: fix parsing of test suite prefixes
Edward Thomson 27051d4e 2016-07-22T13:34:19 odb: only freshen pack files every 2 seconds Since writing multiple objects may all already exist in a single packfile, avoid freshening that packfile repeatedly in a tight loop. Instead, only freshen pack files every 2 seconds.
Edward Thomson 8f09a98e 2016-07-14T16:23:24 odb: freshen existing objects when writing When writing an object, we calculate its OID and see if it exists in the object database. If it does, we need to freshen the file that contains it.
Edward Thomson 78b500bf 2016-08-04T12:45:19 Merge pull request #3850 from wildart/custom-tls Enable https transport for custom TLS streams
Patrick Steinhardt 1eee631d 2016-08-04T13:45:28 refspec: do not set empty rhs for fetch refspecs According to git-fetch(1), "[t]he colon can be omitted when <dst> is empty." So according to git, the refspec "refs/heads/master" is the same as the refspec "refs/heads/master:" when fetching changes. When trying to fetch from a remote with a trailing colon with libgit2, though, the fetch actually fails while it works when the trailing colon is left out. So obviously, libgit2 does _not_ treat these two refspec formats the same for fetches. The problem results from parsing refspecs, where the resulting refspec has its destination set to an empty string in the case of a trailing colon and to a `NULL` pointer in the case of no trailing colon. When passing this to our DWIM machinery, the empty string gets translated to "refs/heads/", which is simply wrong. Fix the problem by having the parsing machinery treat both cases the same for fetch refspecs.
Patrick Steinhardt f2cab0a6 2016-08-04T11:49:39 clar: fix parsing of test suite prefixes When passing in a specific suite which should be executed by clar via `-stest::suite`, we try to parse this string and then include all tests contained in this suite. This also includes all tests in sub-suites, e.g. 'test::suite::foo'. In the case where multiple suites start with the same _string_, for example 'test::foo' and 'test::foobar', we fail to distinguish this correctly. When passing in `-stest::foobar`, we wrongly determine that 'test::foo' is a prefix and try to execute all of its matching functions. But as no function will now match 'test::foobar', we simply execute nothing. To fix this, we instead have to check if the prefix is an actual suite prefix as opposed to a simple string prefix. We do so by by inspecting if the first two characters trailing the prefix are our suite delimiters '::', and only consider the filter as matching in this case.
Edward Thomson e02f5676 2016-07-15T12:43:57 repo::open: remove dead code, free buffers
Edward Thomson 498d0801 2016-07-22T12:01:24 tests: use a `size_t`
wildart bdec62dc 2016-07-06T13:06:25 remove conditions that prevent use of custom TLS stream
Edward Thomson c18a2bc4 2016-07-05T15:51:01 Merge pull request #3851 from txdv/get-user-agent Add get user agent functionality.
Edward Thomson b57c176a 2016-07-05T12:46:27 Merge pull request #3846 from rkrp/fix_bug_parsing_int64min Fixed bug while parsing INT64_MIN
Andrius Bentkus f1dba144 2016-07-05T09:41:51 Add get user agent functionality.
Edward Thomson ebeb56f0 2016-07-01T18:45:10 Merge pull request #3711 from joshtriplett/git_repository_discover_default Add GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment vars
Edward Thomson 6249d960 2016-06-29T17:55:44 index: include conflicts in `git_index_read_index` Ensure that we include conflicts when calling `git_index_read_index`, which will remove conflicts in the index that do not exist in the new target, and will add conflicts from the new target.
Krishna Ram Prakash R 70b9b841 2016-06-28T20:19:52 Fixed bug while parsing INT64_MIN
Edward Thomson 20302aa4 2016-06-25T23:33:05 Merge pull request #3223 from ethomson/apply Reading patch files
Edward Thomson 1a79cd95 2016-04-26T01:18:01 patch: show copy information for identical copies When showing copy information because we are duplicating contents, for example, when performing a `diff --find-copies-harder -M100 -B100`, then show copy from/to lines in a patch, and do not show context. Ensure that we can also parse such patches.
Edward Thomson 9eb19381 2016-04-25T22:35:55 patch::parse: test diff with exact rename and copy
Edward Thomson 8a670dc4 2016-04-25T18:08:03 patch::parse: test diff with simple rename
Edward Thomson e774d5af 2016-04-25T16:47:48 diff::parse tests: test parsing a diff Test that we can create a diff file, then parse the results and that the two are identical in-memory.
Josh Triplett 0dd98b69 2016-04-03T17:22:07 Add GIT_REPOSITORY_OPEN_FROM_ENV flag to respect $GIT_* environment vars git_repository_open_ext provides parameters for the start path, whether to search across filesystems, and what ceiling directories to stop at. git commands have standard environment variables and defaults for each of those, as well as various other parameters of the repository. To avoid duplicate environment variable handling in users of libgit2, add a GIT_REPOSITORY_OPEN_FROM_ENV flag, which makes git_repository_open_ext automatically handle the appropriate environment variables. Commands that intend to act just like those built into git itself can use this flag to get the expected default behavior. git_repository_open_ext with the GIT_REPOSITORY_OPEN_FROM_ENV flag respects $GIT_DIR, $GIT_DISCOVERY_ACROSS_FILESYSTEM, $GIT_CEILING_DIRECTORIES, $GIT_INDEX_FILE, $GIT_NAMESPACE, $GIT_OBJECT_DIRECTORY, and $GIT_ALTERNATE_OBJECT_DIRECTORIES. In the future, when libgit2 gets worktree support, git_repository_open_env will also respect $GIT_WORK_TREE and $GIT_COMMON_DIR; until then, git_repository_open_ext with this flag will error out if either $GIT_WORK_TREE or $GIT_COMMON_DIR is set.
Josh Triplett 39c6fca3 2016-04-03T16:01:01 Add GIT_REPOSITORY_OPEN_NO_DOTGIT flag to avoid appending /.git GIT_REPOSITORY_OPEN_NO_SEARCH does not search up through parent directories, but still tries the specified path both directly and with /.git appended. GIT_REPOSITORY_OPEN_BARE avoids appending /.git, but opens the repository in bare mode even if it has a working directory. To support the semantics git uses when given $GIT_DIR in the environment, provide a new GIT_REPOSITORY_OPEN_NO_DOTGIT flag to not try appending /.git.
Josh Triplett ed577134 2016-04-03T19:24:15 Fix repository discovery with ceiling_dirs at current directory git only checks ceiling directories when its search ascends to a parent directory. A ceiling directory matching the starting directory will not prevent git from finding a repository in the starting directory or a parent directory. libgit2 handled the former case correctly, but differed from git in the latter case: given a ceiling directory matching the starting directory, but no repository at the starting directory, libgit2 would stop the search at that point rather than finding a repository in a parent directory. Test case using git command-line tools: /tmp$ git init x Initialized empty Git repository in /tmp/x/.git/ /tmp$ cd x/ /tmp/x$ mkdir subdir /tmp/x$ cd subdir/ /tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x git rev-parse --git-dir fatal: Not a git repository (or any of the parent directories): .git /tmp/x/subdir$ GIT_CEILING_DIRECTORIES=/tmp/x/subdir git rev-parse --git-dir /tmp/x/.git Fix the testsuite to test this case (in one case fixing a test that depended on the current behavior), and then fix find_repo to handle this case correctly. In the process, simplify and document the logic in find_repo(): - Separate the concepts of "currently checking a .git directory" and "number of iterations left before going further counts as a search" into two separate variables, in_dot_git and min_iterations. - Move the logic to handle in_dot_git and append /.git to the top of the loop. - Only search ceiling_dirs and find ceiling_offset after running out of min_iterations; since ceiling_offset only tracks the longest matching ceiling directory, if ceiling_dirs contained both the current directory and a parent directory, this change makes find_repo stop the search at the parent directory.
Patrick Steinhardt fe345c73 2016-02-09T12:29:31 Remove unused static functions
Patrick Steinhardt 8fd74c08 2016-02-09T12:18:28 Avoid old-style function definitions Avoid declaring old-style functions without any parameters. Functions not accepting any parameters should be declared with `void fn(void)`. See ISO C89 $3.5.4.3.
Patrick Steinhardt faebc1c6 2016-06-20T17:44:04 threads: split up OS-dependent thread code
Edward Thomson bb0bd71a 2016-06-15T15:47:28 checkout: use empty baseline when no index When no index file exists and a baseline is not explicitly provided, use an empty baseline instead of trying to load `HEAD`.
Patrick Steinhardt 292c6027 2016-06-07T12:29:16 tests: fix memory leaks in checkout::typechange
Edward Thomson 5acf18ac 2016-06-02T01:58:25 rebase: test rebasing a new commit with subfolder Test a rebase (both a merge rebase and an inmemory rebase) with a new commit that adds files underneath a new subfolder.
Edward Thomson 91fbf9d8 2016-06-01T22:31:16 test: ensure we can round-trip a written tree Read a tree into an index, write the index, then re-open the index and ensure that we are treesame to the original.
Edward Thomson 5baa20b8 2016-06-01T14:52:25 round-trip trees through index_read_index Read a tree into an index using `git_index_read_index` (by reading a tree into a new index, then reading that index into the current index), then write the index back out, ensuring that our new index is treesame to the tree that we read.
Edward Thomson c2f18b9b 2016-05-26T10:51:16 cleanup: unused warning
Edward Thomson 7166bb16 2016-04-25T00:35:48 introduce `git_diff_from_buffer` to parse diffs Parse diff files into a `git_diff` structure.
Edward Thomson 94e488a0 2016-04-24T16:14:25 patch: differentiate not found and invalid patches
Edward Thomson 17572f67 2016-04-21T00:04:14 git_patch_parse_ctx: refcount the context
Edward Thomson 9be638ec 2016-04-19T15:12:18 git_diff_generated: abstract generated diffs
Edward Thomson 53571f2f 2015-11-21T15:16:01 vector: more sensible names for `grow_at`/`shrink_at`
Edward Thomson 440e3bae 2015-11-21T12:27:03 patch: `git_patch_from_patchfile` -> `git_patch_from_buffer`
Edward Thomson e564fc65 2015-09-25T12:41:15 git_vector_grow/shrink: correct shrink, and tests
Edward Thomson 0ff723cc 2015-09-25T12:09:50 apply: test postimages that grow/shrink original Test with some postimages that actually grow/shrink from the original, adding new lines or removing them. (Also do so without context to ensure that we can add/remove from a non-zero part of the line vector.)
Edward Thomson 8cb27223 2015-09-25T10:48:19 git_buf_quote/unquote: handle > \177 Parse values up to and including `\377` (`0xff`) when unquoting. Print octal values as an unsigned char when quoting, lest `printf` think we're talking about negatives.
Edward Thomson 6278fbc5 2015-09-24T09:40:42 patch parsing: squash some memory leaks
Edward Thomson d3d95d5a 2015-09-23T16:30:48 git_buf_quote: quote ugly characters