[PATCH 1/3] strbuf: add strbuf_add_cwd()

2014-07-20 Thread René Scharfe
Add strbuf_add_cwd(), which adds the current working directory to a strbuf. Because it doesn't use a fixed-size buffer it supports arbitrarily long paths, as long as the platform's getcwd() does as well. At least on Linux and FreeBSD it handles paths longer than PATH_MAX just fine.

[PATCH 2/3] wrapper: add xgetcwd()

2014-07-20 Thread René Scharfe
Add the helper function xgetcwd(), which returns the current directory or dies. The returned string has to be free()d after use. Signed-off-by: Rene Scharfe l@web.de --- git-compat-util.h | 1 + wrapper.c | 8 2 files changed, 9 insertions(+) diff --git a/git-compat-util.h

[PATCH 3/3] use xgetcwd() get the current directory or die

2014-07-20 Thread René Scharfe
Convert several calls of getcwd() and die() to use xgetcwd() instead. This way we get rid of fixed-size buffers (which can be too small depending on the used file system) and gain consistent error messages. Signed-off-by: Rene Scharfe l@web.de --- builtin/init-db.c | 17 -

Re: [PATCH 3/3] use xgetcwd() get the current directory or die

2014-07-20 Thread René Scharfe
Am 20.07.2014 14:45, schrieb Duy Nguyen: On Sun, Jul 20, 2014 at 6:22 PM, René Scharfe l@web.de wrote: Convert several calls of getcwd() and die() to use xgetcwd() instead. This way we get rid of fixed-size buffers (which can be too small depending on the used file system) and gain

Re: [PATCH 1/3] strbuf: add strbuf_add_cwd()

