[PATCH 3/3] sha1_file: use hex_to_bytes()

2017-10-31 Thread René Scharfe
The path of a loose object contains its hash value encoded into two substrings of 2 and 38 hexadecimal digits separated by a slash. The first part is handed to for_each_file_in_obj_subdir() in decoded form as subdir_nr. The current code builds a full hexadecimal representation of the hash in a

[PATCH 2/3] http-push: use hex_to_bytes()

2017-10-31 Thread René Scharfe
The path of a loose object contains its hash value encoded into two substrings of hexadecimal digits, separated by a slash. The current code copies the pieces into a temporary buffer to get rid of the slash and then uses get_oid_hex() to decode the hash value. Avoid the copy by using

[PATCH 1/3] notes: move hex_to_bytes() to hex.c and export it

2017-10-31 Thread René Scharfe
Make the function for converting pairs of hexadecimal digits to binary available to other call sites. Signed-off-by: Rene Scharfe --- cache.h | 7 +++ hex.c | 12 notes.c | 17 - 3 files changed, 19 insertions(+), 17 deletions(-) diff --git

[PATCH 2/2] sequencer: use O_TRUNC to truncate files

2017-10-31 Thread René Scharfe
Cut off any previous content of the file to be rewritten by passing the flag O_TRUNC to open(2) instead of calling ftruncate(2) at the end. That's easier and shorter. Signed-off-by: Rene Scharfe --- sequencer.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git

[PATCH 1/2] sequencer: factor out rewrite_file()

2017-10-31 Thread René Scharfe
Reduce code duplication by extracting a function for rewriting an existing file. Signed-off-by: Rene Scharfe --- sequencer.c | 46 +- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/sequencer.c b/sequencer.c index

Re: [PATCH 2/2] diff.c: get rid of duplicate implementation

2017-10-26 Thread René Scharfe
Am 25.10.2017 um 20:49 schrieb Stefan Beller: > The implementations in diff.c to detect moved lines needs to compare > strings and hash strings, which is implemented in that file, as well > as in the xdiff library. > > Remove the rather recent implementation in diff.c and rely on the well >

Re: [PATCH 1/2] xdiff-interface: export comparing and hashing strings

