[PATCH] contrib/coccinelle: fix semantic patch for oid_to_hex_r()

2016-09-15 Thread René Scharfe
Both sha1_to_hex_r() and oid_to_hex_r() take two parameters, so use two expressions in the semantic patch for transforming calls of the former to the latter one. Signed-off-by: Rene Scharfe --- contrib/coccinelle/object_id.cocci | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-)

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

2016-09-15 Thread René Scharfe
Replace uses of strbuf_addf() for adding strings with more lightweight strbuf_addstr() calls. This makes the intent clearer and avoids potential issues with printf format specifiers. 02962d36845b89145cd69f8bc65e015d78ae3434 already converted six cases, this patch covers eleven more. A semantic p

[PATCH] add coccicheck make target

2016-09-15 Thread René Scharfe
Provide a simple way to run Coccinelle against all source files, in the form of a Makefile target. Running "make coccicheck" applies each .cocci file in contrib/coccinelle/ on all source files. It generates a .patch file for each .cocci file, containing the actual changes for effecting the transf

Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf, part 2

2016-09-15 Thread René Scharfe
Am 15.09.2016 um 21:38 schrieb Jeff King: On Thu, Sep 15, 2016 at 12:25:43PM -0700, Junio C Hamano wrote: Silly question: Is there a natural language that uses percent signs as letters or e.g. instead of commas? :) I don't know, but if they do, they'd better get used to escaping them. :) I

Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf, part 2

