Re: bug: git-archive does not use the zip64 extension for archives with more than 16k entries

2015-08-12 Thread René Scharfe
Am 11.08.2015 um 12:40 schrieb Johannes Schauer: Hi, for repositories with more than 16k files and folders, git-archive will create zip files which store the wrong number of entries. That is, it stores the number of entries modulo 16k. This will break unpackers that do not include code to suppor

[PATCH 3/3] archive-zip: support more than 65535 entries

2015-08-22 Thread René Scharfe
Support more than 65535 entries cleanly by writing a "zip64 end of central directory record" (with a 64-bit field for the number of entries) before the usual "end of central directory record" (which contains only a 16-bit field). InfoZIP's zip does the same. Archives with 65535 or less entries are

[PATCH 2/3] archive-zip: use a local variable to store the creator version

2015-08-22 Thread René Scharfe
Use a simpler conditional right next to the code which makes a higher creator version necessary -- namely symlink handling and support for executable files -- instead of a long line with a ternary operator. The resulting code has more lines but is simpler and allows reuse of the value easily. Sign

[PATCH 1/3] t5004: test ZIP archives with many entries

2015-08-22 Thread René Scharfe
A ZIP file directory has a 16-bit field for the number of entries it contains. There are 64-bit extensions to deal with that. Demonstrate that git archive --format=zip currently doesn't use them and instead overflows the field. InfoZIP's unzip doesn't care about this field and extracts all files

Re: [PATCH 1/3] t5004: test ZIP archives with many entries

2015-08-23 Thread René Scharfe
Am 23.08.2015 um 07:54 schrieb Eric Sunshine: > On Sat, Aug 22, 2015 at 3:06 PM, René Scharfe wrote: >> diff --git a/t/t5004-archive-corner-cases.sh >> b/t/t5004-archive-corner-cases.sh >> index 654adda..c6bd729 100755 >> --- a/t/t5004-archive-corner-cases.sh >

Eric Sunshine mail delivery failure

2015-08-23 Thread René Scharfe
Eric, hope you see this reply on the list. Direct replies to sunsh...@sunshineco.com are rejected by my mail provider on submit in Thunderbird with the following message: Requested action not taken: mailbox unavailable invalid DNS MX or A/ resource record. And with this one when us

Re: [PATCH 60/68] prefer memcpy to strcpy