2017-10-26 Thread René Scharfe
Am 25.10.2017 um 20:49 schrieb Stefan Beller: > +/* > + * Compare the strings l1 with l2 which are of size s1 and s2 respectively. > + * Returns 1 if the strings are deemed equal, 0 otherwise. > + * The `flags` given as XDF_WHITESPACE_FLAGS determine how white spaces > + * are treated for the

Re: [PATCH 2/4] xdiff-interface: export comparing and hashing strings

2017-10-26 Thread René Scharfe
Am 24.10.2017 um 22:42 schrieb Stefan Beller: > On Tue, Oct 24, 2017 at 1:23 PM, René Scharfe <l@web.de> wrote: > >> xdl_recmatch() is already exported; why not use it without this >> wrapper? > > It is exported in xdiff/xutils.h, to be used by various xdif

Re: [PATCH 3/4] xdiff: use stronger hash function internally

2017-10-24 Thread René Scharfe
Am 24.10.2017 um 20:59 schrieb Stefan Beller: > Instead of using the hash seeded with 5381, and updated via > `(hash << 5) ^ new_byte`, use the FNV-1 primitives as offered by > hashmap.h, which is seeded with 0x811c9dc5 and computed as > `(hash * 0x01000193) ^ new_byte`. The hash function you're

Re: [PATCH 2/4] xdiff-interface: export comparing and hashing strings

2017-10-24 Thread René Scharfe
Am 24.10.2017 um 20:59 schrieb Stefan Beller: > This will turn out to be useful in a later patch > > Signed-off-by: Stefan Beller > --- > xdiff-interface.c | 11 +++ > xdiff-interface.h | 5 + > 2 files changed, 16 insertions(+) > > diff --git

Re: [PATCH 1/4] hashmap: introduce memhash_feed to access the internals of FNV-1 hash

2017-10-24 Thread René Scharfe
Am 24.10.2017 um 20:59 schrieb Stefan Beller: > This will be useful shortly. > > Signed-off-by: Stefan Beller > --- > hashmap.c | 7 ++- > hashmap.h | 3 +++ > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/hashmap.c b/hashmap.c > index

Re: [Alt. PATCH] ls-remote: deprecate -h as short for --heads

2017-10-24 Thread René Scharfe
Am 24.10.2017 um 02:52 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: > >> Am 21.10.2017 um 14:18 schrieb Junio C Hamano: >>> René Scharfe <l@web.de> writes: >>> >>>> FWIW, I use "-?" for that everywhere. I have y

Re: [Alt. PATCH] ls-remote: deprecate -h as short for --heads

2017-10-23 Thread René Scharfe
Am 21.10.2017 um 14:18 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: > >> FWIW, I use "-?" for that everywhere. I have yet to find a command or >> environment where it does something dangerous. > > Yeah, it would have made the world a be

Re: [Alt. PATCH] ls-remote: deprecate -h as short for --heads

2017-10-21 Thread René Scharfe
Am 20.10.2017 um 07:35 schrieb Junio C Hamano: > Jeff King writes: > >> It seems weird and inconsistent to me that the meaning of "-h" >> depends on the position and presence of other unrelated options. The position is relevant with parse-options for *each* flag for a different

Re: [Alt. PATCH] ls-remote: deprecate -h as short for --heads

2017-10-19 Thread René Scharfe
Am 18.10.2017 um 01:22 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: > >> Stop advertising -h as the short equivalent of --heads, because it's >> used for showing a short help text for almost all other git commands. >> Since the ba5f28bf79 (ls-remote:

[PATCH 2/2] ls-remote: use PARSE_OPT_NO_INTERNAL_HELP

2017-10-17 Thread René Scharfe
Since ba5f28bf79 (ls-remote: use parse-options api) git ls-remote -h without any other options has shown the short help text of the command instead of acting as the short equivalent of --heads. Fix this regression by turning off internal handling of -h for repository setup, and option parsing, as

[Alt. PATCH] ls-remote: deprecate -h as short for --heads

2017-10-17 Thread René Scharfe
Stop advertising -h as the short equivalent of --heads, because it's used for showing a short help text for almost all other git commands. Since the ba5f28bf79 (ls-remote: use parse-options api) it has only been working when used together with other parameters anyway. Signed-off-by: Rene Scharfe

[PATCH 1/2] git: add NO_INTERNAL_HELP flag for builtins

2017-10-17 Thread René Scharfe
Builtin commands have skipped repo setup when called with just a single option -h and thus shown their short help text even outside of repositories since 99caeed05d3 (Let 'git -h' show usage without a git dir). Add the flag NO_INTERNAL_HELP for builtins to opt out of this special treatment and

Re: Bug: git ls-remote -h / --head results differ in output

2017-10-15 Thread René Scharfe
Am 15.10.2017 um 13:08 schrieb Martin Ågren: > On 15 October 2017 at 12:02, Thomas Rikl wrote: >> Example: >> >> tom1 ~/emacs/spacemacs/.emacs.d $ export LANG=en_US.utf8 >> >> tom1 ~/emacs/spacemacs/.emacs.d $ git ls-remote -h >> usage: git ls-remote [--heads] [--tags] [--refs]

Re: [PATCH] sequencer.c: unify error messages

2017-10-13 Thread René Scharfe
Am 13.10.2017 um 19:51 schrieb Ralf Thielow: > When ftruncate() in rearrange_squash() fails, we write > that we couldn't finish the operation on the todo file. > It is more accurate to write that we couldn't truncate > as we do in other calls of ftruncate(). Would it make sense to factor out

Re: "git rm" seems to do recursive removal even without "-r"

2017-10-08 Thread René Scharfe
[My SMTP server still refuses to accept emails to rpj...@crashcourse.ca and reports "mailbox unavailable" and "invalid DNS MX or A/ resource record." So just replying to the list.] Am 08.10.2017 um 13:56 schrieb Robert P. J. Day: >but as i asked in my earlier post, if i wanted to

Re: [PATCH v2] fsck: handle NULL return of lookup_blob() and lookup_tree()

2017-10-06 Thread René Scharfe
Am 06.10.2017 um 04:23 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: >> +blob_bin=$(echo $blob | hex2oct) && >> +tree=$( >> +printf "4 dir\0${blob_bin}100644 file\0${blob_bin}" | > > Wow, that's ... cute.

[PATCH v2] fsck: handle NULL return of lookup_blob() and lookup_tree()

2017-10-05 Thread René Scharfe
lookup_blob() and lookup_tree() can return NULL if they find an object of an unexpected type. Accessing the object member is undefined in that case. Cast the result to a struct object pointer instead; we can do that because object is the first member of all object types. This trick is already

Re: [PATCH] fsck: check results of lookup_blob() and lookup_tree() for NULL

2017-10-05 Thread René Scharfe
Am 04.10.2017 um 06:00 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: >> lookup_blob() and lookup_tree() can return NULL if they find an object >> of an unexpected type. Error out of fsck_walk_tree() in that case, like >> we do when encountering a bad f

[PATCH] .mailmap: normalize name for René Scharfe

2017-10-05 Thread René Scharfe
- a/.mailmap +++ b/.mailmap @@ -194,6 +194,7 @@ Philippe Bruhat <b...@cpan.org> Ralf Thielow <ralf.thie...@gmail.com> <ralf.thie...@googlemail.com> Ramsay Jones <ram...@ramsayjones.plus.com> <ram...@ramsay1.demon.co.uk> René Scharfe <l@web.de> <rene.

[PATCH] test-stringlist: avoid buffer underrun when sorting nothing

2017-10-03 Thread René Scharfe
Check if the strbuf containing data to sort is empty before attempting to trim a trailing newline character. Signed-off-by: Rene Scharfe --- t/helper/test-string-list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/helper/test-string-list.c

[PATCH] fsck: check results of lookup_blob() and lookup_tree() for NULL

2017-10-03 Thread René Scharfe
Am 03.10.2017 um 14:51 schrieb René Scharfe: > Am 03.10.2017 um 12:22 schrieb SZEDER Gábor: >> Furthermore, fsck.c:fsck_walk_tree() does the same "immediately >> reference the object member in lookup_blob()'s and lookup_tree()'s >> return value" thing. I thin

Re: [PATCH] tag: avoid NULL pointer arithmetic

2017-10-03 Thread René Scharfe
Am 03.10.2017 um 12:22 schrieb SZEDER Gábor: >> lookup_blob() etc. can return NULL if the referenced object isn't of the >> expected type. In theory it's wrong to reference the object member in >> that case. In practice it's OK because it's located at offset 0 for all >> types, so the pointer

Re: What means "git config bla ~/"?

2017-10-02 Thread René Scharfe
[When I try to reply to rpj...@crashcourse.ca then my SMTP server says "Requested action not taken: mailbox unavailable invalid DNS MX or A/ resource record.", so I'm replying only to the list.] Am 02.10.2017 um 12:13 schrieb rpj...@crashcourse.ca: > i'm sure i'm about to embarrass myself

Re: [PATCH] tag: avoid NULL pointer arithmetic

2017-10-02 Thread René Scharfe
Am 02.10.2017 um 07:08 schrieb Jeff King: > On Sun, Oct 01, 2017 at 04:45:13PM +0200, René Scharfe wrote: > >> lookup_blob() etc. can return NULL if the referenced object isn't of the >> expected type. In theory it's wrong to reference the object member in >> that ca

[PATCH 2/2] run-command: use ALLOC_ARRAY

2017-10-01 Thread René Scharfe
Use the macro ALLOC_ARRAY to allocate an array. This is shorter and eaasier, as it automatically infers the size of elements. Patch generated with Coccinelle and contrib/coccinelle/array.cocci. Signeg-off-by: Rene Scharfe --- run-command.c | 2 +- 1 file changed, 1 insertion(+),

[PATCH 1/2] coccinelle: remove parentheses that become unnecessary

2017-10-01 Thread René Scharfe
Transformations that hide multiplications can end up with an pair of parentheses that is no longer needed. E.g. with a rule like this: @@ expression E; @@ - E * 2 + double(E) ... we might get a patch like this: - x = (a + b) * 2; + x = double((a + b)); Add a pair of

[PATCH 2/2] commit: use strbuf_add() to add a buffer to a strbuf

2017-10-01 Thread René Scharfe
This is shorter, easier and makes the intent clearer. Patch generated with Coccinelle and contrib/coccinelle/strbuf.cocci. Signed-off-by: Rene Scharfe --- builtin/commit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/commit.c b/builtin/commit.c

[PATCH 1/2] coccinelle: add rules to use strbuf_add() for adding buffers to strbufs

2017-10-01 Thread René Scharfe
strbuf_addf() can be used with "%.*s" to add a buffer of a specific size to a strbuf, but the resulting code is longer, may require casting the length to int and is less efficient than simply calling strbuf_add(). Add Coccinelle rules for transforming calls of the former type to the latter.

[PATCH] graph: use strbuf_addchars() to add spaces

2017-10-01 Thread René Scharfe
strbuf_addf() can be used to add a specific number of space characters by using the format "%*s" with an empty string and specifying the desired width. Use strbuf_addchars() instead as it's shorter, makes the intent clearer and is a bit more efficient. Signed-off-by: Rene Scharfe

[PATCH] tag: avoid NULL pointer arithmetic

2017-10-01 Thread René Scharfe
lookup_blob() etc. can return NULL if the referenced object isn't of the expected type. In theory it's wrong to reference the object member in that case. In practice it's OK because it's located at offset 0 for all types, so the pointer arithmetic (NULL + 0) is optimized out by the compiler.

[PATCH] repository: use FREE_AND_NULL

2017-10-01 Thread René Scharfe
Use the macro FREE_AND_NULL to release allocated objects and clear their pointers. This is shorter and documents the intent better by combining the two related operations into one. Patch generated with Coccinelle and contrib/coccinelle/free.cocci. Signed-off-by: Rene Scharfe ---

[PATCH] path: use strbuf_add_real_path()

2017-10-01 Thread René Scharfe
Avoid a string copy to a static buffer by using strbuf_add_real_path() instead of combining strbuf_addstr() and real_path(). Patch generated by Coccinelle and contrib/coccinelle/strbuf.cocci. Signed-off-by: Rene Scharfe --- path.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH] use strbuf_addstr() for adding strings to strbufs

2017-10-01 Thread René Scharfe
Use strbuf_addstr() instead of strbuf_addf() for adding strings. That's simpler and makes the intent clearer. Patch generated by Coccinelle and contrib/coccinelle/strbuf.cocci; adjusted indentation in refs/packed-backend.c manually. Signed-off-by: Rene Scharfe ---

[PATCH 5/3] refs: pass NULL to resolve_refdup() if hash is not needed

2017-10-01 Thread René Scharfe
This allows us to get rid of several write-only variables. Signed-off-by: Rene Scharfe --- builtin/checkout.c | 3 +-- builtin/receive-pack.c | 3 +-- ref-filter.c | 7 ++- reflog-walk.c | 6 ++ transport.c| 3 +-- wt-status.c

[PATCH 4/3] refs: pass NULL to refs_resolve_refdup() if hash is not needed

2017-10-01 Thread René Scharfe
This gets us rid of a write-only variable. Signed-off-by: Rene Scharfe --- refs/files-backend.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index fec77744b4..ed00ddab1a 100644 --- a/refs/files-backend.c +++

Re: [PATCH 1/3] refs: make sha1 output parameter of refs_resolve_ref_unsafe() optional

2017-09-24 Thread René Scharfe
Am 24.09.2017 um 03:26 schrieb Junio C Hamano: > I wonder if we want a dedicated helper for them (perhaps about a > dozen callers we have that fall into this pattern?) to call for the > exact purpose, implemented as a thin-wrapper around the > resolve_ref_unsafe() function, though.

Re: [PATCH] mailinfo: don't decode invalid =XY quoted-printable sequences

2017-09-23 Thread René Scharfe
Am 23.09.2017 um 20:04 schrieb René Scharfe: > Decode =XY in quoted-printable segments only if X and Y are hexadecimal > digits, otherwise just copy them. That's at least better than > interpreting negative results from hexval() as a character. Forgot to add: Reported-by: Jef

[PATCH] mailinfo: don't decode invalid =XY quoted-printable sequences

2017-09-23 Thread René Scharfe
Decode =XY in quoted-printable segments only if X and Y are hexadecimal digits, otherwise just copy them. That's at least better than interpreting negative results from hexval() as a character. Signed-off-by: Rene Scharfe --- mailinfo.c | 11 --- 1 file changed, 8

[PATCH 2/3] refs: pass NULL to refs_resolve_ref_unsafe() if hash is not needed

2017-09-23 Thread René Scharfe
This allows us to get rid of two write-only variables, one of them being a SHA1 buffer. Signed-off-by: Rene Scharfe --- refs/files-backend.c | 3 +-- worktree.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/refs/files-backend.c

[PATCH 3/3] refs: pass NULL to resolve_ref_unsafe() if hash is not needed

2017-09-23 Thread René Scharfe
This allows us to get rid of some write-only variables, among them seven SHA1 buffers. Signed-off-by: Rene Scharfe --- branch.c| 3 +-- builtin/commit.c| 3 +-- builtin/log.c | 3 +-- builtin/receive-pack.c | 3 +--

[PATCH 1/3] refs: make sha1 output parameter of refs_resolve_ref_unsafe() optional

2017-09-23 Thread René Scharfe
Allow callers of refs_resolve_ref_unsafe() to pass NULL if they don't need the resolved hash value. We already allow the same for the flags parameter. This new leniency is inherited by the various wrappers like resolve_ref_unsafe(). Signed-off-by: Rene Scharfe --- refs.c | 3 +++

Re: [PATCH 3/4] cache.h: hex2chr() - avoid -Wsign-compare warnings

2017-09-22 Thread René Scharfe
Am 22.09.2017 um 07:47 schrieb Jeff King: > On Thu, Sep 21, 2017 at 05:48:38PM +0100, Ramsay Jones wrote: > >> diff --git a/cache.h b/cache.h >> index a916bc79e..a0e3e362c 100644 >> --- a/cache.h >> +++ b/cache.h >> @@ -1243,8 +1243,8 @@ static inline unsigned int hexval(unsigned char c) >>*/

