Re: [PATCH v6 1/3] read-cache: add strcmp_offset function

2017-04-06 Thread René Scharfe
Am 06.04.2017 um 18:34 schrieb g...@jeffhostetler.com: diff --git a/read-cache.c b/read-cache.c index 9054369..e8f1900 100644 --- a/read-cache.c +++ b/read-cache.c @@ -887,6 +887,26 @@ static int has_file_name(struct index_state *istate, return retval; } + +/* + * Like strcmp(), but

[PATCH] test-read-cache: setup git dir

2017-04-06 Thread René Scharfe
b1ef400e (setup_git_env: avoid blind fall-back to ".git") made programs that tried to access a repository without initializing properly die with a diagnostic message. One offender is test-read-cache, which is used in p0002. Fix it by calling setup_git_directory() before accessing the index. Sign

Re: [PATCH v5 3/4] test-strcmp-offset: created test for strcmp_offset

2017-04-06 Thread René Scharfe
Am 05.04.2017 um 19:38 schrieb g...@jeffhostetler.com: diff --git a/t/helper/test-strcmp-offset.c b/t/helper/test-strcmp-offset.c new file mode 100644 index 000..fe01318 --- /dev/null +++ b/t/helper/test-strcmp-offset.c @@ -0,0 +1,64 @@ +#include "cache.h" + +struct test_data { + const

Re: [PATCH v5 1/4] p0004-read-tree: perf test to time read-tree

2017-04-06 Thread René Scharfe
Am 05.04.2017 um 19:38 schrieb g...@jeffhostetler.com: > From: Jeff Hostetler > > Signed-off-by: Jeff Hostetler > --- > t/perf/p0004-read-tree.sh | 116 > ++ > 1 file changed, 116 insertions(+) > create mode 100755 t/perf/p0004-read-tree.sh > > dif

Re: [PATCH v3 1/2] Fix nonnull errors reported by UBSAN with GCC 7.

2017-04-06 Thread René Scharfe
Am 06.04.2017 um 18:33 schrieb Johannes Sixt: Am 06.04.2017 um 17:42 schrieb Martin Liška: +static inline void *sane_memmove(void *dest, const void *src, size_t n) +{ +if (n > 0) +return memmove(dest, src, n); +else +return dest; +} Huh? memmove with n == 0 is well-defi

Re: [PATCH v2 1/2] Fix nonnull errors reported by UBSAN with GCC 7.

2017-04-06 Thread René Scharfe
Am 06.04.2017 um 11:52 schrieb Martin Liška: > I'm sending (v2), where I updated commit message and wrapped 2 problematic > places to newly introduced macros that do the check. Follow-up patch can > change usages of memcpy and memove. > diff --git a/apply.c b/apply.c > index e6dbab26a..eacca29fa 1

Re: [PATCH] strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD

2017-03-30 Thread René Scharfe
Am 29.03.2017 um 06:54 schrieb Christian Couder: On Tue, Mar 28, 2017 at 11:49 PM, Jeff King wrote: On Tue, Mar 28, 2017 at 11:15:12PM +0200, Christian Couder wrote: On Sun, Mar 26, 2017 at 3:43 PM, René Scharfe wrote: FreeBSD implements getcwd(3) as a syscall, but falls back to a version

[PATCH] strbuf: support long paths w/o read rights in strbuf_getcwd() on FreeBSD

2017-03-26 Thread René Scharfe
FreeBSD implements getcwd(3) as a syscall, but falls back to a version based on readdir(3) if it fails for some reason. The latter requires permissions to read and execute path components, while the former does not. That means that if our buffer is too small and we're missing rights we could get

Re: [PATCH] pretty: add extra headers and MIME boundary directly

2017-03-26 Thread René Scharfe
Am 25.03.2017 um 22:11 schrieb Jeff King: > The most correct way is that the caller of log_write_email_headers() and > diff_flush() should have a function-local strbuf which holds the data, > gets passed to diff_flush() as some kind opaque context, and then is > freed afterwards. We don't have such

Re: [PATCH] pretty: add extra headers and MIME boundary directly

2017-03-25 Thread René Scharfe
Am 25.03.2017 um 17:17 schrieb Jeff King: On Sat, Mar 25, 2017 at 01:16:42PM +0100, René Scharfe wrote: @@ -374,26 +372,9 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit, graph_show_oneline(opt->graph); } if (opt->mime_bo

[PATCH] pretty: add extra headers and MIME boundary directly

2017-03-25 Thread René Scharfe
Use the after_subject member of struct pretty_print_context to pass the extra_headers unchanged, and construct and add the MIME boundary headers directly in pretty.c::pp_title_line() instead of writing both to a static buffer in log-tree.c::log_write_email_headers() first. That's easier, quicker a

Re: [PATCH] refs.c: use skip_prefix() in prettify_refname()

2017-03-23 Thread René Scharfe
Am 23.03.2017 um 20:39 schrieb Jeff King: On Thu, Mar 23, 2017 at 12:33:06PM -0700, Junio C Hamano wrote: Nice, but why add the "if" when it's doing nothing? It's short-circuiting in the conditional. I think René meant this: /* just for side effects */ skip_prefix(name, "refs/hea

Re: [PATCH] refs.c: use skip_prefix() in prettify_refname()

2017-03-23 Thread René Scharfe
Am 23.03.2017 um 20:33 schrieb Junio C Hamano: Jeff King writes: On Thu, Mar 23, 2017 at 08:18:26PM +0100, René Scharfe wrote: Am 23.03.2017 um 16:50 schrieb SZEDER Gábor: This eliminates three magic numbers. Signed-off-by: SZEDER Gábor --- refs.c | 10 +- 1 file changed, 5

Re: Question: libxdiff: text-patches: internal format

2017-03-23 Thread René Scharfe
Am 23.03.2017 um 19:00 schrieb matt...@giassa.net: Hi there, Following up on an earlier question of mine from yesterday, is there any formal documentation (save for source diving) on the internal format used by libxdiff/xdiff when it generates a patch by comparing two plaintext files? I'd like

Re: [PATCH] refs.c: use skip_prefix() in prettify_refname()

2017-03-23 Thread René Scharfe
Am 23.03.2017 um 16:50 schrieb SZEDER Gábor: This eliminates three magic numbers. Signed-off-by: SZEDER Gábor --- refs.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/refs.c b/refs.c index e7606716d..0272e332c 100644 --- a/refs.c +++ b/refs.c @@ -366,11 +366,11

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-21 Thread René Scharfe
Am 21.03.2017 um 14:29 schrieb Zenobiusz Kunegunda: I think I found a way to reproduce this error. I installed FreeBSD 10.3 under qemu with zfs partitioning. Test program did not report any access errors. Then I did chmod 711 /usr/home Now program started reporting permission denied errors just l

[PATCH] http-push: don't check return value of lookup_unknown_object()

2017-03-17 Thread René Scharfe
This function always returns a reference to an object, creating one if needed, so remove the unnecessary NULL check. Signed-off-by: Rene Scharfe --- http-push.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/http-push.c b/http-push.c index 704b1c837c..f0e3108f71 1006

[PATCH] shortlog: don't set after_subject to an empty string

2017-03-17 Thread René Scharfe
The string after_subject is added to a strbuf by pp_title_line() if it's not NULL. Adding an empty string has the same effect as not adding anything, but the latter is easier, so don't bother changing the context member from NULL to "". Signed-off-by: Rene Scharfe --- builtin/shortlog.c | 1 -

Re: [PATCH] receive-pack: simplify run_update_post_hook()

2017-03-17 Thread René Scharfe
Am 17.03.2017 um 23:23 schrieb Jeff King: On Fri, Mar 17, 2017 at 11:02:13PM +0100, René Scharfe wrote: Instead of counting the arguments to see if there are any and then building the full command use a single loop and add the hook command just before the first argument. This reduces

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-17 Thread René Scharfe
Am 17.03.2017 um 23:29 schrieb Jeff King: On Fri, Mar 17, 2017 at 10:07:18PM +0100, René Scharfe wrote: As an extension to the POSIX.1-2001 standard, Linux (libc4, libc5, glibc) getcwd() allocates the buffer dynamically using malloc(3) if buf is NULL. In this case, the allocated buffer

[PATCH] revision: remove declaration of path_name()

2017-03-17 Thread René Scharfe
The definition of path_name() was removed by 2824e1841 (list-objects: pass full pathname to callbacks); remove its declaration as well. Signed-off-by: Rene Scharfe --- revision.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/revision.h b/revision.h index 9fac1a607d..14886ec92b 100644 ---

[PATCH] receive-pack: simplify run_update_post_hook()

2017-03-17 Thread René Scharfe
Instead of counting the arguments to see if there are any and then building the full command use a single loop and add the hook command just before the first argument. This reduces duplication and overall code size. Signed-off-by: Rene Scharfe --- builtin/receive-pack.c | 13 + 1 fi

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-17 Thread René Scharfe
Am 17.03.2017 um 20:45 schrieb Stefan Beller: On Fri, Mar 17, 2017 at 12:34 PM, René Scharfe wrote: Am 15.03.2017 um 22:30 schrieb René Scharfe: Am 15.03.2017 um 10:44 schrieb Zenobiusz Kunegunda: $ git bisect bad 7333ed1788b4f2b162a35003044d77a716732a1f is the first bad commit commit

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-17 Thread René Scharfe
Am 15.03.2017 um 22:30 schrieb René Scharfe: > Am 15.03.2017 um 10:44 schrieb Zenobiusz Kunegunda: >> $ git bisect bad >> 7333ed1788b4f2b162a35003044d77a716732a1f is the first bad commit >> commit 7333ed1788b4f2b162a35003044d77a716732a1f >> Author: René Scharfe >>

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-15 Thread René Scharfe
Am 15.03.2017 um 10:44 schrieb Zenobiusz Kunegunda: $ git bisect bad 7333ed1788b4f2b162a35003044d77a716732a1f is the first bad commit commit 7333ed1788b4f2b162a35003044d77a716732a1f Author: René Scharfe Date: Mon Jul 28 20:26:40 2014 +0200 setup: convert setup_git_directory_gently_1 et

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-14 Thread René Scharfe
Am 14.03.2017 um 08:44 schrieb Zenobiusz Kunegunda: Od: "René Scharfe" <l@web.de> Do: "Zenobiusz Kunegunda" <zenobiusz.kunegu...@interia.pl>; Wysłane: 22:31 Poniedziałek 2017-03-13 Temat: Re: fatal: Could not get current working directory: Permission denied |

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-13 Thread René Scharfe
Am 13.03.2017 um 14:23 schrieb Zenobiusz Kunegunda: Bisecting: 0 revisions left to test after this (roughly 0 steps) [a26bc613a64ac2c7ee69a50675e61b004a26382d] pretty.c: make git_pretty_formats_config return -1 on git_config_string failure This is what I found with git bisect Strange, I don't

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-13 Thread René Scharfe
Am 13.03.2017 um 13:23 schrieb Zenobiusz Kunegunda: > Tested on ZFS filesystem > > > > [test0@s0]:<~>$ mkdir > '23222' > [test0@s0]:<~>$ cd > 2322

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-11 Thread René Scharfe
Am 09.03.2017 um 12:01 schrieb Zenobiusz Kunegunda: OK, I printed euids inside function calling getcwd(). Every single EUID is the same and have expected value. The same as any other local application run by this user. Permissions of every directory in the path are OK. /bin/pwd -P inside directo

Re: [PATCH v1] Travis: also test on 32-bit Linux

2017-03-11 Thread René Scharfe
Am 11.03.2017 um 00:33 schrieb Junio C Hamano: > René Scharfe writes: > >> @ depends on r @ >> expression E; >> @@ >> - *& >>E > > I guess my source of the confusion is that the tool that understands > the semantics of

Re: [PATCH v1] Travis: also test on 32-bit Linux

2017-03-10 Thread René Scharfe
Am 10.03.2017 um 21:13 schrieb Junio C Hamano: René Scharfe writes: I think this misses the other two cases: (*dst, src) and (*dst, *src). ... and that's why I left them out. You can't get dst vs. *dst wrong with structs (at least not without the compiler complaining);

Re: [PATCH v1] Travis: also test on 32-bit Linux

2017-03-10 Thread René Scharfe
Am 10.03.2017 um 18:57 schrieb Jeff King: On Fri, Mar 10, 2017 at 05:20:13PM +0100, René Scharfe wrote: I think this misses the other two cases: (*dst, src) and (*dst, *src). ... and that's why I left them out. You can't get dst vs. *dst wrong with structs (at least not without th

Re: [PATCH] Makefile: detect errors in running spatch

2017-03-10 Thread René Scharfe
Am 10.03.2017 um 09:31 schrieb Jeff King: The "make coccicheck" target runs spatch against each source file. But it does so in a for loop, so "make" never sees the exit code of spatch. Worse, it redirects stderr to a log file, so the user has no indication of any failure. And then to top it all o

Re: [PATCH v1] Travis: also test on 32-bit Linux

2017-03-10 Thread René Scharfe
Am 10.03.2017 um 09:18 schrieb Jeff King: On Fri, Mar 10, 2017 at 01:14:16AM +0100, René Scharfe wrote: 2. Ones which just copy a single object, like: memcpy(&dst, &src, sizeof(dst)); Perhaps we should be using struct assignment like: dst = src; here. It

Re: [PATCH] blame: move blame_entry duplication to add_blame_entry()

2017-03-10 Thread René Scharfe
Am 10.03.2017 um 09:32 schrieb Jeff King: On Fri, Mar 10, 2017 at 01:12:59AM +0100, René Scharfe wrote: All callers of add_blame_entry() allocate and copy the second argument. Let the function do it for them, reducing code duplication. I assume you found this due to the DUPLICATE

Re: [PATCH v1] Travis: also test on 32-bit Linux

2017-03-09 Thread René Scharfe
Am 05.03.2017 um 12:36 schrieb Jeff King: > I grepped for 'memcpy.*sizeof' and found one other case that's not a > bug, but is questionable. > > Of the "good" cases, I think most of them could be converted into > something more obviously-correct, which would make auditing easier. The > three main

Re: [PATCH v1] Travis: also test on 32-bit Linux

2017-03-09 Thread René Scharfe
Am 05.03.2017 um 12:36 schrieb Jeff King: I grepped for 'memcpy.*sizeof' and found one other case that's not a bug, but is questionable. Of the "good" cases, I think most of them could be converted into something more obviously-correct, which would make auditing easier. The three main cases I sa

[PATCH] blame: move blame_entry duplication to add_blame_entry()

2017-03-09 Thread René Scharfe
All callers of add_blame_entry() allocate and copy the second argument. Let the function do it for them, reducing code duplication. Signed-off-by: Rene Scharfe --- builtin/blame.c | 25 - 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/builtin/blame.c b/bui

Re: [PATCH 2/2] Fix callsites of real_pathdup() that wanted it to die on error

2017-03-09 Thread René Scharfe
Am 09.03.2017 um 12:24 schrieb Johannes Schindelin: While I would have agreed earlier that René's patch looks less intrusive, I have to point out that there would not have been any possible regression if the original patch had introduced the die_on_error parameter. It would have made the contract

Re: [PATCH 2/2] Fix callsites of real_pathdup() that wanted it to die on error

2017-03-08 Thread René Scharfe
Am 08.03.2017 um 16:43 schrieb Johannes Schindelin: > In 4ac9006f832 (real_path: have callers use real_pathdup and > strbuf_realpath, 2016-12-12), we changed the xstrdup(real_path()) > pattern to use real_pathdup() directly. > > The only problem with this change is that real_path() calls > strbuf_

Re: fatal: Could not get current working directory: Permission denied | affected 2.10,2.11,2.12, but not 1.9.5 |

2017-03-08 Thread René Scharfe
Am 06.03.2017 um 17:10 schrieb Zenobiusz Kunegunda: OS: FreeBSD 10.3-STABLE Story: I was trying to install openproject using this manual https://www.openproject.org/open-source/download/manual-installation-guide/ Everything was fine till command $ bundle install --deployment --without postgres

Re: git status --> Out of memory, realloc failed

2017-03-02 Thread René Scharfe
Am 01.03.2017 um 21:12 schrieb Carsten Fuchs: Hi René, Am 01.03.2017 um 11:02 schrieb René Scharfe: I use Git at a web hosting service, where my user account has a memory limit of 768 MB: (uiserver):p7715773:~$ uname -a Linux infongp-de15 3.14.0-ui16322-uiabi1-infong-amd64 #1 SMP Debian

Re: [PATCH 2/2] pretty: use fmt_output_email_subject()

2017-03-01 Thread René Scharfe
Am 01.03.2017 um 12:37 schrieb René Scharfe: Add the email-style subject prefix (e.g. "Subject: [PATCH] ") directly when it's needed instead of letting log_write_email_headers() prepare it in a static buffer in advance. This simplifies storage ownership and code flow. Sign

Re: What's cooking in git.git (Mar 2017, #01; Wed, 1)

2017-03-01 Thread René Scharfe
Am 01.03.2017 um 23:35 schrieb Junio C Hamano: > * rs/log-email-subject (2017-03-01) 2 commits > - pretty: use fmt_output_email_subject() > - log-tree: factor out fmt_output_email_subject() > > Code clean-up. > > Will merge to 'next'. Could you please squash this in? We only use a single co

[PATCH 1/2] log-tree: factor out fmt_output_email_subject()

2017-03-01 Thread René Scharfe
Use a strbuf to store the subject prefix string and move its construction into its own function. This gets rid of two arbitrary length limits and allows the string to be added by callers directly. Signed-off-by: Rene Scharfe --- log-tree.c | 40 log-tree

[PATCH 2/2] pretty: use fmt_output_email_subject()

2017-03-01 Thread René Scharfe
Add the email-style subject prefix (e.g. "Subject: [PATCH] ") directly when it's needed instead of letting log_write_email_headers() prepare it in a static buffer in advance. This simplifies storage ownership and code flow. Signed-off-by: Rene Scharfe --- This slows down the last three tests in

Re: git status --> Out of memory, realloc failed

2017-03-01 Thread René Scharfe
Am 25.02.2017 um 11:13 schrieb Carsten Fuchs: Dear Git group, I use Git at a web hosting service, where my user account has a memory limit of 768 MB: (uiserver):p7715773:~$ uname -a Linux infongp-de15 3.14.0-ui16322-uiabi1-infong-amd64 #1 SMP Debian 3.14.79-2~ui80+4 (2016-11-17) x86_64 GNU/Linu

Re: [PATCH 0/6] Use time_t

2017-02-28 Thread René Scharfe
Am 28.02.2017 um 21:54 schrieb Johannes Schindelin: Hi Junio, On Tue, 28 Feb 2017, Junio C Hamano wrote: René Scharfe writes: Am 28.02.2017 um 15:28 schrieb Jeff King: It looks from the discussion like the sanest path forward is our own signed-64bit timestamp_t. That's unfort

Re: [PATCH 0/6] Use time_t

2017-02-28 Thread René Scharfe
Am 01.03.2017 um 00:10 schrieb Johannes Schindelin: Hi René, On Tue, 28 Feb 2017, René Scharfe wrote: Am 28.02.2017 um 21:54 schrieb Johannes Schindelin: On Tue, 28 Feb 2017, Junio C Hamano wrote: René Scharfe writes: Am 28.02.2017 um 15:28 schrieb Jeff King: It looks from the

Re: [PATCH 0/6] Use time_t

2017-02-28 Thread René Scharfe
Am 28.02.2017 um 15:28 schrieb Jeff King: On Mon, Feb 27, 2017 at 10:30:20PM +0100, Johannes Schindelin wrote: One notable fallout of this patch series is that on 64-bit Linux (and other platforms where `unsigned long` is 64-bit), we now limit the range of dates to LONG_MAX (i.e. the *signed* m

Re: [PATCH 2/2] apply: handle assertion failure gracefully

2017-02-28 Thread René Scharfe
Am 27.02.2017 um 23:33 schrieb Junio C Hamano: > René Scharfe writes: > >> Am 27.02.2017 um 21:04 schrieb Junio C Hamano: >>> René Scharfe writes: >>> >>>>> diff --git a/apply.c b/apply.c >>>>> index cbf7cc7f2..9219d2737 100644 >

Re: [PATCH] strbuf: add strbuf_add_real_path()

2017-02-27 Thread René Scharfe
Am 27.02.2017 um 19:22 schrieb Brandon Williams: On 02/25, René Scharfe wrote: +void strbuf_add_real_path(struct strbuf *sb, const char *path) +{ + if (sb->len) { + struct strbuf resolved = STRBUF_INIT; + strbuf_realpath(&resolved,

Re: [PATCH 2/2] commit: don't check for space twice when looking for header

2017-02-27 Thread René Scharfe
Am 27.02.2017 um 23:27 schrieb Jakub Narębski: W dniu 25.02.2017 o 20:27, René Scharfe pisze: Both standard_header_field() and excluded_header_field() check if there's a space after the buffer that's handed to them. We already check in the caller if that space is present. Don't

Re: [PATCH 2/2] apply: handle assertion failure gracefully

2017-02-27 Thread René Scharfe
Am 27.02.2017 um 21:04 schrieb Junio C Hamano: René Scharfe writes: diff --git a/apply.c b/apply.c index cbf7cc7f2..9219d2737 100644 --- a/apply.c +++ b/apply.c @@ -3652,7 +3652,6 @@ static int check_preimage(struct apply_state *state, if (!old_name) return 0

Re: [PATCH 1/2] apply: guard against renames of non-existant empty files

2017-02-27 Thread René Scharfe
Am 27.02.2017 um 21:10 schrieb Junio C Hamano: René Scharfe writes: Would it make sense to mirror the previously existing condition and check for is_new instead? I.e.: if ((!patch->is_delete && !patch->new_name) || (

Re: SHA1 collisions found

2017-02-27 Thread René Scharfe
Am 25.02.2017 um 20:04 schrieb brian m. carlson: >>> So I think that the current scope left is best estimated by the >>> following command: >>> >>> git grep -P 'unsigned char\s+(\*|.*20)' | grep -v '^Documentation' >>> >>> So there are approximately 1200 call sites left, which is quite a bit of >

Re: [PATCH 2/2] commit: don't check for space twice when looking for header

2017-02-25 Thread René Scharfe
Am 25.02.2017 um 21:15 schrieb Jeff King: On Sat, Feb 25, 2017 at 08:27:40PM +0100, René Scharfe wrote: Both standard_header_field() and excluded_header_field() check if there's a space after the buffer that's handed to them. We already check in the caller if that space is prese

Re: [PATCH 2/2] apply: handle assertion failure gracefully

2017-02-25 Thread René Scharfe
Am 25.02.2017 um 11:13 schrieb Vegard Nossum: For the patches in the added testcases, we were crashing with: git-apply: apply.c:3665: check_preimage: Assertion `patch->is_new <= 0' failed. As it turns out, check_preimage() is prepared to handle these conditions, so we can remove the assert

Re: [PATCH 1/2] apply: guard against renames of non-existant empty files

2017-02-25 Thread René Scharfe
Am 25.02.2017 um 11:13 schrieb Vegard Nossum: If we have a patch like the one in the new test-case, then we will try to rename a non-existant empty file, i.e. patch->old_name will be NULL. In this case, a NULL entry will be added to fn_table, which is not allowed (a subsequent binary search will

[PATCH 2/2] commit: don't check for space twice when looking for header

2017-02-25 Thread René Scharfe
Both standard_header_field() and excluded_header_field() check if there's a space after the buffer that's handed to them. We already check in the caller if that space is present. Don't bother calling the functions if it's missing, as they are guaranteed to return 0 in that case, and remove the no

[PATCH 1/2] commit: be more precise when searching for headers

2017-02-25 Thread René Scharfe
Search for a space character only within the current line in read_commit_extra_header_lines() instead of searching in the whole buffer (and possibly beyond, if it's not NUL-terminated) and then discarding any results after the end of the current line. Signed-off-by: Rene Scharfe --- commit.c | 4

[PATCH] strbuf: add strbuf_add_real_path()

2017-02-25 Thread René Scharfe
Add a function for appending the canonized absolute pathname of a given path to a strbuf. It keeps the existing contents intact, as expected of a function of the strbuf_add() family, while avoiding copying the result if the given strbuf is empty. It's more consistent with the rest of the strbuf A

[PATCH] cocci: use ALLOC_ARRAY

2017-02-25 Thread René Scharfe
Add a semantic patch for using ALLOC_ARRAY to allocate arrays and apply the transformation on the current source tree. The macro checks for multiplication overflow and infers the element size automatically; the result is shorter and safer code. Signed-off-by: Rene Scharfe --- contrib/coccinelle

[PATCH] sha1_file: release fallback base's memory in unpack_entry()

2017-02-25 Thread René Scharfe
If a pack entry that's used as a delta base is corrupt, unpack_entry() marks it as unusable and then searches the object again in the hope that it can be found in another pack or in a loose file. The memory for this external base object is never released. Free it after use. Signed-off-by: Rene S

Re: What's cooking in git.git (Feb 2017, #04; Tue, 14)

2017-02-15 Thread René Scharfe
Am 14.02.2017 um 23:59 schrieb Junio C Hamano: * rs/ls-files-partial-optim (2017-02-13) 2 commits - ls-files: move only kept cache entries in prune_cache() - ls-files: pass prefix length explicitly to prune_cache() "ls-files" run with pathspec has been micro-optimized to avoid one extra call

Re: [PATCH] fixup! bisect--helper: `bisect_next_check` & bisect_voc shell function in C

2017-02-13 Thread René Scharfe
Am 13.02.2017 um 17:23 schrieb Johannes Schindelin: > Hi René, > > On Fri, 10 Feb 2017, René Scharfe wrote: > >> Am 10.02.2017 um 15:20 schrieb Johannes Schindelin: >>> It is curious that only MacOSX builds trigger an error about this, both >>> GCC and Cla

Re: What's cooking in git.git (Feb 2017, #03; Fri, 10)

2017-02-12 Thread René Scharfe
Am 12.02.2017 um 19:32 schrieb Vegard Nossum: I said I would resubmit the patches with more config options and more command-line arguments (to avoid potentially breaking backwards compatibility), but IIRC the response seemed to be "preceding blank line heuristic is good enough" and "why bother",

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

2017-02-11 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. This change was done before in deb8e15a (rm: reuse strbuf for all remove_dir_recursively() calls), but was reverted as a side-effect of 55856a35 (rm: absorb a submo

Re: [PATCH] cocci: detect useless free(3) calls

2017-02-11 Thread René Scharfe
Am 11.02.2017 um 20:31 schrieb Lars Schneider: > how do you run these checks on the entire Git source? > Do you run each semantic patch file on the source like this? > > spatch --sp-file contrib/coccinelle/qsort.cocci --dir /path/to/git/git > ... > spatch --sp-file contrib/coccinelle/free.cocci --

[PATCH] cocci: detect useless free(3) calls

2017-02-11 Thread René Scharfe
Add a semantic patch for removing checks that cause free(3) to only be called with a NULL pointer, as that must be a programming mistake. Signed-off-by: Rene Scharfe --- No cases are found in master or next, but 1d263b93 (bisect--helper: `bisect_next_check` & bisect_voc shell function in C) intro

Re: What's cooking in git.git (Feb 2017, #03; Fri, 10)

2017-02-10 Thread René Scharfe
Am 10.02.2017 um 23:24 schrieb Junio C Hamano: * vn/xdiff-func-context (2017-01-15) 1 commit - xdiff -W: relax end-of-file function detection "git diff -W" has been taught to handle the case where a new function is added at the end of the file better. Will hold. Discussion on an follow-up

Re: [PATCH] fixup! bisect--helper: `bisect_next_check` & bisect_voc shell function in C

2017-02-10 Thread René Scharfe
Am 10.02.2017 um 15:20 schrieb Johannes Schindelin: It is curious that only MacOSX builds trigger an error about this, both GCC and Clang, but not Linux GCC nor Clang (see https://travis-ci.org/git/git/jobs/200182819#L1152 for details): builtin/bisect--helper.c:299:6: error: variable 'good_syn'

[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

[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

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

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: 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-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: [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&

[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

[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

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

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-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-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-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 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 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 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 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 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

[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

[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] 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 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 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 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 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

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