2015-09-27 Thread René Scharfe
Am 24.09.2015 um 23:08 schrieb Jeff King: When we already know the length of a string (e.g., because we just malloc'd to fit it), it's nicer to use memcpy than strcpy, as it makes it more obvious that we are not going to overflow the buffer (because the size we pass matches the size in the alloca

Re: [PATCH 60/68] prefer memcpy to strcpy

2015-09-27 Thread René Scharfe
Am 27.09.2015 um 15:06 schrieb Torsten Bögershausen: On 2015-09-27 13.19, René Scharfe wrote: Am 24.09.2015 um 23:08 schrieb Jeff King: When we already know the length of a string (e.g., because we just malloc'd to fit it), it's nicer to use memcpy than strcpy, as it makes it more ob

Re: [PATCH 60/68] prefer memcpy to strcpy

2015-09-27 Thread René Scharfe
Am 27.09.2015 um 15:13 schrieb René Scharfe: Am 27.09.2015 um 15:06 schrieb Torsten Bögershausen: On 2015-09-27 13.19, René Scharfe wrote: Am 24.09.2015 um 23:08 schrieb Jeff King: When we already know the length of a string (e.g., because we just malloc'd to fit it), it's nicer to

Re: [PATCH] grep: use regcomp() for icase search with non-ascii patterns

2015-07-06 Thread René Scharfe
Am 06.07.2015 um 14:42 schrieb Nguyễn Thái Ngọc Duy: Noticed-by: Plamen Totev Signed-off-by: Nguyễn Thái Ngọc Duy --- grep.c | 14 +++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/grep.c b/grep.c index b58c7c6..48db15a 100644 --- a/grep.c +++ b/grep.c @@ -378,7 +

git@vger.kernel.org

2015-07-10 Thread René Scharfe
Signed-off-by: Rene Scharfe --- GIT_TEST_CHAIN_LINT complains about the missing &&s and is enabled by default now. t/perf/p5310-pack-bitmaps.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/perf/p5310-pack-bitmaps.sh b/t/perf/p5310-pack-bitmaps.sh index f8ed857..de2

git@vger.kernel.org

2015-07-11 Thread René Scharfe
Am 10.07.2015 um 22:50 schrieb Jeff King: Thanks, this definitely is a problem, but we already have a fix in the sb/p5310-and-chain topic. I thought that had been merged-up, but it looks like it is only in "next" right now. All the better. And I see it's in master now. René -- To unsubscribe

[PATCH] diff: parse ws-error-highlight option more strictly

2015-07-11 Thread René Scharfe
Check if a matched token is followed by a delimiter before advancing the pointer arg. This avoids accepting composite words like "allnew" or "defaultcontext". Signed-off-by: Rene Scharfe --- diff.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/diff.c b/diff.c index 8

Re: [PATCH 2/2] archive-tar: write extended headers for far-future mtime

2016-06-20 Thread René Scharfe
Am 16.06.2016 um 06:37 schrieb Jeff King: The ustar format represents timestamps as seconds since the epoch, but only has room to store 11 octal digits. To express anything larger, we need to use an extended header. This is exactly the same case we fixed for the size field in the previous commit

Re: [PATCH 1/2] archive-tar: write extended headers for file sizes >= 8GB

2016-06-20 Thread René Scharfe
Am 16.06.2016 um 06:37 schrieb Jeff King: The ustar format has a fixed-length field for the size of each file entry which is supposed to contain up to 11 bytes of octal-formatted data plus a NUL or space terminator. These means that the largest size we can represent is 0777, or 1 byte sh

Re: [PATCH 1/2] archive-tar: write extended headers for file sizes >= 8GB

2016-06-21 Thread René Scharfe
Am 21.06.2016 um 17:59 schrieb Jeff King: > On Tue, Jun 21, 2016 at 12:54:11AM +0200, René Scharfe wrote: > >>> Unfortunately, it's quite an expensive test to run. For one >>> thing, unless your filesystem supports files with holes, it >>> takes 64GB of disk

Re: [PATCH 1/2] archive-tar: write extended headers for file sizes >= 8GB

2016-06-21 Thread René Scharfe
Am 21.06.2016 um 22:42 schrieb René Scharfe: > The value 120 is magic; we need it to pass the tests. That's > because prepare_header() is used for building extended header > records as well and we don't create extended headers for extended > headers (not sure if that would

Re: [PATCH 1/2] archive-tar: write extended headers for file sizes >= 8GB

2016-06-21 Thread René Scharfe
Am 21.06.2016 um 17:59 schrieb Jeff King: > On Tue, Jun 21, 2016 at 12:54:11AM +0200, René Scharfe wrote: > >>> Unfortunately, it's quite an expensive test to run. For one >>> thing, unless your filesystem supports files with holes, it >>> takes 64GB of disk

Re: [PATCH 1/2] archive-tar: write extended headers for file sizes >= 8GB

2016-06-21 Thread René Scharfe
Am 21.06.2016 um 23:02 schrieb Jeff King: On Tue, Jun 21, 2016 at 10:42:52PM +0200, René Scharfe wrote: If we could set the limit to a lower value than 8GB for testing then we could at least check if the extended header is written, e.g. if ustar_size() could be convinced to return 0 every time

Re: [PATCH 1/2] archive-tar: write extended headers for file sizes >= 8GB

2016-06-21 Thread René Scharfe
Am 21.06.2016 um 23:04 schrieb Jeff King: > On Tue, Jun 21, 2016 at 10:57:43PM +0200, René Scharfe wrote: > >> Am 21.06.2016 um 22:42 schrieb René Scharfe: >>> The value 120 is magic; we need it to pass the tests. That's >>> because prepare_header() i

Re: [PATCH 2/2] archive-tar: write extended headers for far-future mtime

2016-06-21 Thread René Scharfe
Am 21.06.2016 um 00:54 schrieb René Scharfe: Am 16.06.2016 um 06:37 schrieb Jeff King: 2. System tars that cannot handle pax headers. In t5000 there is a simple interpreter for path headers for systems whose tar doesn't handle them. Adding one for mtime headers may be feasible. It&#

Re: [PATCH 2/2] archive-tar: write extended headers for far-future mtime

2016-06-23 Thread René Scharfe
Am 23.06.2016 um 21:22 schrieb Jeff King: On Wed, Jun 22, 2016 at 07:46:25AM +0200, René Scharfe wrote: Am 21.06.2016 um 00:54 schrieb René Scharfe: Am 16.06.2016 um 06:37 schrieb Jeff King: 2. System tars that cannot handle pax headers. In t5000 there is a simple interpreter for path

[PATCH] am: ignore return value of write_file()

2016-07-07 Thread René Scharfe
write_file() either returns 0 or dies, so there is no point in checking its return value. The callers of the wrappers write_state_text(), write_state_count() and write_state_bool() consequently already ignore their return values. Stop pretenting we care and make them void. Signed-off-by: Rene Sc

[PATCH] notes-merge: use O_EXCL to avoid overwriting existing files

2016-07-07 Thread René Scharfe
Use the open(2) flag O_EXCL to ensure the file doesn't already exist instead of (racily) calling stat(2) through file_exists(). While at it switch to xopen() to reduce code duplication and get more consistent error messages. Signed-off-by: Rene Scharfe --- notes-merge.c | 6 +- 1 file chang

[PATCH] .gitattributes: set file type for C files

2016-07-07 Thread René Scharfe
Set the diff attribute for C source file to "cpp" in order to improve git's ability to determine hunk headers. In particular it helps avoid showing unindented labels in hunk headers. That in turn is useful for git diff -W and git grep -W, which show whole functions now instead of stopping at a la

Re: [PATCH] am: ignore return value of write_file()

2016-07-08 Thread René Scharfe
Hi Dscho, Am 08.07.2016 um 08:33 schrieb Johannes Schindelin: On Thu, 7 Jul 2016, René Scharfe wrote: write_file() either returns 0 or dies, so there is no point in checking its return value. The question is whether it makes sense for write_file() to die(). It is a library function and not

Re: [PATCH 0/8] write_file cleanups

2016-07-08 Thread René Scharfe
Am 08.07.2016 um 11:04 schrieb Jeff King: Here it is. There actually weren't that many spots to clean up, as quite a few of them have a "twist" where they want to do something clever, like open the file and feed the descriptor to a sub-function, or open with funny things like O_EXCL. But still,

[PATCH] rm: reuse strbuf for all remove_dir_recursively() calls

2016-07-09 Thread René Scharfe
Don't throw the memory allocated for remove_dir_recursively() away after a single call, use it for the other entries as well instead. Signed-off-by: Rene Scharfe --- builtin/rm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/rm.c b/builtin/rm.c index 8abb020..b

[PATCH] worktree: use strbuf_add_absolute_path() directly

2016-07-09 Thread René Scharfe
absolute_path() is a wrapper for strbuf_add_absolute_path(). Call the latter directly for adding absolute paths to a strbuf. That's shorter and avoids an extra string copy. Signed-off-by: Rene Scharfe --- worktree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worktr

Re: Question: Getting 'git diff' to generate /usr/bin/diff output

2016-07-17 Thread René Scharfe
Am 16.07.2016 um 21:12 schrieb n...@dad.org: I am trying to learn how to use git, and am having difficulty using 'git diff'. I can't deal with its output very well. The other replies covered how to use the system's own diff instead. Just curious: What makes using git diff difficult and its ou

[PATCH] use strbuf_addbuf() for appending a strbuf to another

2016-07-19 Thread René Scharfe
Use strbuf_addbuf() where possible; it's shorter and more efficient. Signed-off-by: Rene Scharfe --- dir.c | 2 +- path.c | 2 +- wt-status.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dir.c b/dir.c index 6172b34..0ea235f 100644 --- a/dir.c +++ b/dir.c @@ -

[PATCH] submodule-config: use explicit empty string instead of strbuf in config_from()

2016-07-19 Thread René Scharfe
Use a string constant instead of an empty strbuf to shorten the code and make it easier to read. Signed-off-by: Rene Scharfe --- ... unless someone can come up with a suitable non-empty string to feed to git_config_from_mem() as its name parameter. submodule-config.c | 3 +-- 1 file changed, 1

Re: [PATCH] use strbuf_addbuf() for appending a strbuf to another

2016-07-21 Thread René Scharfe
Am 20.07.2016 um 15:20 schrieb Jeff King: > On Tue, Jul 19, 2016 at 08:36:29PM +0200, René Scharfe wrote: > >> Use strbuf_addbuf() where possible; it's shorter and more efficient. > > After seeing "efficient", I was momentarily surprised by the first hunk:

Re: [PATCH] submodule-config: use explicit empty string instead of strbuf in config_from()

2016-07-21 Thread René Scharfe
Am 20.07.2016 um 10:25 schrieb Heiko Voigt: Hi, On Tue, Jul 19, 2016 at 09:05:43PM +0200, René Scharfe wrote: Use a string constant instead of an empty strbuf to shorten the code and make it easier to read. This must have been some oversight from my original code. I also can not see any

[PATCH] use strbuf_addstr() for adding constant strings to a strbuf

2016-07-30 Thread René Scharfe
Replace uses of strbuf_addf() for adding strings with more lightweight strbuf_addstr() calls. In http-push.c it becomes easier to see what's going on without having to verfiy that the definition of PROPFIND_ALL_REQUEST doesn't contain any format specifiers. Signed-off-by: Rene Scharfe --- built

[PATCH] pass constants as first argument to st_mult()

2016-07-30 Thread René Scharfe
The result of st_mult() is the same no matter the order of its arguments. It invokes the macro unsigned_mult_overflows(), which divides the second parameter by the first one. Pass constants first to allow that division to be done already at compile time. Signed-off-by: Rene Scharfe --- diffcor

Re: [PATCH 2/2] nedmalloc: work around overzealous GCC 6 warning

2016-08-04 Thread René Scharfe
Am 04.08.2016 um 18:07 schrieb Johannes Schindelin: With GCC 6, the strdup() function is declared with the "nonnull" attribute, stating that it is not allowed to pass a NULL value as parameter. In nedmalloc()'s reimplementation of strdup(), Postel's Law is heeded and NULL parameters are handled

[PATCH] use strbuf_addstr() instead of strbuf_addf() with "%s"

2016-08-05 Thread René Scharfe
Call strbuf_addstr() for adding a simple string to a strbuf instead of using the heavier strbuf_addf(). This is shorter and documents the intent more clearly. Signed-off-by: Rene Scharfe --- builtin/fmt-merge-msg.c | 2 +- http.c | 2 +- sequencer.c | 2 +- 3 files

[PATCH] use CHILD_PROCESS_INIT to initialize automatic variables

2016-08-05 Thread René Scharfe
Initialize struct child_process variables already when they're defined. That's shorter and saves a function call. Signed-off-by: Rene Scharfe --- builtin/submodule--helper.c | 3 +-- builtin/worktree.c | 6 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/builtin/su

[PATCH] merge-recursive: use STRING_LIST_INIT_NODUP

2016-08-05 Thread René Scharfe
Initialize a string_list right when it's defined. That's shorter, saves a function call and makes it more obvious that we're using the NODUP variant here. Signed-off-by: Rene Scharfe --- merge-recursive.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/merge-recursive.c b/

[PATCH] merge: use string_list_split() in add_strategies()

2016-08-05 Thread René Scharfe
Call string_list_split() for cutting a space separated list into pieces instead of reimplementing it based on struct strategy. The attr member of struct strategy was not used split_merge_strategies(); it was a pure string operation. Also be nice and clean up once we're done splitting; the old cod

Re: [PATCH 2/2] nedmalloc: work around overzealous GCC 6 warning

2016-08-06 Thread René Scharfe
r comments below. Thanks. -- >8 -- From: René Scharfe Date: Thu, 4 Aug 2016 23:56:54 +0200 Subject: [PATCH] nedmalloc: work around overzealous GCC 6 warning With GCC 6, the strdup() function is declared with the "nonnull" attribute, stating that it is not allowed to pass a NULL value a

[PATCH] archive-tar: make write_extended_header() void

2016-08-06 Thread René Scharfe
The function write_extended_header() only ever returns 0. Simplify it and its caller by dropping its return value, like we did with write_global_extended_header() earlier. Signed-off-by: Rene Scharfe --- archive-tar.c | 15 +-- 1 file changed, 5 insertions(+), 10 deletions(-) diff

[PATCH] use strbuf_add_unique_abbrev() for adding short hashes

2016-08-06 Thread René Scharfe
Call strbuf_add_unique_abbrev() to add abbreviated hashes to strbufs instead of taking detours through find_unique_abbrev() and its static buffer. This is shorter and a bit more efficient. Signed-off-by: Rene Scharfe --- builtin/checkout.c | 3 +-- pretty.c | 13 ++--- transp

Re: Rename detection within in files WAS: [PATCH 2/6] t7408: merge short tests, factor out testing method

2016-08-07 Thread René Scharfe
Am 06.08.2016 um 01:26 schrieb Stefan Beller: When moving code around, we usually get large chunks of text. If the contributor is not 100% trustworthy, we need to review all the code without much intelectual joy. Essentially the reviewer is just making sure the parts of the text are the same. I'

Re: [PATCH 1/3] compat: add qsort_s()

2016-12-21 Thread René Scharfe
Am 12.12.2016 um 20:57 schrieb Jeff King: On Mon, Dec 12, 2016 at 08:51:14PM +0100, René Scharfe wrote: It's kinda cool to have a bespoke compatibility layer for major platforms, but the more I think about it the less I can answer why we would want that. Safety, reliability and perfor

[PATCH] string-list: make compare function compatible with qsort(3)

2016-12-21 Thread René Scharfe
The cmp member of struct string_list points to a comparison function that is used for sorting and searching of list items. It takes two string pointers -- like strcmp(3), which is in fact the default; cmp_items() provides a qsort(3) compatible interface by passing the string members of two struct

Re: [PATCH] unpack-trees: move checkout state into check_updates

2016-12-29 Thread René Scharfe
Am 29.12.2016 um 00:26 schrieb Stefan Beller: The checkout state was introduced via 16da134b1f9 (read-trees: refactor the unpack_trees() part, 2006-07-30). An attempt to refactor the checkout state was done in b56aa5b268e (unpack-trees: pass checkout state explicitly to check_updates(), 2016-09-1

Re: [PATCH] string-list: make compare function compatible with qsort(3)

2016-12-29 Thread René Scharfe
Am 21.12.2016 um 17:12 schrieb Jeff King: On Wed, Dec 21, 2016 at 10:36:41AM +0100, René Scharfe wrote: One shortcoming is that the comparison function is restricted to working with the string members of items; util is inaccessible to it. Another one is that the value of cmp is passed in a

Re: [PATCH] submodule.c: use GIT_DIR_ENVIRONMENT consistently

2016-12-29 Thread René Scharfe
Am 30.12.2016 um 01:47 schrieb Stefan Beller: diff --git a/submodule.c b/submodule.c index ece17315d6..973b9f3f96 100644 --- a/submodule.c +++ b/submodule.c @@ -1333,5 +1333,6 @@ void prepare_submodule_repo_env(struct argv_array *out) if (strcmp(*var, CONFIG_DATA_ENVIRONMENT))

Re: [PATCH] archive-zip: load userdiff config

2017-01-03 Thread René Scharfe
Am 02.01.2017 um 23:25 schrieb Jeff King: Since 4aff646d17 (archive-zip: mark text files in archives, 2015-03-05), the zip archiver will look at the userdiff driver to decide whether a file is text or binary. This usually doesn't need to look any further than the attributes themselves (e.g., "-di

Re: [PATCH 1/3] xdiff: -W: relax end-of-file function detection

2017-01-13 Thread René Scharfe
n its entirety as (uncalled for) context. Cc: René Scharfe Signed-off-by: Vegard Nossum --- xdiff/xemit.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/xdiff/xemit.c b/xdiff/xemit.c index 7389ce4..8c88dbd 100644 --- a/xdiff/xemit.c +++ b/xdiff/xemit.c @@ -1

Re: [PATCH 2/3] xdiff: -W: include immediately preceding non-empty lines in context

2017-01-13 Thread René Scharfe
Am 13.01.2017 um 17:15 schrieb Vegard Nossum: When using -W to include the whole function in the diff context, you are typically doing this to be able to review the change in its entirety within the context of the function. It is therefore almost always desirable to include any comments that imme

Re: [PATCH 2/3] xdiff: -W: include immediately preceding non-empty lines in context

2017-01-14 Thread René Scharfe
Am 14.01.2017 um 00:56 schrieb Junio C Hamano: Vegard Nossum writes: The patch will work as intended and as expected for 95% of the users out there (javadoc, Doxygen, kerneldoc, etc. all have the comment immediately preceding the function) and fixes a very real problem for me (and I expect man

Re: [PATCHv3 2/2] builtin/commit.c: switch to xstrfmt(), instead of snprintf,

2017-01-14 Thread René Scharfe
Am 13.01.2017 um 18:58 schrieb Elia Pinto: > In this patch, instead of using xnprintf instead of snprintf, which asserts > that we don't truncate, we are switching to dynamic allocation with > xstrfmt(), > , so we can avoid dealing with magic numbers in the code and reduce the > cognitive burden

Re: [PATCH 2/3] xdiff: -W: include immediately preceding non-empty lines in context

2017-01-15 Thread René Scharfe
Am 15.01.2017 um 03:39 schrieb Junio C Hamano: > René Scharfe writes: > >>> I am also more focused on keeping the codebase maintainable in good >>> health by making sure that we made an effort to find a solution that >>> is general-enough before solving a

Re: [PATCH 2/3] xdiff: -W: include immediately preceding non-empty lines in context

2017-01-15 Thread René Scharfe
Am 15.01.2017 um 11:06 schrieb Vegard Nossum: On 15/01/2017 03:39, Junio C Hamano wrote: René Scharfe writes: How about extending the context upward only up to and excluding a line that is either empty *or* a function line? That would limit the extra context to a single function in the worst

[PATCH v2 0/5] string-list: make string_list_sort() reentrant

2017-01-22 Thread René Scharfe
Use qsort_s() from C11 Annex K to make string_list_sort() safer, in particular when called from parallel threads. Changes from v1: * Renamed HAVE_QSORT_S to HAVE_ISO_QSORT_S in Makefile to disambiguate. * Added basic perf test (patch 3). * Converted a second caller to QSORT_S, in ref-filter.c (pat

[PATCH v2 1/5] compat: add qsort_s()

2017-01-22 Thread René Scharfe
The function qsort_s() was introduced with C11 Annex K; it provides the ability to pass a context pointer to the comparison function, supports the convention of using a NULL pointer for an empty array and performs a few safety checks. Add an implementation based on compat/qsort.c for platforms tha

[PATCH v2 3/5] perf: add basic sort performance test

2017-01-22 Thread René Scharfe
Add a sort command to test-string-list that reads lines from stdin, stores them in a string_list and then sorts it. Use it in a simple perf test script to measure the performance of string_list_sort(). Signed-off-by: Rene Scharfe --- t/helper/test-string-list.c | 25 + t

[PATCH v2 4/5] string-list: use QSORT_S in string_list_sort()

2017-01-22 Thread René Scharfe
Pass the comparison function to cmp_items() via the context parameter of qsort_s() instead of using a global variable. That allows calling string_list_sort() from multiple parallel threads. Our qsort_s() in compat/ is slightly slower than qsort(1) from glibc 2.24 for sorting lots of lines: Test

[PATCH v2 5/5] ref-filter: use QSORT_S in ref_array_sort()

2017-01-22 Thread René Scharfe
Pass the array of sort keys to compare_refs() via the context parameter of qsort_s() instead of using a global variable; that's cleaner and simpler. If ref_array_sort() is to be called from multiple parallel threads then care still needs to be taken that the global variable used_atom is not modifi

[PATCH v2 2/5] add QSORT_S

2017-01-22 Thread René Scharfe
Add the macro QSORT_S, a convenient wrapper for qsort_s() that infers the size of the array elements and dies on error. Basically all possible errors are programming mistakes (passing NULL as base of a non-empty array, passing NULL as comparison function, out-of-bounds accesses), so terminating th

[DEMO][PATCH v2 6/5] compat: add a qsort_s() implementation based on GNU's qsort_r(1)

2017-01-22 Thread René Scharfe
Implement qsort_s() as a wrapper to the GNU version of qsort_r(1) and use it on Linux. Performance increases slightly: Test HEAD^ HEAD 0071.2: sort(1) 0.10(0.20+0.02) 0.10(0.21+

Re: [DEMO][PATCH v2 6/5] compat: add a qsort_s() implementation based on GNU's qsort_r(1)

2017-01-24 Thread René Scharfe
Am 23.01.2017 um 20:07 schrieb Junio C Hamano: > René Scharfe writes: > >> Implement qsort_s() as a wrapper to the GNU version of qsort_r(1) and >> use it on Linux. Performance increases slightly: >> >> Test

Re: [PATCH v2 0/5] string-list: make string_list_sort() reentrant

2017-01-24 Thread René Scharfe
Am 24.01.2017 um 00:54 schrieb Jeff King: The speed looks like a reasonable outcome. I'm torn on the qsort_r() demo patch. I don't think it looks too bad. OTOH, I don't think I would want to deal with the opposite-argument-order versions. The code itself may look OK, but it's not really necessa

Re: [DEMO][PATCH v2 6/5] compat: add a qsort_s() implementation based on GNU's qsort_r(1)

2017-01-25 Thread René Scharfe
Am 24.01.2017 um 21:39 schrieb Jeff King: On Tue, Jan 24, 2017 at 07:00:03PM +0100, René Scharfe wrote: I do worry about having to support more implementations in the future that have different function signature for the comparison callbacks, which will make things ugly, but this addition

PATCH 1/2] abspath: add absolute_pathdup()

2017-01-26 Thread René Scharfe
Add a function that returns a buffer containing the absolute path of its argument and a semantic patch for its intended use. It avoids an extra string copy to a static buffer. Signed-off-by: Rene Scharfe --- abspath.c| 7 +++ cache.h

[PATCH 2/2] use absolute_pathdup()

2017-01-26 Thread René Scharfe
Apply the symantic patch for converting callers that duplicate the result of absolute_path() to call absolute_pathdup() instead, which avoids an extra string copy to a static buffer. Signed-off-by: Rene Scharfe --- builtin/clone.c | 4 ++-- builtin/submodule--helper.c | 2 +- worktre

Re: [PATCH 2/2] use absolute_pathdup()

2017-01-27 Thread René Scharfe
Hi Dscho, Am 27.01.2017 um 11:21 schrieb Johannes Schindelin: On Thu, 26 Jan 2017, René Scharfe wrote: Apply the symantic patch for converting callers that duplicate the s/symantic/semantic/ thank you! I wonder where this came from. And where my spellchecker went without as much as a

[PATCH 0/5] introduce SWAP macro

2017-01-28 Thread René Scharfe
Exchanging the value of two variables requires declaring a temporary variable and repeating their names. The swap macro in apply.c simplifies this for its callers without changing the compiled binary. Polish this macro and export it, then use it throughout the code to reduce repetition and hide th

[PATCH 1/5] add SWAP macro

2017-01-28 Thread René Scharfe
Add a macro for exchanging the values of variables. It allows users to avoid repetition and takes care of the temporary variable for them. It also makes sure that the storage sizes of its two parameters are the same. Its memcpy(1) calls are optimized away by current compilers. Also add a conserv

[PATCH 2/5] apply: use SWAP macro

2017-01-28 Thread René Scharfe
Use the exported macro SWAP instead of the file-scoped macro swap and remove the latter's definition. Signed-off-by: Rene Scharfe --- apply.c | 23 +++ 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/apply.c b/apply.c index 2ed808d429..0e2caeab9c 100644 --- a/a

[PATCH 4/5] diff: use SWAP macro

2017-01-28 Thread René Scharfe
Use the macro SWAP to exchange the value of pairs of variables instead of swapping them manually with the help of a temporary variable. The resulting code is shorter and easier to read. The two cases were not transformed by the semantic patch swap.cocci because it's extra careful and handles only

[PATCH 3/5] use SWAP macro

2017-01-28 Thread René Scharfe
Apply the semantic patch swap.cocci to convert hand-rolled swaps to use the macro SWAP. The resulting code is shorter and easier to read, the object code is effectively unchanged. The patch for object.c had to be hand-edited in order to preserve the comment before the change; Coccinelle tried to

[PATCH 5/5] graph: use SWAP macro

2017-01-28 Thread René Scharfe
Exchange the values of graph->columns and graph->new_columns using the macro SWAP instead of hand-rolled code. The result is shorter and easier to read. This transformation was not done by the semantic patch swap.cocci because there's an unrelated statement between the second and the last step of

[PATCH] use oidcpy() for copying hashes between instances of struct object_id

2017-01-28 Thread René Scharfe
Patch generated by Coccinelle and contrib/coccinelle/object_id.cocci. Signed-off-by: Rene Scharfe --- refs/files-backend.c | 2 +- wt-status.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index f9023939d5..8ee2aba39

[PATCH] checkout: convert post_checkout_hook() to struct object_id

2017-01-28 Thread René Scharfe
Signed-off-by: Rene Scharfe --- builtin/checkout.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index bfe685c198..80d5e38981 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -56,8 +56,8 @@ static int post_checkout_hook(

[PATCH] use oid_to_hex_r() for converting struct object_id hashes to hex strings

2017-01-28 Thread René Scharfe
Patch generated by Coccinelle and contrib/coccinelle/object_id.cocci. Signed-off-by: Rene Scharfe --- builtin/blame.c | 4 ++-- builtin/merge-index.c | 2 +- builtin/rev-list.c| 2 +- diff.c| 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/b

[PATCH] receive-pack: call string_list_clear() unconditionally

2017-01-29 Thread René Scharfe
string_list_clear() handles empty lists just fine, so remove the redundant check. Signed-off-by: Rene Scharfe --- builtin/receive-pack.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 6b97cbdbe..1dbb8a069 100644 --- a/b

Re: [PATCH 1/5] add SWAP macro

2017-01-30 Thread René Scharfe
Am 30.01.2017 um 16:39 schrieb Johannes Schindelin: Hi René, On Sat, 28 Jan 2017, René Scharfe wrote: Add a macro for exchanging the values of variables. It allows users to avoid repetition and takes care of the temporary variable for them. It also makes sure that the storage sizes of its

Re: [PATCH 1/5] add SWAP macro

2017-01-30 Thread René Scharfe
Am 30.01.2017 um 17:01 schrieb Johannes Schindelin: Hi René, On Sat, 28 Jan 2017, René Scharfe wrote: diff --git a/git-compat-util.h b/git-compat-util.h index 87237b092b..66cd466eea 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -527,6 +527,16 @@ static inline int ends_with(const

Re: [PATCH 4/5] diff: use SWAP macro

2017-01-30 Thread René Scharfe
Am 30.01.2017 um 17:04 schrieb Johannes Schindelin: Hi René, On Sat, 28 Jan 2017, René Scharfe wrote: Use the macro SWAP to exchange the value of pairs of variables instead of swapping them manually with the help of a temporary variable. The resulting code is shorter and easier to read. The

Re: [PATCH 3/5] use SWAP macro

2017-01-30 Thread René Scharfe
Am 30.01.2017 um 17:03 schrieb Johannes Schindelin: Hi René, On Sat, 28 Jan 2017, René Scharfe wrote: diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c index 806dd7a885..8ce00480cd 100644 --- a/builtin/diff-tree.c +++ b/builtin/diff-tree.c @@ -147,9 +147,7 @@ int cmd_diff_tree(int argc

Re: [PATCH 5/5] graph: use SWAP macro

2017-01-30 Thread René Scharfe
Am 30.01.2017 um 17:16 schrieb Johannes Schindelin: Hi René, On Sat, 28 Jan 2017, René Scharfe wrote: Exchange the values of graph->columns and graph->new_columns using the macro SWAP instead of hand-rolled code. The result is shorter and easier to read. This transformation was not d

Re: [PATCH 1/5] add SWAP macro

2017-01-30 Thread René Scharfe
Am 30.01.2017 um 21:48 schrieb Johannes Schindelin: So I tried to verify that Visual C optimizes this well, and oh my deity, this was not easy. In Debug mode, it does not optimize, i.e. the memcpy() will be called, even for simple 32-bit integers. In Release mode, Visual Studio's defaults turn on

Re: [PATCH 1/5] add SWAP macro

2017-01-30 Thread René Scharfe
Am 30.01.2017 um 22:03 schrieb Johannes Schindelin: It is curious, though, that an expression like "sizeof(a++)" would not be rejected. Clang normally warns about something like this ("warning: expression with side effects has no effect in an unevaluated context [-Wunevaluated-expression]"),

Re: [PATCH 1/5] add SWAP macro

2017-01-31 Thread René Scharfe
Am 31.01.2017 um 13:13 schrieb Johannes Schindelin: Hi René, On Mon, 30 Jan 2017, René Scharfe wrote: Am 30.01.2017 um 21:48 schrieb Johannes Schindelin: The commit you quoted embarrasses me, and I have no excuse for it. I would love to see that myswap() ugliness fixed by replacing it with

Re: [PATCH 3/5] use SWAP macro

2017-01-31 Thread René Scharfe
Am 30.01.2017 um 23:22 schrieb Junio C Hamano: René Scharfe writes: if (tree2->flags & UNINTERESTING) { - struct object *tmp = tree2; - tree2 = tree1; - tree1 = tmp; + SWAP(tree2

Re: [PATCH 1/5] add SWAP macro

2017-01-31 Thread René Scharfe
Am 30.01.2017 um 23:21 schrieb Brandon Williams: On 01/30, René Scharfe wrote: Am 30.01.2017 um 22:03 schrieb Johannes Schindelin: It is curious, though, that an expression like "sizeof(a++)" would not be rejected. Clang normally warns about something like this ("warning:

Re: [PATCH 1/5] add SWAP macro

2017-02-01 Thread René Scharfe
Am 01.02.2017 um 12:47 schrieb Jeff King: I'm not altogether convinced that SWAP() is an improvement in readability. I really like that it's shorter than the code it replaces, but there is a danger with introducing opaque constructs. It's one more thing for somebody familiar with C but new to the

[PATCH] p5302: create repositories for index-pack results explicitly

2017-02-05 Thread René Scharfe
Before 7176a314 (index-pack: complain when --stdin is used outside of a repo) index-pack silently created a non-existing target directory; now the command refuses to work unless it's used against a valid repository. That causes p5302 to fail, which relies on the former behavior. Fix it by setting

[PATCH] dir: avoid allocation in fill_directory()

2017-02-07 Thread René Scharfe
Pass the match member of the first pathspec item directly to read_directory() instead of using common_prefix() to duplicate it first, thus avoiding memory duplication, strlen(3) and free(3). Signed-off-by: Rene Scharfe --- This updates 966de3028 (dir: convert fill_directory to use the pathspec st

Re: [PATCH 1/5] add SWAP macro

2017-02-07 Thread René Scharfe
Am 01.02.2017 um 19:33 schrieb Junio C Hamano: > René Scharfe writes: > >> Size checks could be added to SIMPLE_SWAP as well. > > Between SWAP() and SIMPLE_SWAP() I am undecided. > > If the compiler can infer the type and the size of the two > "locations&

Re: Trying to use xfuncname without success.

2017-02-07 Thread René Scharfe
Am 07.02.2017 um 20:21 schrieb Jack Adrian Zappa: I'm trying to setup a hunk header for .natvis files. For some reason, it doesn't seem to be working. I'm following their instructions from here, which doesn't say much in terms of restrictions of the regex, such as, is the matched item considered

Re: Trying to use xfuncname without success.

2017-02-08 Thread René Scharfe
Am 08.02.2017 um 18:11 schrieb Jack Adrian Zappa: > Thanks Rene, but you seem to have missed the point. NOTHING is > working. No matter what I put there, it doesn't seem to get matched. I'm not so sure about that. With your example I get this diff without setting diff.natvis.xfuncname: diff --

Re: Trying to use xfuncname without success.

2017-02-10 Thread René Scharfe
Am 09.02.2017 um 01:10 schrieb Jack Adrian Zappa: where it has grabbed a line at 126 and is using that for the hunk header. When I say that, I mean that it is using that line for *every* hunk header, for every change, regardless if it has passed a hunk head that it should have matched. Stran

Re: [PATCH] dir: avoid allocation in fill_directory()

2017-02-10 Thread René Scharfe
Am 08.02.2017 um 07:22 schrieb Duy Nguyen: On Wed, Feb 8, 2017 at 5:04 AM, René Scharfe wrote: Pass the match member of the first pathspec item directly to read_directory() instead of using common_prefix() to duplicate it first, thus avoiding memory duplication, strlen(3) and free(3). How

[PATCH 1/2] ls-files: pass prefix length explicitly to prune_cache()

2017-02-10 Thread René Scharfe
The function prune_cache() relies on the fact that it is only called on max_prefix and sneakily uses the matching global variable max_prefix_len directly. Tighten its interface by passing both the string and its length as parameters. While at it move the NULL check into the function to collect al

[PATCH 2/2] ls-files: move only kept cache entries in prune_cache()

2017-02-10 Thread René Scharfe
prune_cache() first identifies those entries at the start of the sorted array that can be discarded. Then it moves the rest of the entries up. Last it identifies the unwanted trailing entries among the moved ones and cuts them off. Change the order: Identify both start *and* end of the range to k

  1   2   3   4   5   6   7   8   9   10   >