Re: [PATCH 4/4] archive: queue directories for all types of pathspecs

2017-09-13 Thread René Scharfe
Am 13.09.2017 um 14:53 schrieb Jeff King: > On Wed, Sep 13, 2017 at 12:43:57AM +0200, René Scharfe wrote: >> Yet another way is have a few levels of nested subdirectories (e.g. >> d1/d2/d3/file1) and ignoring the entries at the leaved (e.g. file1). > > s/leaved/leaves/ ? Indeed. René

Re: [PATCH 4/4] archive: queue directories for all types of pathspecs

2017-09-12 Thread René Scharfe
Am 20.08.2017 um 11:06 schrieb Jeff King: > I actually think it would be reasonable to omit the empty directory in > t5004. The main thing we care about there is that we produce an archive > with no files rather than barfing. Checking that the empty directory is > actually there was mostly "this

Re: [PATCH 06/34] clone: release strbuf after use in remove_junk()

2017-09-11 Thread René Scharfe
Am 10.09.2017 um 19:38 schrieb Jeff King: > On Sun, Sep 10, 2017 at 12:37:06PM +0200, René Scharfe wrote: > >>> And in fact, being called from a signal handler means we should >>> generally avoid touching malloc or free (which could be holding locks). >>>

Re: [PATCH 06/34] clone: release strbuf after use in remove_junk()