2014-07-20 Thread René Scharfe
Am 20.07.2014 14:33, schrieb Duy Nguyen: On Sun, Jul 20, 2014 at 6:21 PM, René Scharfe l@web.de wrote: +int strbuf_add_cwd(struct strbuf *sb) +{ + size_t oldalloc = sb-alloc; + size_t guessed_len = 32; For Linux, I think this is enough to succesfully get cwd in the first pass

Re: [PATCH 2/3] wrapper: add xgetcwd()

2014-07-20 Thread René Scharfe
Am 20.07.2014 14:35, schrieb Duy Nguyen: On Sun, Jul 20, 2014 at 6:21 PM, René Scharfe l@web.de wrote: +char *xgetcwd(void) +{ + struct strbuf sb = STRBUF_INIT; + if (strbuf_add_cwd(sb)) + die_errno(unable to get current working directory); Wrap the string

[PATCH v2 0/4] getcwd without PATH_MAX

2014-07-20 Thread René Scharfe
getcwd() call in setup.c René Scharfe (4): strbuf: add strbuf_getcwd() use strbuf_getcwd() to get the current working directory without fixed-sized buffers wrapper: add xgetcwd() use xgetcwd() get the current directory or die Documentation/technical/api-strbuf.txt | 4 builtin

[PATCH v2 1/4] strbuf: add strbuf_getcwd()

2014-07-20 Thread René Scharfe
Add strbuf_getcwd(), which puts the current working directory intto a strbuf. Because it doesn't use a fixed-size buffer it supports arbitrarily long paths, as long as the platform's getcwd() does as well. At least on Linux and FreeBSD it handles paths longer than PATH_MAX just fine.

[PATCH v2 2/4] use strbuf_getcwd() to get the current working directory without fixed-sized buffers

2014-07-20 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- builtin/init-db.c | 8 git.c | 6 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/builtin/init-db.c b/builtin/init-db.c index 56f85e2..c4958b6 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -535,10

[PATCH v2 3/4] wrapper: add xgetcwd()

2014-07-20 Thread René Scharfe
Add the helper function xgetcwd(), which returns the current directory or dies. The returned string has to be free()d after use. Helped-by: Duy Nguyen pclo...@gmail.com Signed-off-by: Rene Scharfe l@web.de --- git-compat-util.h | 1 + wrapper.c | 8 2 files changed, 9

[PATCH v2 4/4] use xgetcwd() get the current directory or die

2014-07-20 Thread René Scharfe
Convert several calls of getcwd() and die() to use xgetcwd() instead. This way we get rid of fixed-size buffers (which can be too small depending on the used file system) and gain consistent error messages. Signed-off-by: Rene Scharfe l@web.de --- builtin/init-db.c | 17 -

Re: [PATCH v2 2/4] use strbuf_getcwd() to get the current working directory without fixed-sized buffers

2014-07-21 Thread René Scharfe
Am 21.07.2014 04:33, schrieb Jeff King: On Sun, Jul 20, 2014 at 06:49:54PM +0200, René Scharfe wrote: diff --git a/builtin/init-db.c b/builtin/init-db.c index 56f85e2..c4958b6 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -535,10 +535,10 @@ int cmd_init_db(int argc, const char

Re: Bug in get_pwd_cwd() in Windows?

2014-07-22 Thread René Scharfe
Am 21.07.2014 16:13, schrieb Duy Nguyen: This function tests if $PWD is the same as getcwd() using st_dev and st_ino. But on Windows these fields are always zero (mingw.c:do_lstat). If cwd is moved away, I think falling back to $PWD is wrong. I don't understand the use of $PWD in the first

[PATCH v3 0/10] getcwd without PATH_MAX

2014-07-28 Thread René Scharfe
to handle longer working directory paths. Changes in v3: * all getcwd() calls are converted * the two strbuf_getcwd() examples from last round use xgetcwd() now, as suggested by Jeff * strbuf_add_absolute_path() is introduced René Scharfe (10): strbuf: add strbuf_getcwd() unix-sockets: use

[PATCH v3 01/10] strbuf: add strbuf_getcwd()

2014-07-28 Thread René Scharfe
Add strbuf_getcwd(), which puts the current working directory into a strbuf. Because it doesn't use a fixed-size buffer it supports arbitrarily long paths, provided the platform's getcwd() does as well. At least on Linux and FreeBSD it handles paths longer than PATH_MAX just fine. Suggested-by:

[PATCH v3 02/10] unix-sockets: use strbuf_getcwd()

2014-07-28 Thread René Scharfe
Instead of using a PATH_MAX-sized buffer, which can be too small on some file systems, use strbuf_getcwd(), which handles any path getcwd() returns. Also preserve the errno set by strbuf_getcwd() instead of setting it to ENAMETOOLONG; that way a more appropriate error message can be shown based

[PATCH v3 03/10] setup: convert setup_git_directory_gently_1 et al. to strbuf

2014-07-28 Thread René Scharfe
Convert setup_git_directory_gently_1() and its helper functions setup_explicit_git_dir(), setup_discovered_git_dir() and setup_bare_git_dir() to use a struct strbuf to hold the current working directory. Replacing the PATH_MAX-sized buffer used before removes a path length limition on some file

[PATCH 04/10] abspath: use strbuf_getcwd() to remember original working directory

2014-07-28 Thread René Scharfe
Store the original working directory in a strbuf instead of in a fixed-sized buffer, in order to be able to handle longer paths. Signed-off-by: Rene Scharfe l@web.de --- abspath.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/abspath.c b/abspath.c index

[PATCH v3 06/10] wrapper: add xgetcwd()

2014-07-28 Thread René Scharfe
Add the helper function xgetcwd(), which returns the current directory or dies. The returned string has to be free()d after use. Helped-by: Duy Nguyen pclo...@gmail.com Signed-off-by: Rene Scharfe l@web.de --- git-compat-util.h | 1 + wrapper.c | 8 2 files changed, 9

[PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread René Scharfe
Use strbuf instead of fixed-sized buffers in real_path() in order to avoid the size limitations of the latter. Signed-off-by: Rene Scharfe l@web.de --- abspath.c | 69 +++ 1 file changed, 25 insertions(+), 44 deletions(-) diff

[PATCH v3 07/10] use xgetcwd() to get the current directory or die

2014-07-28 Thread René Scharfe
Convert several calls of getcwd() and die() to use xgetcwd() instead. This way we get rid of fixed-size buffers (which can be too small depending on the used file system) and gain consistent error messages. Signed-off-by: Rene Scharfe l@web.de --- builtin/init-db.c | 17 -

[PATCH v3 08/10] use xgetcwd() to set $GIT_DIR

2014-07-28 Thread René Scharfe
Instead of dying of a segmentation fault if getcwd() returns NULL, use xgetcwd() to make sure to write a useful error message and then exit in an orderly fashion. Suggested-by: Jeff King p...@peff.net Signed-off-by: Rene Scharfe l@web.de --- builtin/init-db.c | 7 +++ git.c |

[PATCH v3 09/10] abspath: convert absolute_path() to strbuf

2014-07-28 Thread René Scharfe
Move most of the code of absolute_path() into the new function strbuf_add_absolute_path() and in the process transform it to use struct strbuf and xgetcwd() instead of a PATH_MAX-sized buffer, which can be too small on some file systems. Signed-off-by: Rene Scharfe l@web.de ---

[PATCH v3 10/10] use strbuf_add_absolute_path() to add absolute paths

2014-07-28 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- exec_cmd.c | 6 +- sha1_file.c | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/exec_cmd.c b/exec_cmd.c index 125fa6f..698e752 100644 --- a/exec_cmd.c +++ b/exec_cmd.c @@ -86,11 +86,7 @@ const char *git_exec_path(void)

[PATCH v3 04/10] abspath: use strbuf_getcwd() to remember original working directory

2014-07-28 Thread René Scharfe
Store the original working directory in a strbuf instead of in a fixed-sized buffer, in order to be able to handle longer paths. Signed-off-by: Rene Scharfe l@web.de --- Resent with corrected subject. abspath.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git

[PATCH] init: avoid superfluous real_path() calls

2014-07-28 Thread René Scharfe
Feeding the result of a real_path() call to real_path() again doesn't change that result -- the returned path won't get any more real. Avoid such a double call in set_git_dir_init() and for the same reason stop calling real_path() before feeding paths to set_git_work_tree(), as the latter already

Re: [PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread René Scharfe
Am 28.07.2014 um 21:09 schrieb Jeff King: On Mon, Jul 28, 2014 at 08:28:30PM +0200, René Scharfe wrote: static const char *real_path_internal(const char *path, int die_on_error) { - static char bufs[2][PATH_MAX + 1], *buf = bufs[0], *next_buf = bufs[1]; + static struct strbuf

Re: [PATCH v3 09/10] abspath: convert absolute_path() to strbuf

2014-07-28 Thread René Scharfe
Am 28.07.2014 um 21:15 schrieb Jeff King: On Mon, Jul 28, 2014 at 08:33:55PM +0200, René Scharfe wrote: const char *absolute_path(const char *path) { - static char buf[PATH_MAX + 1]; - - if (!*path) { - die(The empty string is not a valid path); - } else

Re: [PATCH v3 05/10] abspath: convert real_path_internal() to strbuf

2014-07-28 Thread René Scharfe
Am 28.07.2014 um 23:42 schrieb Junio C Hamano: Jeff King p...@peff.net writes: On Mon, Jul 28, 2014 at 08:28:30PM +0200, René Scharfe wrote: @@ -60,26 +58,22 @@ static const char *real_path_internal(const char *path, int die_on_error) goto error_out

fixup for 09/10: plug leak

2014-07-28 Thread René Scharfe
Noticed-by: Jeff King p...@peff.net --- abspath.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/abspath.c b/abspath.c index cf9b404..5edb4e7 100644 --- a/abspath.c +++ b/abspath.c @@ -146,8 +146,8 @@ const char *real_path_if_valid(const char *path) */ const char

fixup for 05/10: plug leak

2014-07-28 Thread René Scharfe
Noticed-by: Jeff King p...@peff.net --- abspath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abspath.c b/abspath.c index 16e7fa2..6aa328f 100644 --- a/abspath.c +++ b/abspath.c @@ -58,7 +58,7 @@ static const char *real_path_internal(const char *path, int die_on_error)

Re: Bug report about symlinks

2014-07-31 Thread René Scharfe
Am 31.07.2014 um 21:50 schrieb Nikolay Avdeev: I've noticed something strange with git status when replacing a folder with symlink to another folder. There is a git repo with script with demo in the attachment. Let's try and make this a bit easier for folks to follow along. # Create test repo

Re: Bug report about symlinks

2014-08-02 Thread René Scharfe
Am 01.08.2014 um 18:23 schrieb Junio C Hamano: René Scharfe l@web.de writes: # Create test repo with two directories with two files each. $ git init Initialized empty Git repository in /tmp/.git/ $ mkdir a b $ echo x a/equal $ echo x b/equal $ echo y a/different $ echo z b/different

Re: Bug report about symlinks

2014-08-03 Thread René Scharfe
Am 03.08.2014 um 19:19 schrieb Junio C Hamano: René Scharfe l@web.de writes: How about the patch below? Before it checks if an index entry exists in the work tree, it checks if its path includes a symlink. Honestly, I didn't expect the fix to be in the refresh-index code path, but doing

[PATCH] use labs() for variables of type long instead of abs()

2014-11-15 Thread René Scharfe
Using abs() on long values can cause truncation, so use labs() instead. Reported by Clang 3.5 (-Wabsolute-value, enabled by -Wall). Signed-off-by: Rene Scharfe l@web.de --- builtin/receive-pack.c | 2 +- config.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff

[PATCH] use strbuf_complete_line() for adding a newline if needed

2014-12-12 Thread René Scharfe
Call strbuf_complete_line() instead of open-coding it. Also remove surrounding comments indicating the intent to complete a line since this information is already included in the function name. Signed-off-by: Rene Scharfe l@web.de --- builtin/fmt-merge-msg.c | 3 +-- notes-utils.c

[PATCH] merge: release strbuf after use in suggest_conflicts()

2014-12-23 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- builtin/merge.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/merge.c b/builtin/merge.c index 215d485..d722889 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -894,6 +894,7 @@ static int suggest_conflicts(void)

[PATCH] commit-tree: simplify parsing of option -S using skip_prefix()

2014-12-23 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- builtin/commit-tree.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c index 8a66c74..25aa2cd 100644 --- a/builtin/commit-tree.c +++ b/builtin/commit-tree.c @@ -66,10 +66,8 @@ int

[PATCH] transport: simplify duplicating a substring in transport_get() using xmemdupz()

2014-12-23 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- transport.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/transport.c b/transport.c index 70d38e4..08bcd3a 100644 --- a/transport.c +++ b/transport.c @@ -971,9 +971,7 @@ struct transport *transport_get(struct remote *remote,

[PATCH] refs: release strbuf after use in check_refname_component()

2014-12-23 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- refs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 5fcacc6..ed3b2cb 100644 --- a/refs.c +++ b/refs.c @@ -2334,7 +2334,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname,

Re: [PATCH] .clang-format: introduce the use of clang-format

2015-01-18 Thread René Scharfe
Am 17.01.2015 um 22:30 schrieb Ramkumar Ramachandra: Instead of manually eyeballing style in reviews, just ask all contributors to run their patches through [git-]clang-format. Signed-off-by: Ramkumar Ramachandra artag...@gmail.com --- The idea is to introduce the community to this new toy I

[PATCH 1/2] daemon: look up client-supplied hostname lazily

2015-02-15 Thread René Scharfe
Look up canonical hostname and IP address using getaddrinfo(3) or gethostbyname(3) only if --interpolated-path or --access-hook were specified. Do that by introducing getter functions for canon_hostname and ip_address and using them for all read accesses. These wrappers call the new helper

Re: [PATCH 1/2] remote: Remove -v/--verbose option from git remote show synopsis

2015-01-08 Thread René Scharfe
Am 08.01.2015 um 18:57 schrieb Alexander Kuleshov: git remote show doesn't use -v/--verbose option Hmm, but it does? $ git version git version 2.2.1 $ git remote show origin $ git remote -v show origin git://git.kernel.org/pub/scm/git/git.git

Re: [PATCH] daemon: use strbuf for hostname info

2015-03-06 Thread René Scharfe
Am 06.03.2015 um 22:06 schrieb Jeff King: On Fri, Mar 06, 2015 at 09:57:22AM +0100, René Scharfe wrote: if (port) { - free(tcp_port); - tcp_port = sanitize_client(port

Re: [PATCH] daemon: use strbuf for hostname info

2015-03-06 Thread René Scharfe
Am 06.03.2015 um 22:06 schrieb Jeff King: On Fri, Mar 06, 2015 at 09:57:22AM +0100, René Scharfe wrote: Convert hostname, canon_hostname, ip_address and tcp_port to strbuf. This allows to get rid of the helpers strbuf_addstr_or_null() and STRARG because a strbuf always represents a valid

[PATCH] use isxdigit() for checking if a character is a hexadecimal digit

2015-03-09 Thread René Scharfe
Use the standard function isxdigit() to make the intent clearer and avoid using magic constants. Signed-off-by: Rene Scharfe l@web.de --- sha1_name.c | 2 +- transport.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 95f9f8f..6d10f05

[PATCH] zlib: initialize git_zstream in git_deflate_init{,_gzip,_raw}

2015-03-05 Thread René Scharfe
Clear the git_zstream variable at the start of git_deflate_init() etc. so that callers don't have to do that. Signed-off-by: Rene Scharfe l@web.de --- archive-zip.c | 2 -- builtin/index-pack.c | 1 - builtin/pack-objects.c | 2 -- bulk-checkin.c | 1 - diff.c

Re: [PATCH] [GSoC][MICRO] Forbid log --graph --no-walk

2015-03-06 Thread René Scharfe
Am 06.03.2015 um 09:55 schrieb Dongcan Jiang: Because --graph is about connected history while --no-walk is about discrete points. revision.c: Judge whether --graph and --no-walk come together when running git-log. buildin/log.c: Set git-log cmd flag. Documentation/rev-list-options.txt: Add

[PATCH] daemon: use strbuf for hostname info

2015-03-06 Thread René Scharfe
Convert hostname, canon_hostname, ip_address and tcp_port to strbuf. This allows to get rid of the helpers strbuf_addstr_or_null() and STRARG because a strbuf always represents a valid (initially empty) string. sanitize_client() becomes unused and is removed as well. Signed-off-by: Rene Scharfe

Re: [PATCH] daemon: use strbuf for hostname info

2015-03-07 Thread René Scharfe
Am 07.03.2015 um 02:08 schrieb Jeff King: On Sat, Mar 07, 2015 at 01:20:22AM +0100, René Scharfe wrote: Not a big deal, but do we want to rename sanitize_client_strbuf to sanitize_client? It only had the unwieldy name to distinguish it from this one. A patch would look like this. The result

[PATCH v2 1/2] daemon: use strbuf for hostname info

2015-03-07 Thread René Scharfe
Convert hostname, canon_hostname, ip_address and tcp_port to strbuf. This allows to get rid of the helpers strbuf_addstr_or_null() and STRARG because a strbuf always represents a valid (initially empty) string. sanitize_client() is not needed anymore and sanitize_client_strbuf() takes its place

[PATCH v2 2/2] daemon: deglobalize hostname information

2015-03-07 Thread René Scharfe
Move the variables related to the client-supplied hostname into its own struct, let execute() own an instance of that instead of storing the information in global variables and pass the struct to any function that needs to access it as a parameter. The lifetime of the variables is easier to see

Re: [PATCH 00/14] numparse module: systematically tighten up integer parsing

2015-03-24 Thread René Scharfe
Am 24.03.2015 um 17:06 schrieb Michael Haggerty: Parsing numbers is not rocket science, but there are a lot of pitfalls, especially around overflow. It's even harder to write such code via macros and the result is less readable. This patch series is mostly about finding a reasonable API and

[PATCH] archive-zip: add --text parameter

2015-03-04 Thread René Scharfe
Entries in a ZIP file can be marked as text files. Extractors can use that flag to apply end-of-line conversions. An example is unzip -a. git archive currently marks all ZIP file entries as binary files. This patch adds the new option --text that can be used to mark non-binary files or all

Re: zip files created with git archive flags text files as binaries

2015-03-04 Thread René Scharfe
Am 23.02.2015 um 20:30 schrieb René Scharfe: Am 23.02.2015 um 14:58 schrieb Ulrike Fischer: The zip contained four text files and a pdf. The CTAN maintainers informed me that all files in the zip are flagged as binaries and this makes it difficult for them to process them further (they want

Re: [PATCH] archive-zip: add --text parameter

2015-03-05 Thread René Scharfe
Am 04.03.2015 um 22:13 schrieb René Scharfe: diff --git a/archive-zip.c b/archive-zip.c index 4bde019..3767940 100644 --- a/archive-zip.c +++ b/archive-zip.c @@ -5,6 +5,7 @@ #include archive.h #include streaming.h #include utf8.h +#include xdiff-interface.h static int zip_date; static

Re: [PATCH] archive-zip: add --text parameter

2015-03-05 Thread René Scharfe
Am 05.03.2015 um 03:16 schrieb Junio C Hamano: René Scharfe l@web.de writes: No sign-off, yet, because I'm not sure we really need another option. E.g. --text=all doesn't seem to be actually useful, but it was easy to implement. Info-ZIP's zip always creates archives like --text=auto does

[PATCH v2] archive-zip: mark text files in archives

2015-03-05 Thread René Scharfe
Set the text flag for ZIP archive entries that look like text files so that unzip -a can be used to perform end-of-line conversions. Info-ZIP zip does the same. Detect binary files the same way as git diff and git grep do, namely by checking for the attribute diff and its negation -diff, and if

Re: zip files created with git archive flags text files as binaries

2015-02-23 Thread René Scharfe
Am 23.02.2015 um 14:58 schrieb Ulrike Fischer: I'm using git on windows 7. $ git --version git version 1.9.4.msysgit.0 Git's code for ZIP file creation hasn't changed since then. Some days ago I uploaded a latex package to CTAN (www.ctan.org). I created the zip-file with git archive

Re: [PATCH] sha1_name: use strlcpy() to copy strings

2015-02-22 Thread René Scharfe
Am 22.02.2015 um 21:00 schrieb Junio C Hamano: René Scharfe l@web.de writes: Use strlcpy() instead of calling strncpy() and then setting the last byte of the target buffer to NUL explicitly. This shortens and simplifies the code a bit. Thanks. It makes me wonder if the longer term

Re: Copyright on wildmatch.c

2015-02-24 Thread René Scharfe
Am 24.02.2015 um 13:34 schrieb Guilherme: This is just an email to all the people i have written in private about relicensing the files in need in TSS so they can reply to this email and it be recorded in the mailing list. The files are part of ctypes.c hex.c git-compat-util.h. On Tue, Feb 24,

[PATCH] for-each-ref: use skip_prefix() to avoid duplicate string comparison

2015-02-21 Thread René Scharfe
Use skip_prefix() to get the part after color: (if present) and only compare it with reset instead of comparing the whole string again. This gets rid of the duplicate color: part of the string constant. Signed-off-by: Rene Scharfe l@web.de --- builtin/for-each-ref.c | 7 +++ 1 file

[PATCH] pretty: use starts_with() to check for a prefix

2015-02-21 Thread René Scharfe
Simplify the code and avoid duplication by using starts_with() instead of strlen() and strncmp() to check if a line starts with encoding . Signed-off-by: Rene Scharfe l@web.de --- pretty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pretty.c b/pretty.c index

[PATCH] sha1_name: use strlcpy() to copy strings

2015-02-21 Thread René Scharfe
Use strlcpy() instead of calling strncpy() and then setting the last byte of the target buffer to NUL explicitly. This shortens and simplifies the code a bit. Signed-of-by: Rene Scharfe l@web.de --- sha1_name.c | 8 ++-- 1 file changed, 2 insertions(+), 6 deletions(-) diff --git

[PATCH] connect: use strcmp() for string comparison

2015-02-21 Thread René Scharfe
Get rid of magic string length constants and simply compare the strings using strcmp(). This makes the intent of the code a bit clearer. Signed-off-by: Rene Scharfe l@web.de --- connect.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/connect.c b/connect.c index

Re: [PATCH] git-gui: sort entries in tclIndex

2015-04-25 Thread René Scharfe
Looping in Pat (git-gui maintainer). Am 15.04.2015 um 09:22 schrieb Olaf Hering: Ping? On Tue, Feb 10, Olaf Hering wrote: Ping? On Mon, Jan 26, Olaf Hering wrote: ALL_LIBFILES uses wildcard, which provides the result in directory order. This order depends on the underlying filesystem on

Re: [PATCH 0/6] address packed-refs speed regressions

2015-04-05 Thread René Scharfe
Am 05.04.2015 um 20:52 schrieb Jeff King: On Sun, Apr 05, 2015 at 03:41:39PM +0200, René Scharfe wrote: I wonder if pluggable reference backends could help here. Storing refs in a database table indexed by refname should simplify things. ...this. I think that effort might be better spent

Re: [PATCH 0/6] address packed-refs speed regressions

2015-04-05 Thread René Scharfe
Am 05.04.2015 um 20:59 schrieb Jeff King: Still, the numbers are promising. Here's are comparisons against for-each-ref on torvalds/linux, which has a 218M packed-refs file: $ time git for-each-ref \ --format='%(objectname) %(refname)' \ refs/remotes/2325298/ | wc -c

Re: [PATCH 0/6] address packed-refs speed regressions

2015-04-05 Thread René Scharfe
Am 05.04.2015 um 03:06 schrieb Jeff King: As I've mentioned before, I have some repositories with rather large numbers of refs. The worst one has ~13 million refs, for a 1.6GB packed-refs file. So I was saddened by this: $ time git.v2.0.0 rev-parse refs/heads/foo /dev/null 21 real

[PATCH] use file_exists() to check if a file exists in the worktree

2015-05-19 Thread René Scharfe
Call file_exists() instead of open-coding it. That's shorter, simpler and the intent becomes clearer. Signed-off-by: Rene Scharfe l@web.de --- builtin/blame.c | 15 +++ builtin/rm.c | 3 +-- merge-recursive.c | 3 +-- sha1_name.c | 7 +++ submodule.c |

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

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

Re: [PATCH v3 0/4] submodule config lookup API

2015-05-21 Thread René Scharfe
Am 21.05.2015 um 19:06 schrieb Heiko Voigt: diff --git a/submodule-config.h b/submodule-config.h index 9061e4e..58afc83 100644 --- a/submodule-config.h +++ b/submodule-config.h @@ -24,6 +24,6 @@ const struct submodule *submodule_from_name(const unsigned char *commit_sha1, const

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

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

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

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

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

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

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

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

Eric Sunshine mail delivery failure

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

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

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

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

[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

[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

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 <gits...@pobox.com> wrote: René Scharfe <l@web.de> writes: Avoid duplication by moving the code to release allocated memory for arguments and environment to its own function, child_p

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 <l@web.de> 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 <l@web.de> --- builtin/fmt-merg

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 <l@web.de> 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

[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

[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(-)

[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

[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

[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

[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

[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

[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

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

[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

[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

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

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 <kmcgui...@twitter.com> During merges, we would previously free entries that we no longer need in the destination

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

Re: [PATCH] p5310: mend broken -chain

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

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

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

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