2016-09-15 Thread René Scharfe
Am 15.09.2016 um 22:01 schrieb Junio C Hamano: > René Scharfe writes: > >> Take this for example: >> >> -strbuf_addf(&o->obuf, _("(bad commit)\n")); >> +strbuf_addstr(&o->obuf, _("(bad commit

Re: Two bugs in --pretty with %C(auto)

2016-09-17 Thread René Scharfe
Am 17.09.2016 um 14:51 schrieb Anatoly Borodin: > Hi All! > > First bug: > > git log -3 --pretty='%C(cyan)%C(auto)%h%C(auto)%d %s' > > prints %h with the default color (normal yellow), but > > git log -3 --pretty='%C(bold cyan)%C(auto)%h%C(auto)%d %s' > > shows %h with bold yellow,

Re: Two bugs in --pretty with %C(auto)

2016-09-18 Thread René Scharfe
Am 18.09.2016 um 14:30 schrieb Anatoly Borodin: On Sat, Sep 17, 2016 at 8:25 PM, René Scharfe wrote: I'm not sure how just how automatic %C(auto) is supposed to be, but you expected it do emit the reset for you, right? Sounds reasonable to me. I don't see a good reason not to do

[PATCH] introduce CHECKOUT_INIT

2016-09-22 Thread René Scharfe
Add a static initializer for struct checkout and use it throughout the code base. It's shorter, avoids a memset(3) call and makes sure the base_dir member is initialized to a valid (empty) string. Signed-off-by: Rene Scharfe --- apply.c | 4 +--- builtin/checkout-index.c | 2 +-

[PATCH] git-gui: stop using deprecated merge syntax

2016-09-24 Thread René Scharfe
Starting with v2.5.0 git merge can handle FETCH_HEAD internally and warns when it's called like 'git merge HEAD ' because that syntax is deprecated. Use this feature in git-gui and get rid of that warning. Signed-off-by: Rene Scharfe --- Tested only _very_ lightly! git-gui/lib/merge.tcl | 7 +

[PATCH 1/2] add COPY_ARRAY

2016-09-25 Thread René Scharfe
Add COPY_ARRAY, a safe and convenient helper for copying arrays, complementing ALLOC_ARRAY and REALLOC_ARRAY. Users just specify source, destination and the number of elements; the size of an element is inferred automatically. It checks if the multiplication of size and element count overflows. T

[PATCH 6/7] use COPY_ARRAY

2016-09-25 Thread René Scharfe
Add a semantic patch for converting certain calls of memcpy(3) to COPY_ARRAY() and apply that transformation to the code base. The result is shorter and safer code. For now only consider calls where source and destination have the same type, or in other words: easy cases. Signed-off-by: Rene Sc

Re: [PATCH 6/7] use COPY_ARRAY

2016-09-25 Thread René Scharfe
Ha, can't count. It should be [PATCH 2/2] of course. René

Re: [PATCH 1/2] add COPY_ARRAY

2016-09-25 Thread René Scharfe
Am 25.09.2016 um 09:41 schrieb Jeff King: On Sun, Sep 25, 2016 at 09:15:42AM +0200, René Scharfe wrote: It checks if the multiplication of size and element count overflows. The inferred size is passed first to st_mult, which allows the division there to be done at compilation time. I wonder

[PATCH] gitignore: ignore output files of coccicheck make target

2016-09-27 Thread René Scharfe
Signed-off-by: Rene Scharfe --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 05cb58a..f370ba0 100644 --- a/.gitignore +++ b/.gitignore @@ -207,6 +207,7 @@ /tags /TAGS /cscope* +/contrib/coccinelle/*.patch* *.obj *.lib *.res -- 2.10.0

[PATCH 1/2] use strbuf_addstr() instead of strbuf_addf() with "%s", part 2

2016-09-27 Thread René Scharfe
Replace uses of strbuf_addf() for adding strings with more lightweight strbuf_addstr() calls. This is shorter and makes the intent clearer. bc57b9c0cc5a123365a922fa1831177e3fd607ed already converted three cases, this patch covers two more. A semantic patch for Coccinelle is included for easier c

[PATCH 2/2] use strbuf_add_unique_abbrev() for adding short hashes, part 2

2016-09-27 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. 1eb47f167d65d1d305b9c196a1bb40eb96117cb1 already converted six cases, this patch covers three more. A seman

Re: [PATCH] gitignore: ignore output files of coccicheck make target

2016-09-27 Thread René Scharfe
Am 27.09.2016 um 21:52 schrieb Jakub Narębski: > W dniu 27.09.2016 o 21:01, René Scharfe pisze: >> Signed-off-by: Rene Scharfe >> --- >> .gitignore | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/.gitignore b/.gitignore >> index 05cb58a

Re: [PATCH 2/2] use strbuf_add_unique_abbrev() for adding short hashes, part 2

2016-09-27 Thread René Scharfe
Am 27.09.2016 um 22:28 schrieb Junio C Hamano: > René Scharfe writes: >> diff --git a/submodule.c b/submodule.c >> index dcc5ce3..8cf40ea 100644 >> --- a/submodule.c >> +++ b/submodule.c >> @@ -396,7 +396,7 @@ static void show_submodule_hea

[PATCH 2/3] use QSORT

2016-09-29 Thread René Scharfe
Apply the semantic patch contrib/coccinelle/qsort.cocci to the code base, replacing calls of qsort(3) with QSORT. The resulting code is shorter and supports empty arrays with NULL pointers. Signed-off-by: Rene Scharfe --- Freshly generated using coccicheck, compiles, survives make test. bisect

[PATCH 3/3] remove unnecessary check before QSORT

2016-09-29 Thread René Scharfe
Add a semantic patch for removing checks similar to the one that QSORT already does internally and apply it to the code base. Signed-off-by: Rene Scharfe --- builtin/fmt-merge-msg.c| 10 -- contrib/coccinelle/qsort.cocci | 18 ++ sh-i18n--envsubst.c|

[PATCH 1/3] add QSORT

2016-09-29 Thread René Scharfe
Add the macro QSORT, a convenient wrapper for qsort(3) that infers the size of the array elements and supports the convention of initializing empty arrays with a NULL pointer, which we use in some places. Calling qsort(3) directly with a NULL pointer is undefined -- even with an element count of z

Re: Two bugs in --pretty with %C(auto)

2016-09-29 Thread René Scharfe
Am 17.09.2016 um 20:25 schrieb René Scharfe: > diff --git a/pretty.c b/pretty.c > index 9788bd8..493edb0 100644 > --- a/pretty.c > +++ b/pretty.c > @@ -1072,6 +1072,8 @@ static size_t format_commit_one(struct strbuf *sb, /* > in UTF-8 */ > case 'C':

Re: [PATCH 1/3] add QSORT

2016-09-29 Thread René Scharfe
Am 30.09.2016 um 00:36 schrieb Junio C Hamano: > René Scharfe writes: > >> Add the macro QSORT, a convenient wrapper for qsort(3) that infers the >> size of the array elements and supports the convention of initializing >> empty arrays with a NULL pointer, whi

Re: [PATCH 1/3] add QSORT

2016-09-29 Thread René Scharfe
Am 30.09.2016 um 01:21 schrieb René Scharfe: > Am 30.09.2016 um 00:36 schrieb Junio C Hamano: >> René Scharfe writes: >> >>> Add the macro QSORT, a convenient wrapper for qsort(3) that infers the >>> size of the array elements and supports the convention of ini

Re: [PATCH 1/3] add QSORT

2016-10-01 Thread René Scharfe
Am 30.09.2016 um 00:36 schrieb Junio C Hamano: > 3. builtin/show-branch.c does this: > > qsort(ref_name + bottom, top - bottom, sizeof(ref_name[0]), > compare_ref_name); > > where ref_name[] is a file-scope global: > > static char *ref_name[MAX_REVS + 1]; > > and top and botto

Re: [PATCH 2/6] sha1_file: always allow relative paths to alternates

2016-10-02 Thread René Scharfe
Am 30.09.2016 um 21:36 schrieb Jeff King: > We adjust the test script here to demonstrate that this now > works. Unfortunately, we can't demonstrate that the > duplicate is suppressed, since it has no user-visible > behavior (it's just one less place for our object lookups to > go). But you can ver

Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf, part 2

2016-10-02 Thread René Scharfe
Am 15.09.2016 um 23:39 schrieb Junio C Hamano: > René Scharfe writes: > >> Am 15.09.2016 um 22:01 schrieb Junio C Hamano: >>> René Scharfe writes: >>> >>>> Take this for example: >>>> >>>> - strbuf_addf(&o

Re: [PATCH] git-gui: stop using deprecated merge syntax

2016-10-03 Thread René Scharfe
suggest: From c2716458f05893ca88c05ce211a295a330e74590 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Sat, 24 Sep 2016 13:30:22 +0200 Subject: [PATCH] git-gui: stop using deprecated merge syntax Starting with v2.5.0 git merge can handle FETCH_HEAD internally and warns when it's called

Re: [PATCH 1/3] add QSORT

2016-10-03 Thread René Scharfe
Am 03.10.2016 um 19:09 schrieb Kevin Bracey: As such, NULL checks can still be elided even with your change. If you effectively change your example to: if (nmemb > 1) qsort(array, nmemb, size, cmp); if (!array) printf("array is NULL\n"); array may only be checked for NUL

Re: [PATCH 1/3] add QSORT

2016-10-04 Thread René Scharfe
Am 04.10.2016 um 07:28 schrieb Kevin Bracey: On 04/10/2016 01:00, René Scharfe wrote: Am 03.10.2016 um 19:09 schrieb Kevin Bracey: As such, NULL checks can still be elided even with your change. If you effectively change your example to: if (nmemb > 1) qsort(array, nmemb, s

Re: git archive should use vendor extension in pax header

2016-01-26 Thread René Scharfe
Am 24.01.2016 um 16:59 schrieb f...@fuz.su: Right now, git archive creates a pax global header of the form comment=57ca140635bf157354124e4e4b3c8e1bde2832f1 in tar archives it creates. This is suboptimal as as comments are specified to be ignored by extraction software. It is impossible to

Re: git archive should use vendor extension in pax header

2016-02-06 Thread René Scharfe
Am 28.01.2016 um 00:45 schrieb f...@fuz.su: There is git get-tar-commit-id, which prints the commit ID if it finds a comment entry which looks like a hexadecimal SHA-1 hash. It's better than a hex editor at least. :) This is incredibly fuzzy and can get wrong for a pleothora of reasons. I hope

Re: git archive should use vendor extension in pax header

2016-02-15 Thread René Scharfe
Am 06.02.2016 um 15:57 schrieb f...@fuz.su: On Sat, Feb 06, 2016 at 02:23:11PM +0100, René Scharfe wrote: Am 28.01.2016 um 00:45 schrieb f...@fuz.su: There is git get-tar-commit-id, which prints the commit ID if it finds a comment entry which looks like a hexadecimal SHA-1 hash. It's b

Re: [PATCH 04/21] harden REALLOC_ARRAY and xcalloc against size_t overflow

2016-02-20 Thread René Scharfe
Am 19.02.2016 um 12:22 schrieb Jeff King: REALLOC_ARRAY inherently involves a multiplication which can overflow size_t, resulting in a much smaller buffer than we think we've allocated. We can easily harden it by using st_mult() to check for overflow. Likewise, we can add ALLOC_ARRAY to do the s

Re: [PATCH v3] merge: fix cache_entry use-after-free

2015-10-14 Thread René Scharfe
Am 15.10.2015 um 00:07 schrieb David Turner: From: Keith McGuigan During merges, we would previously free entries that we no longer need in the destination index. But those entries might also be stored in the dir_entry cache, and when a later call to add_to_index found them, they would be used

Re: [PATCH v3] merge: fix cache_entry use-after-free

2015-10-15 Thread René Scharfe
Am 15.10.2015 um 21:02 schrieb David Turner: On Thu, 2015-10-15 at 05:35 +0200, René Scharfe wrote: Am 15.10.2015 um 00:07 schrieb David Turner: From: Keith McGuigan During merges, we would previously free entries that we no longer need in the destination index. But those entries might also

[PATCH 1/2] run-command: factor out child_process_clear()

2015-10-24 Thread René Scharfe
Avoid duplication by moving the code to release allocated memory for arguments and environment to its own function, child_process_clear(). Export it to provide a counterpart to child_process_init(). Signed-off-by: Rene Scharfe --- Documentation/technical/api-run-command.txt | 7 +++ run-com

[PATCH 2/2] daemon: plug memory leak

2015-10-24 Thread René Scharfe
Call child_process_clear() when a child ends to release the memory allocated for its environment. This is necessary because unlike all other users of start_command() we don't call finish_command(), which would have taken care of that for us. This leak was introduced by f063d38b (daemon: use cld->

[PATCH] use pop_commit() for consuming the first entry of a struct commit_list

2015-10-24 Thread René Scharfe
Instead of open-coding the function pop_commit() just call it. This makes the intent clearer and reduces code size. Signed-off-by: Rene Scharfe --- builtin/fmt-merge-msg.c | 9 +++-- builtin/merge.c | 12 +--- builtin/reflog.c| 6 +- builtin/rev-parse.c |

Re: [PATCH 1/2] run-command: factor out child_process_clear()

2015-10-27 Thread René Scharfe
Am 26.10.2015 um 20:23 schrieb Stefan Beller: On Mon, Oct 26, 2015 at 11:43 AM, Junio C Hamano wrote: René Scharfe writes: Avoid duplication by moving the code to release allocated memory for arguments and environment to its own function, child_process_clear(). Export it to provide a

Re: [PATCH] use pop_commit() for consuming the first entry of a struct commit_list

2015-10-27 Thread René Scharfe
Am 26.10.2015 um 22:33 schrieb Junio C Hamano: René Scharfe writes: Instead of open-coding the function pop_commit() just call it. This makes the intent clearer and reduces code size. Signed-off-by: Rene Scharfe --- builtin/fmt-merge-msg.c | 9 +++-- builtin/merge.c | 12

[PATCH v2 0/3] daemon: plug memory leak

2015-10-31 Thread René Scharfe
Changes since v1: - Rebased on next, which already has a cleanup function. - Added first patch for renaming it. Rene Scharfe (3): run-command: name the cleanup function child_process_clear() run-command: export child_process_clear() daemon: plug memory leak Documentation/technical/api-run

[PATCH v2 1/3] run-command: name the cleanup function child_process_clear()

2015-10-31 Thread René Scharfe
Rename child_process_deinit() to child_process_clear() in order to stay consistent with similar cleanup functions like argv_array_clear(), string_list_clear() etc. Signed-off-by: Rene Scharfe --- run-command.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/run-c

[PATCH v2 2/3] run-command: export child_process_clear()

2015-10-31 Thread René Scharfe
Make the API symmetric by including a cleanup function as a counterpart to child_process_init(). Signed-off-by: Rene Scharfe --- Documentation/technical/api-run-command.txt | 7 +++ run-command.c | 2 +- run-command.h | 1 + 3 files

[PATCH v2 3/3] daemon: plug memory leak

2015-10-31 Thread René Scharfe
Call child_process_clear() when a child ends to release the memory allocated for its environment. This is necessary because unlike all other users of start_command() we don't call finish_command(), which would have taken care of that for us. This leak was introduced by f063d38b (daemon: use cld->

[PATCH 0/5] wt-status: fix an invalid memory read, clean up

2015-10-31 Thread René Scharfe
Memory is accessed out-of-bounds when try to show --branch info in a repo with a detached HEAD. Add a test in patch 1 and a fix in patch 3, as well as some cleanups. Rene Scharfe (5): t7060: add test for status --branch on a detached HEAD wt-status: exit early using goto in wt_shortstatus_pri

[PATCH 1/5] t7060: add test for status --branch on a detached HEAD

2015-10-31 Thread René Scharfe
This test fails when run under Valgrind because branch_get() gets passed a bogus branch name pointer: ==62831== Invalid read of size 1 ==62831==at 0x4F76AE: branch_get (remote.c:1650) ==62831==by 0x53499E: wt_shortstatus_print_tracking (wt-status.c:1654) ==62831==by 0x53499E: wt_shorts

[PATCH 2/5] wt-status: exit early using goto in wt_shortstatus_print_tracking()

2015-10-31 Thread René Scharfe
Deduplicate printing the line terminator by jumping to the end of the function. Signed-off-by: Rene Scharfe --- wt-status.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/wt-status.c b/wt-status.c index 3e3b8c0..083328f 100644 --- a/wt-status.c +++ b/wt-status.

[PATCH 3/5] wt-status: avoid building bogus branch name with detached HEAD

2015-10-31 Thread René Scharfe
If we're on a detached HEAD then wt_shortstatus_print_tracking() takes the string "HEAD (no branch)", translates it, skips the first eleven characters and passes the result to branch_get(), which returns a bogus result and accesses memory out of bounds in order to produce it. Somehow stat_tracking_

[PATCH 5/5] wt-status: use skip_prefix() to get rid of magic string length constants

2015-10-31 Thread René Scharfe
Signed-off-by: Rene Scharfe --- wt-status.c | 36 +++- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/wt-status.c b/wt-status.c index 42ea15e..435fc28 100644 --- a/wt-status.c +++ b/wt-status.c @@ -897,15 +897,15 @@ static void wt_status_print_verb

[PATCH 4/5] wt-status: don't skip a magical number of characters blindly

2015-10-31 Thread René Scharfe
Use the variable branch_name, which already has "refs/heads/" removed, instead of blindly advancing in the ->branch string by 11 bytes. This is safer and less magical. Signed-off-by: Rene Scharfe --- wt-status.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wt-status.c b/w

[PATCH] show-branch: use argv_array for default arguments

2015-10-31 Thread René Scharfe
Use argv_array instead of open-coding it. Signed-off-by: Rene Scharfe --- builtin/show-branch.c | 24 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index ac5141d..e17744b 100644 --- a/builtin/show-branch.c ++

Re: [PATCH 3/5] wt-status: avoid building bogus branch name with detached HEAD

2015-11-01 Thread René Scharfe
Am 01.11.2015 um 18:50 schrieb Junio C Hamano: René Scharfe writes: If we're on a detached HEAD then wt_shortstatus_print_tracking() takes the string "HEAD (no branch)", translates it, skips the first eleven characters and passes the result to branch_get(), which returns a b

[PATCH] wt-status: use strncmp() for length-limited string comparison

2015-11-06 Thread René Scharfe
When a branch name is longer than four characters, memcmp() can read past the end of the string literal "HEAD". Use strncmp() instead, which stops at the end of a string. This fixes the following test failures with AddressSanitizer: t3203-branch-output.sh (Wstat: 256 Te

[PATCH 0/5] parse-options: allow -h as a short option

2015-11-17 Thread René Scharfe
The short option -h is hard-wired in parseopt to list the options of a command together with a short explanation. If -h is to be given a different meaning then the flag PARSE_OPT_NO_INTERNAL_HELP has to be specified, which turns off handling for -h, --help and --help-all (except that --help handli

[PATCH 1/5] parse-options: deduplicate parse_options_usage() calls

2015-11-17 Thread René Scharfe
Avoid long lines and repeating parse_options_usage() calls with their duplicate parameters by providing labels with speaking names to jump to. Signed-off-by: Rene Scharfe --- parse-options.c | 18 -- 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/parse-options.c b

[PATCH 3/5] parse-options: allow -h as a short option

2015-11-17 Thread René Scharfe
Let callers provide their own handler for the short option -h even without the flag PARSE_OPT_NO_INTERNAL_HELP, but call the internal handler (showing usage information) if that is the only parameter. Implement the first part by checking for -h only if parse_short_opt() can't find it and returns -2

[PATCH 4/5] grep: stop using PARSE_OPT_NO_INTERNAL_HELP

2015-11-17 Thread René Scharfe
The flag PARSE_OPT_NO_INTERNAL_HELP is set to allow overriding the option -h, except when it's the only one given. This is the default behavior now, so remove the flag and the hand-rolled --help-all handling. The internal --help-all handler now actually shows hidden options, i.e. --debug in this

[PATCH 2/5] parse-options: inline parse_options_usage() at its only remaining caller

2015-11-17 Thread René Scharfe
Signed-off-by: Rene Scharfe --- parse-options.c | 13 + 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/parse-options.c b/parse-options.c index f0b6d9b..4863966 100644 --- a/parse-options.c +++ b/parse-options.c @@ -5,10 +5,6 @@ #include "color.h" #include "utf8.h" -

[PATCH 5/5] show-ref: stop using PARSE_OPT_NO_INTERNAL_HELP

2015-11-17 Thread René Scharfe
The flag PARSE_OPT_NO_INTERNAL_HELP is set to allow overriding the option -h, except when it's the only one given. This is the default behavior now, so remove the flag and the hand-rolled --help-all handling. The internal --help-all handler now actually shows hidden options, i.e. -h in this case.

[PATCH 1/2] t1450: add tests for NUL in headers of commits and tags

2015-11-19 Thread René Scharfe
Signed-off-by: Rene Scharfe --- t/t1450-fsck.sh | 32 1 file changed, 32 insertions(+) diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index dc09797..6c96953 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -176,6 +176,18 @@ test_expect_success 'integer overf

[PATCH 2/2] fsck: treat a NUL in a tag header as an error

2015-11-19 Thread René Scharfe
We check the return value of verify_header() for commits already, so do the same for tags as well. Signed-off-by: Rene Scharfe --- fsck.c | 3 ++- t/t1450-fsck.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fsck.c b/fsck.c index e41e753..4060f1f 100644 --- a/f

Re: [PATCH 1/2] t1450: add tests for NUL in headers of commits and tags

2015-11-19 Thread René Scharfe
Am 19.11.2015 um 21:33 schrieb Eric Sunshine: On Thu, Nov 19, 2015 at 11:20 AM, René Scharfe wrote: Signed-off-by: Rene Scharfe --- diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh @@ -176,6 +176,18 @@ test_expect_success 'integer overflow in timestamps is reported' ' +test

[PATCH 4/2] test: use test_must_contain

2015-11-20 Thread René Scharfe
Some tests print a file using cat and then grep it for some pattern. This is done to aid debugging in case the pattern is unexpectedly not found; the file contents can easily inspected by running the test with the option --verbose. Replace these combinations by calls of test_must_contain. It only

Re: [PATCH 1/2] t1450: add tests for NUL in headers of commits and tags

2015-11-20 Thread René Scharfe
Am 20.11.2015 um 12:14 schrieb Jeff King: On Thu, Nov 19, 2015 at 09:54:54PM +0100, René Scharfe wrote: diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh @@ -176,6 +176,18 @@ test_expect_success 'integer overflow in timestamps is reported' ' +test_expect_success 'commi

[PATCH 3/2] test: factor out helper function test_must_contain

2015-11-20 Thread René Scharfe
Extract a helper function for searching for a pattern in a file and printing the whole file if the pattern is not found. It is useful when starting tests with --verbose for debugging purposes. Signed-off-by: Rene Scharfe --- t/t0008-ignores.sh | 10 +- t/test-lib-functions.sh | 12

Re: [PATCH 4/2] test: use test_must_contain

2015-11-20 Thread René Scharfe
Am 21.11.2015 um 02:16 schrieb SZEDER Gábor: Hi, diff --git a/t/t9810-git-p4-rcs.sh b/t/t9810-git-p4-rcs.sh index 8134ab4..e02b490 100755 --- a/t/t9810-git-p4-rcs.sh +++ b/t/t9810-git-p4-rcs.sh @@ -294,8 +294,7 @@ test_expect_success 'cope with rcs keyword file deletion' ' echo

Re: [PATCH 3/2] test: factor out helper function test_must_contain

2015-11-21 Thread René Scharfe
Am 21.11.2015 um 09:11 schrieb Johannes Sixt: > Am 20.11.2015 um 21:50 schrieb René Scharfe: >> Extract a helper function for searching for a pattern in a file and >> printing the whole file if the pattern is not found. It is useful >> when starting tests with --verbose f

Re: [PATCH] wt-status: use strncmp() for length-limited string comparison

2015-11-24 Thread René Scharfe
Am 24.11.2015 um 22:36 schrieb Jeff King: > On Fri, Nov 06, 2015 at 11:47:03PM +0100, René Scharfe wrote: > >> When a branch name is longer than four characters, memcmp() can read >> past the end of the string literal "HEAD". Use strncmp() instead, which >> s

[PATCH v2] wt-status: correct and simplify check for detached HEAD

2015-11-25 Thread René Scharfe
If a branch name is longer than four characters then memcmp() reads over the end of the static string "HEAD". This causes the following test failures with AddressSanitizer: t3203-branch-output.sh (Wstat: 256 Tests: 18 Failed: 4) Failed tests: 12, 15-17 Non-zero exi

jk/loose-object-cache

2019-01-06 Thread René Scharfe
Am 28.12.2018 um 19:04 schrieb Junio C Hamano: > * jk/loose-object-cache (2018-11-24) 10 commits > (merged to 'next' on 2018-12-28 at 5a5faf384e) > + odb_load_loose_cache: fix strbuf leak > + fetch-pack: drop custom loose object cache > + sha1-file: use loose object cache for quick existence c

[PATCH 1/3] object-store: factor out odb_loose_cache()

2019-01-06 Thread René Scharfe
Add and use a function for loading the entries if a loose object subdirectory for a given object ID. It frees callers from deriving the fanout key; they can use the returned oid_array reference for lookups or forward range scans. Suggested-by: Jeff King Signed-off-by: Rene Scharfe --- object-s

[PATCH 2/3] object-store: factor out odb_clear_loose_cache()

2019-01-06 Thread René Scharfe
Add and use a function for emptying the loose object cache, so callers don't have to know any of its implementation details. Signed-off-by: Rene Scharfe --- object-store.h | 3 +++ object.c | 2 +- packfile.c | 7 ++- sha1-file.c| 7 +++ 4 files changed, 13 insertions(+), 6

[PATCH 3/3] object-store: use one oid_array per subdirectory for loose cache

2019-01-06 Thread René Scharfe
The loose objects cache is filled one subdirectory at a time as needed. It is stored in an oid_array, which has to be resorted after each add operation. So when querying a wide range of objects, the partially filled array needs to be resorted up to 255 times, which takes over 100 times longer than

Re: [PATCH 3/3] object-store: use one oid_array per subdirectory for loose cache

2019-01-06 Thread René Scharfe
Am 06.01.2019 um 21:38 schrieb Ævar Arnfjörð Bjarmason: >> $ git count-objects >> 26733 objects, 68808 kilobytes >> >> TestHEAD^ HEAD >> >> 4205.1: log with %H 0.51(0.47+0.04) 0.51(0.4

Re: [PATCH 1/3] object-store: factor out odb_loose_cache()

2019-01-07 Thread René Scharfe
Am 07.01.2019 um 13:30 schrieb Jeff King: > On Mon, Jan 07, 2019 at 11:27:06AM +, Philip Oakley wrote: > >> On 06/01/2019 16:45, René Scharfe wrote: >>> Add and use a function for loading the entries if a loose object >>> subdirectory for a given object ID

Re: [PATCH 1/3] object-store: factor out odb_loose_cache()

2019-01-07 Thread René Scharfe
Am 07.01.2019 um 09:27 schrieb Jeff King: > On Sun, Jan 06, 2019 at 05:45:30PM +0100, René Scharfe wrote: >> diff --git a/object-store.h b/object-store.h >> index 60758efad8..7236c571c0 100644 >> --- a/object-store.h >> +++ b/object-store.h >> @@ -54,6 +54,13 @@ vo

[PATCH] sha1-file: close fd of empty file in map_sha1_file_1()

2019-01-07 Thread René Scharfe
map_sha1_file_1() checks if the file it is about to mmap() is empty and errors out in that case and explains the situation in an error message. It leaks the private handle to that empty file, though. Have the function clean up after itself and close the file descriptor before exiting early. Signe

[PATCH 4/3] object-store: retire odb_load_loose_cache()

2019-01-07 Thread René Scharfe
Inline odb_load_loose_cache() into its only remaining caller, odb_loose_cache(). The latter offers a nicer interface for loading the cache, as it doesn't require callers to deal with fanout directory numbers directly. Signed-off-by: Rene Scharfe --- object-store.h | 7 --- sha1-file.c|

Re: [PATCH 1/3] object-store: factor out odb_loose_cache()

2019-01-07 Thread René Scharfe
Am 07.01.2019 um 14:26 schrieb René Scharfe: > Yes, the functions are arranged so that odb_load_loose_cache() can be > inlined easily. I meant to include a patch for that but then quibbled > about keeping the BUG check (which is probably optimized out) or not, > and dropped it for no

Re: [PATCH 0/11] jk/loose-object-cache sha1/object_id fixups

2019-01-08 Thread René Scharfe
Am 07.01.2019 um 09:31 schrieb Jeff King: > I also cleaned up my sha1/object_id patch and rebased it on top of what > you have here. Though as I worked on it, it expanded in scope a bit. > Possibly it should be a separate series entirely, but that would create > some annoying textual conflicts on m

Re: null pointer dereference in refs/file-backend

2019-01-16 Thread René Scharfe
Am 16.01.2019 um 10:18 schrieb Carlo Arenas: > while running HEAD cppcheck against git HEAD got the following error, > that seem to be in the code all the way to maint: > > [refs/files-backend.c:2681] -> [refs.c:1044] -> [cache.h:1075]: > (error) Null pointer dereference: src > > the code that uses

Re: [PATCH v2 2/3] blame: add the ability to ignore commits and their changes

2019-01-20 Thread René Scharfe
Am 17.01.2019 um 21:29 schrieb Barret Rhoden: > The blame_entry will get passed up the tree until we find a commit that > has a diff chunk that affects those lines. If an ignored commit added > more lines than it removed, the blame will fall on a commit that made a > change nearby. There is no ge

Re: [PATCH 04/12] packfile: check midx coverage with .idx rather than .pack

2019-04-05 Thread René Scharfe
Am 05.04.2019 um 01:25 schrieb Jeff King: > When we have a .midx that covers many packfiles, we try to avoid opening > the .idx for those packfiles. However, there are a few problems with the > filename comparison we use: > >- we ask midx_contains_pack() about the .pack name, not the .idx name.

Re: [PATCH 05/12] http: simplify parsing of remote objects/info/packs

2019-04-05 Thread René Scharfe
Am 05.04.2019 um 01:27 schrieb Jeff King: > We can use skip_prefix() and parse_oid_hex() to continuously increment > our pointer, rather than dealing with magic numbers. This also fixes a > few small shortcomings: > > - if we see a 'P' line that does not match our expectations, we'll > leave

Re: [PATCH 05/12] http: simplify parsing of remote objects/info/packs

2019-04-05 Thread René Scharfe
Am 05.04.2019 um 20:11 schrieb Jeff King: > On Fri, Apr 05, 2019 at 12:41:27PM +0200, René Scharfe wrote: >> Parsing "P" and "pack-" together crosses logical token boundaries, >> but that I don't mind it here. > > Yeah, I was tempted to

Re: [PATCH v2 05/13] midx: check both pack and index names for containment

2019-04-05 Thread René Scharfe
s does fix _a_ bug, it's masked > by another bug in that same caller. That will be covered (with a test) > in the next patch. > > Helped-by: René Scharfe > Signed-off-by: Jeff King > --- > I was tempted to suggest that the midx struct just store the base name > withou

Re: [PATCH 2/2] archive: avoid spawning `gzip`

2019-04-13 Thread René Scharfe
Am 13.04.2019 um 03:51 schrieb Jeff King: > On Fri, Apr 12, 2019 at 04:04:40PM -0700, Rohit Ashiwal via GitGitGadget > wrote: > >> From: Rohit Ashiwal >> >> As we already link to the zlib library, we can perform the compression >> without even requiring gzip on the host machine. > > Very cool. It

Re: [PATCH 2/2] archive: avoid spawning `gzip`

2019-04-27 Thread René Scharfe
Am 26.04.19 um 16:51 schrieb Johannes Schindelin:> Hi Peff, > > On Mon, 15 Apr 2019, Jeff King wrote: > >> On Sun, Apr 14, 2019 at 12:01:10AM +0200, René Scharfe wrote: >> >>>>> As we already link to the zlib library, we can perform the compression >&g

Re: [PATCH 2/2] archive: avoid spawning `gzip`

2019-04-27 Thread René Scharfe
Am 27.04.19 um 11:59 schrieb René Scharfe:> Am 26.04.19 um 16:51 schrieb Johannes Schindelin: >> >> On Mon, 15 Apr 2019, Jeff King wrote: >> >>> On Sun, Apr 14, 2019 at 12:01:10AM +0200, René Scharfe wrote: >>> >>>> Doing compression in its ow

Re: [PATCH 2/2] archive: avoid spawning `gzip`

2019-05-01 Thread René Scharfe
Hello Dscho, Am 29.04.19 um 23:25 schrieb Johannes Schindelin: > On Sat, 27 Apr 2019, René Scharfe wrote: >> The simplest solution is of course to not touch the archive code. > > We could do that, of course, and we could avoid adding a new command that > we have to suppo

Re: [PATCH 1/2] archive: replace write_or_die() calls with write_block_or_die()

2019-05-02 Thread René Scharfe
Am 01.05.19 um 20:09 schrieb Jeff King: > On Mon, Apr 29, 2019 at 05:32:50PM -0400, Johannes Schindelin wrote: > >>> Another is that I am not sure how your "fixed format" argument >>> meshes with the "-b blocksize" parameter to affect the tar/pax >>> output. The format may be fixed, but it is para

Re: [PATCH v2 3/4] archive: optionally use zlib directly for gzip compression

2019-05-02 Thread René Scharfe
Am 27.04.19 um 01:27 schrieb Rohit Ashiwal via GitGitGadget: > From: Rohit Ashiwal > > As we already link to the zlib library, we can perform the compression > without even requiring gzip on the host machine. > > Note: the `-n` flag that `git archive` passed to `gzip` wants to ensure > that a repr

Re: [PATCH v2 2/4] archive-tar: mark RECORDSIZE/BLOCKSIZE as unsigned

2019-05-02 Thread René Scharfe
Am 27.04.19 um 01:27 schrieb Johannes Schindelin via GitGitGadget: > From: Johannes Schindelin > > They really are unsigned, and we are using e.g. BLOCKSIZE as `size_t` > parameter to pass to `write_or_die()`. True, but the compiler converts that value correctly to size_t without complaint alread

Re: [PATCH v2 2/4] archive-tar: mark RECORDSIZE/BLOCKSIZE as unsigned

2019-05-10 Thread René Scharfe
Am 09.05.19 um 20:38 schrieb Jeff King: > I do dream of a world where we do not have a bunch of implicit > conversions (both signedness but also truncation) in our code base, and > can compile cleanly with -Wconversion We know that this case is > perfectly fine, but I am sure there are many that ar

Re: [PATCH 1/3] transport_anonymize_url(): support retaining username

2019-05-20 Thread René Scharfe
Am 19.05.19 um 07:10 schrieb Jeff King: > diff --git a/transport.c b/transport.c > index f1fcd2c4b0..ba61e57295 100644 > --- a/transport.c > +++ b/transport.c > @@ -1373,7 +1372,15 @@ char *transport_anonymize_url(const char *url) > cp = strchr(scheme_prefix + 3, '/'); >

Re: git archive generates tar with malformed pax extended attribute

2019-05-25 Thread René Scharfe
Am 24.05.19 um 10:13 schrieb Jeff King: > On Fri, May 24, 2019 at 09:35:51AM +0200, Keegan Carruthers-Smith wrote: > >>> I can't reproduce on Linux, using GNU tar (1.30) nor with bsdtar 3.3.3 >>> (from Debian's bsdtar package). What does your "tar --version" say? >> >> bsdtar 2.8.3 - libarchive 2.8

Re: git archive generates tar with malformed pax extended attribute

2019-05-26 Thread René Scharfe
Am 25.05.19 um 23:07 schrieb Ævar Arnfjörð Bjarmason: > > On Sat, May 25 2019, René Scharfe wrote: > >> We could truncate symlink targets at the first NUL as well in git >> archive -- but that would be a bit sad, as the archive formats allow >> storing the "real&quo

Re: git archive generates tar with malformed pax extended attribute

2019-05-28 Thread René Scharfe
Am 28.05.19 um 07:58 schrieb Jeff King: > On Sat, May 25, 2019 at 03:26:53PM +0200, René Scharfe wrote: > >> We could >> make git fsck report such symlinks. > > This is a little tricky, because fsck generally looks at individual > objects, and the bad pattern is a combi

Re: git archive generates tar with malformed pax extended attribute

2019-05-28 Thread René Scharfe
Am 28.05.19 um 21:08 schrieb Jeff King: > On Tue, May 28, 2019 at 08:01:43PM +0200, René Scharfe wrote: > >> Am 28.05.19 um 07:58 schrieb Jeff King: >>> On Sat, May 25, 2019 at 03:26:53PM +0200, René Scharfe wrote: >>> >>>> We could >>>> make g

<    1   2   3   4   5   6   7   8   9   10   >