2017-09-10 Thread René Scharfe
Am 10.09.2017 um 09:30 schrieb Jeff King: > On Sun, Sep 10, 2017 at 08:27:40AM +0200, René Scharfe wrote: > >>>>if (junk_work_tree) { >>>>strbuf_addstr(, junk_work_tree); >>>>remove_dir_recu

Re: [PATCH] shortlog: skip format/parse roundtrip for internal traversal

2017-09-10 Thread René Scharfe
Am 08.09.2017 um 11:21 schrieb Jeff King: > Note that the non-stdin path no longer looks at the "mailmap" entry of > "struct shortlog" (instead we use the one cached inside pretty.c). But > we still waste time loading it. I'm not sure if it's worth addressing > that. It's only once per program

Re: [PATCH 06/34] clone: release strbuf after use in remove_junk()

2017-09-10 Thread René Scharfe
Am 06.09.2017 um 21:51 schrieb Junio C Hamano: > Rene Scharfe writes: > >> Signed-off-by: Rene Scharfe >> --- >> builtin/clone.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/builtin/clone.c b/builtin/clone.c >> index

Re: [PATCH 34/34] wt-status: release strbuf after use in wt_longstatus_print_tracking()

2017-09-10 Thread René Scharfe
Am 06.09.2017 um 21:51 schrieb Junio C Hamano: > Rene Scharfe writes: > >> If format_tracking_info() returns 0 only if it didn't touch its strbuf >> parameter, so it's OK to exit early in that case. Clean up sb in the >> other case. > > These two "if"s confuse me; perhaps the

Re: [PATCH] pull: honor submodule.recurse config option

2017-09-01 Thread René Scharfe
Am 01.09.2017 um 19:11 schrieb Stefan Beller: > On Fri, Sep 1, 2017 at 12:29 AM, Nicolas Morey-Chaisemartin > wrote: >> git pull used to not parse the submodule.recurse config option and simply >> consider the --recurse-submodules CLI option. >> When using the

Re: [PATCH 17/34] mailinfo: release strbuf on error return in handle_boundary()

2017-08-31 Thread René Scharfe
Am 30.08.2017 um 20:23 schrieb Martin Ågren: > On 30 August 2017 at 19:49, Rene Scharfe wrote: >> Signed-off-by: Rene Scharfe >> --- >> mailinfo.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/mailinfo.c b/mailinfo.c >> index b1f5159546..f2387a3267

[PATCH 2/2] apply: remove epoch date from regex

2017-08-25 Thread René Scharfe
We check the date of epoch timestamp candidates already with starts_with(). Move beyond that part using skip_prefix() instead of checking it again using a regular expression. Also group the minutes part, so that we can access them using a substring match instead of using a magic number.

[PATCH 1/2] apply: check date of potential epoch timestamps first

2017-08-25 Thread René Scharfe
has_epoch_timestamp() looks for time stamps that amount to either 1969-12-31 24:00 or 1970-01-01 00:00 after applying the time zone offset. Move the check for these two dates up, set the expected hour based on which one is found, or exit early if none of them are present, thus avoiding to engage

Re: [PATCH] repository: fix a sparse 'using integer a NULL pointer' warning

2017-08-22 Thread René Scharfe
Am 21.08.2017 um 17:48 schrieb Ramsay Jones: > > Commit 67a9dfcc00 ("hash-algo: integrate hash algorithm support with > repo setup", 21-08-2017) added a 'const struct git_hash_algo *hash_algo' > field to the repository structure, without modifying the initializer > of the 'the_repo' variable.

Re: [PATCH 4/4] archive: queue directories for all types of pathspecs

2017-08-19 Thread René Scharfe
Am 19.08.2017 um 18:53 schrieb René Scharfe: > Am 19.08.2017 um 07:33 schrieb René Scharfe: >> When read_tree_recursive() encounters a directory excluded by a pathspec >> then it enters it anyway because it might contain included entries. It >> calls the callback funct

Re: [PATCH 4/4] archive: queue directories for all types of pathspecs

2017-08-19 Thread René Scharfe
Am 19.08.2017 um 07:33 schrieb René Scharfe: > When read_tree_recursive() encounters a directory excluded by a pathspec > then it enters it anyway because it might contain included entries. It > calls the callback function before it is able to decide if the directory > is act

[PATCH] commit: remove unused inline function single_parent()

2017-08-19 Thread René Scharfe
53b2c823f6 (revision walker: mini clean-up) added the function in 2007, but it was never used, so we should be able to get rid of it now. Signed-off-by: Rene Scharfe --- commit.h | 5 - 1 file changed, 5 deletions(-) diff --git a/commit.h b/commit.h index

[PATCH 3/4] archive: don't queue excluded directories

2017-08-18 Thread René Scharfe
Reject directories with the attribute export-ignore already while queuing them. This prevents read_tree_recursive() from descending into them and this avoids write_archive_entry() rejecting them later on, which queue_or_write_archive_entry() is not prepared for. Borrow the existing strbuf to

[PATCH 4/4] archive: queue directories for all types of pathspecs

2017-08-18 Thread René Scharfe
When read_tree_recursive() encounters a directory excluded by a pathspec then it enters it anyway because it might contain included entries. It calls the callback function before it is able to decide if the directory is actually needed. For that reason git archive adds directories to a queue and

[PATCH 2/4] archive: factor out helper functions for handling attributes

2017-08-18 Thread René Scharfe
Add helpers for accessing attributes that encapsulate the details of how to retrieve their values. Signed-off-by: Rene Scharfe --- archive.c | 31 +++ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/archive.c b/archive.c index

[PATCH 1/4] t5001: add tests for export-ignore attributes and exclude pathspecs

2017-08-18 Thread René Scharfe
Demonstrate mishandling of the attribute export-ignore by git archive when used together with pathspecs. Wildcard pathspecs can even cause it to abort. And a directory excluded without a wildcard is still included as an empty folder in the archive. Test-case-by: David Adam

Re: Bug?: git archive exclude pathspec and gitattributes export-ignore

2017-08-18 Thread René Scharfe
Am 14.08.2017 um 18:43 schrieb René Scharfe: > The real solution is probably to teach tree-walk.c::do_match() how to > handle attributes and then inject ":(attr:-export-ignore)" as a default > internal pathspec in archive.c::parse_pathspec_arg() instead of handlin

Re: [PATCH] t1002: stop using sum(1)

2017-08-15 Thread René Scharfe
Am 15.08.2017 um 02:46 schrieb Jonathan Nieder: > Hi, > > René Scharfe wrote: >> We already compare changed files with their expected new contents using >> diff(1), so we don't need to check with "test_must_fail test_cmp" if >> they differ from their origina

Re: [PATCH] t1002: stop using sum(1)

2017-08-15 Thread René Scharfe
Am 14.08.2017 um 22:16 schrieb René Scharfe: > sum(1) is a command for calculating checksums of the contents of files. > It was part of early editions of Unix ("Research Unix", 1972/1973, [1]). > cksum(1) appeared in 4.4BSD (1993) as a replacement [2], and became part &

[PATCH] t1002: stop using sum(1)

2017-08-14 Thread René Scharfe
sum(1) is a command for calculating checksums of the contents of files. It was part of early editions of Unix ("Research Unix", 1972/1973, [1]). cksum(1) appeared in 4.4BSD (1993) as a replacement [2], and became part of POSIX.1-2008 [3]. OpenBSD 5.6 (2014) removed sum(1). We only use sum(1) in

Re: Bug?: git archive exclude pathspec and gitattributes export-ignore

2017-08-14 Thread René Scharfe
Am 13.08.2017 um 06:53 schrieb David Adam: > Hi all, > > I think I have a bug in git (tested 2.11.0 on Debian 8, 2.14.1 on OS X and > 2.14.1.145.gb3622a4 on OS X). > > Given a repository with an export-ignore directive for a subdirectory in > .gitattributes, `git archive` with a pathspec that

Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread René Scharfe
Am 13.08.2017 um 06:32 schrieb Jeff King: > On Sat, Aug 12, 2017 at 01:57:06PM +0200, René Scharfe wrote: > >> But we probably want to check for other errors. They look unlikely >> enough that we may get away with something like this: >> >>

Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread René Scharfe
Am 12.08.2017 um 13:57 schrieb René Scharfe: > Update: Just noticed that on the BSDs getdelim(3) doesn't set errno > to ENOMEM on allocation failure, but does set the error indicator. > That might be an oversight on their part, but that means we > certainly *need* to

Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-12 Thread René Scharfe
Am 12.08.2017 um 12:02 schrieb Simon Ruderich: > On Fri, Aug 11, 2017 at 10:52:51AM +0200, René Scharfe wrote: >> Am 11.08.2017 um 09:50 schrieb Simon Ruderich: >>> On Thu, Aug 10, 2017 at 10:56:40PM +0200, René Scharfe wrote: >>>> getdelim(3) returns -1 at the end of

[PATCH v2] tree-walk: convert fill_tree_descriptor() to object_id

2017-08-12 Thread René Scharfe
All callers of fill_tree_descriptor() have been converted to object_id already, so convert that function as well. As a nice side-effect we get rid of NULL checks in tree-diff.c, as fill_tree_descriptor() already does them for us. Helped-by: Johannes Sixt Signed-off-by: Rene

[PATCH] tree-walk: convert fill_tree_descriptor() to object_id

2017-08-12 Thread René Scharfe
All callers of fill_tree_descriptor() have been converted to object_id already, so convert that function as well. As a nice side-effect we get rid of NULL checks in tree-diff.c, as fill_tree_descriptor() already does them for us. Signed-off-by: Rene Scharfe ---

Re: [PATCH] cache-tree: remove use of strbuf_addf in update_one

2017-08-11 Thread René Scharfe
Am 10.08.2017 um 20:47 schrieb Kevin Willford: > String formatting can be a performance issue when there are > hundreds of thousands of trees. > > Change to stop using the strbuf_addf and just add the strings > or characters individually. > > There are a limited number of modes so added a switch

Re: [PATCH] apply: remove prefix_length member from apply_state

2017-08-11 Thread René Scharfe
Am 11.08.2017 um 01:41 schrieb Jeff King: > On Wed, Aug 09, 2017 at 05:54:46PM +0200, René Scharfe wrote: > >> Use a NULL-and-NUL check to see if we have a prefix and consistently use >> C string functions on it instead of storing its length in a member of >> struct a

Re: [PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-11 Thread René Scharfe
Am 11.08.2017 um 09:50 schrieb Simon Ruderich: > On Thu, Aug 10, 2017 at 10:56:40PM +0200, René Scharfe wrote: >> getdelim(3) returns -1 at the end of the file and if it encounters an >> error, but sets errno only in the latter case. Set errno to zero before >> calling it t

[PATCH] strbuf: clear errno before calling getdelim(3)

2017-08-10 Thread René Scharfe
getdelim(3) returns -1 at the end of the file and if it encounters an error, but sets errno only in the latter case. Set errno to zero before calling it to avoid misdiagnosing an out-of-memory condition due to a left-over value from some other function call. Reported-by: Yaroslav Halchenko

Re: fatal: Out of memory, getdelim failed under NFS mounts

2017-08-10 Thread René Scharfe
Am 10.08.2017 um 20:56 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: > >> I doubt the type of file system matters. The questions are: How much >> main memory do you have, what is git trying to cram into it, is there >> a way to reduce the memory f

Re: fatal: Out of memory, getdelim failed under NFS mounts

2017-08-10 Thread René Scharfe
Am 10.08.2017 um 16:43 schrieb Yaroslav Halchenko: > On Thu, 10 Aug 2017, René Scharfe wrote: >> Am 09.08.2017 um 19:39 schrieb Yaroslav Halchenko: >>> More context (may be different issue(s)) could be found at >>> http://git-annex.branchable.com/forum/git-an

[PATCH] merge: use skip_prefix()

2017-08-10 Thread René Scharfe
Get rid of a magic string length constant by using skip_prefix() instead of starts_with(). Signed-off-by: Rene Scharfe --- builtin/merge.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index 900bafdb45..4facb6fdd0 100644

Re: fatal: Out of memory, getdelim failed under NFS mounts

2017-08-10 Thread René Scharfe
Am 09.08.2017 um 19:39 schrieb Yaroslav Halchenko: > More context (may be different issue(s)) could be found at > http://git-annex.branchable.com/forum/git-annex_add_out_of_memory_error/ > but currently I am consistently reproducing it while running > git (1:2.11.0-3 debian stretch build) within

[PATCH] win32: plug memory leak on realloc() failure in syslog()

2017-08-10 Thread René Scharfe
If realloc() fails then the original buffer is still valid. Free it before exiting the function. Signed-off-by: Rene Scharfe --- compat/win32/syslog.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/win32/syslog.c b/compat/win32/syslog.c index 6c7c9b6053..161978d720

[PATCH] sha1_file: release delta_stack on error in unpack_entry()

2017-08-10 Thread René Scharfe
When unpack_entry() encounters a broken packed object, it returns early. It adjusts the reference count of the pack window, but leaks the buffer for a big delta stack in case the small automatic one was not enough. Jump to the cleanup code at end instead, which takes care of that. Signed-off-by:

[PATCH] fsck: free buffers on error in fsck_obj()

2017-08-10 Thread René Scharfe
Move the code for releasing tree buffers and commit buffers in fsck_obj() to the end of the function and make sure it's executed no matter of an error is encountered or not. Signed-off-by: Rene Scharfe --- builtin/fsck.c | 22 +++--- 1 file changed, 11

Re: [PATCH] t4062: stop using repetition in regex

2017-08-10 Thread René Scharfe
Am 09.08.2017 um 19:47 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: > >> There could be any characters except NUL and LF between the 4096 zeros >> and "0$" for the latter to match wrongly, no? So there are 4095 >> opportunit

Re: [PATCH] t4062: stop using repetition in regex

2017-08-09 Thread René Scharfe
Am 09.08.2017 um 18:07 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: > >>> In the face of unreliable segfaults we need to reverse our strategy, >>> I think. Searching for something not in the buffer (e.g. "1") and >>> considering m

[PATCH] apply: remove prefix_length member from apply_state

2017-08-09 Thread René Scharfe
Use a NULL-and-NUL check to see if we have a prefix and consistently use C string functions on it instead of storing its length in a member of struct apply_state. This avoids strlen() calls and simplifies the code. Signed-off-by: Rene Scharfe --- apply.c | 12 +---

Re: [PATCH 2/2] hashcmp: use memcmp instead of open-coded loop

2017-08-09 Thread René Scharfe
Am 09.08.2017 um 12:16 schrieb Jeff King: > In 1a812f3a70 (hashcmp(): inline memcmp() by hand to > optimize, 2011-04-28), it was reported that an open-coded > loop outperformed memcmp() for comparing sha1s. > > Discussion[1] a few years later in 2013 showed that this > depends on your libc's

Re: [PATCH] t4062: stop using repetition in regex

2017-08-09 Thread René Scharfe
Am 09.08.2017 um 08:15 schrieb René Scharfe: > Am 09.08.2017 um 07:29 schrieb Junio C Hamano: >> René Scharfe <l@web.de> writes: >> >>> Am 09.08.2017 um 00:26 schrieb Junio C Hamano: >>>> ... but in the meantime, I think replacing the test with &qu

Re: [PATCH] t4062: stop using repetition in regex

2017-08-09 Thread René Scharfe
Am 09.08.2017 um 07:29 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: > >> Am 09.08.2017 um 00:26 schrieb Junio C Hamano: >>> ... but in the meantime, I think replacing the test with "0$" to >>> force the scanner to find either th

Re: [PATCH] t4062: stop using repetition in regex

2017-08-08 Thread René Scharfe
Am 09.08.2017 um 00:26 schrieb Junio C Hamano: > Junio C Hamano writes: > >> So I find Dscho's concern quite valid, even though I do believe you >> when you say the code somehow segfaults. I just can not tell >> how/why it would segfault, though---it is possible that

Re: [PATCH] t4062: stop using repetition in regex

2017-08-08 Thread René Scharfe
Am 09.08.2017 um 00:09 schrieb Junio C Hamano: > René Scharfe <l@web.de> writes: > >> Am 08.08.2017 um 16:49 schrieb Johannes Schindelin: >>> Hi René, >>> >>> On Tue, 8 Aug 2017, René Scharfe wrote: >>> >>>> OpenBSD's reg

[PATCH] sha1_file: avoid comparison if no packed hash matches the first byte

2017-08-08 Thread René Scharfe
find_pack_entry_one() uses the fan-out table of pack indexes to find out which entries match the first byte of the searched hash and does a binary search on this subset of the main index table. If there are no matching entries then lo and hi will have the same value. The binary search still

Re: [PATCH] builtin/add: add a missing newline to an stderr message

2017-08-08 Thread René Scharfe
Am 08.08.2017 um 23:36 schrieb Ramsay Jones: > > Signed-off-by: Ramsay Jones > --- > > Hi Junio, > > I noticed this while looking into the t3700 failure on cygwin tonight. > Also, I couldn't decide whether or not to add the i18n '_()' brackets > around the message.

[PATCH v2] t3700: fix broken test under !POSIXPERM

2017-08-08 Thread René Scharfe
76e368c378 (t3700: fix broken test under !SANITY) explains that the test 'git add --chmod=[+-]x changes index with already added file' can fail if xfoo3 is still present as a symlink from a previous test and deletes it with rm(1). That still leaves it present in the index, which causes the test

Re: t3700 broken on pu on Cygwin

2017-08-08 Thread René Scharfe
Am 08.08.2017 um 17:18 schrieb Adam Dinwoodie: > The t3700-add.sh test is currently failing on the pu branch on Cygwin. > To my surprise, the problem appears to have been introduced by a merge, > 867fa1d6a. Both parents of that merge have the test succeeding, but > it's failing on that merge

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