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

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

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

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

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

[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

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

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

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

[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] 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] run-command: use void to declare that functions take no parameters

2014-11-10 Thread René Scharfe
Explicitly declare that git_atexit_dispatch() and git_atexit_clear() take no parameters instead of leaving their parameter list empty and thus unspecified. Signed-off-by: Rene Scharfe l@web.de --- run-command.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git

Re: [PATCH] use child_process_init() to initialize struct child_process variables

2014-11-09 Thread René Scharfe
Am 29.10.2014 um 18:21 schrieb Jeff King: On Tue, Oct 28, 2014 at 09:52:34PM +0100, René Scharfe wrote: diff --git a/trailer.c b/trailer.c index 8514566..7ff036c 100644 --- a/trailer.c +++ b/trailer.c @@ -237,7 +237,7 @@ static const char *apply_command(const char *command, const char *arg

Re: [PATCH 2/2] use env_array member of struct child_process

2014-11-09 Thread René Scharfe
Am 20.10.2014 um 11:19 schrieb Jeff King: On Sun, Oct 19, 2014 at 01:14:20PM +0200, René Scharfe wrote: --- a/wt-status.c +++ b/wt-status.c @@ -726,14 +726,14 @@ static void wt_status_print_changed(struct wt_status *s) static void wt_status_print_submodule_summary(struct wt_status *s

Re: [PATCH][RFC] grep: add color.grep.matchcontext and color.grep.matchselected

2014-10-28 Thread René Scharfe
Am 28.10.2014 um 00:32 schrieb Zoltan Klinger: I like René's approach, too. It's more flexible, supports the old behaviour and it scratches my itch as well. Don't mind if you dropped my patch and used René's instead. Good. :) And here's the t/ part of your patch, slightly changed to exercise

[PATCH] receive-pack: avoid minor leak in case start_async() fails

2014-10-28 Thread René Scharfe
If the asynchronous start of copy_to_sideband() fails, then any env_array entries added to struct child_process proc by prepare_push_cert_sha1() are leaked. Call the latter function only after start_async() succeeded so that the allocated entries are cleaned up automatically by start_command() or

[PATCH] use child_process_init() to initialize struct child_process variables

2014-10-28 Thread René Scharfe
Call child_process_init() instead of zeroing the memory of variables of type struct child_process by hand before use because the former is both clearer and shorter. Signed-off-by: Rene Scharfe l@web.de --- bundle.c | 2 +- column.c | 2 +- trailer.c | 2 +-

[PATCH] api-run-command: add missing list item marker

2014-10-28 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- Documentation/technical/api-run-command.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt index 3f12fcd..a9fdb45 100644 ---

[PATCH][RFC] grep: add color.grep.matchcontext and color.grep.matchselected

2014-10-27 Thread René Scharfe
The config option color.grep.match can be used to specify the highlighting color for matching strings. Add the options matchContext and matchSelected to allow different colors to be specified for matching strings in the context vs. in selected lines. This is similar to the ms and mc specifiers

Re: [PATCH] grep: fix match highlighting for combined patterns with context lines

2014-10-26 Thread René Scharfe
Am 21.10.2014 um 07:56 schrieb Zoltan Klinger: When git grep is run with combined patterns such as '-e p1 --and -e p2' and surrounding context lines are requested, the output contains incorrectly highlighted matches. Consider the following output (highlighted matches are surrounded by '*'

Re: Sources for 3.18-rc1 not uploaded

2014-10-26 Thread René Scharfe
Am 23.10.2014 um 03:09 schrieb brian m. carlson: On Wed, Oct 22, 2014 at 11:42:48AM +0200, Michael J Gruber wrote: Junio C Hamano schrieb am 21.10.2014 um 20:14: Michael J Gruber g...@drmicha.warpmail.net writes: Unfortunately, the git archive doc clearly says that the umask is applied to

[PATCH 1/2] run-command: add env_array, an optional argv_array for env

2014-10-19 Thread René Scharfe
Similar to args, add a struct argv_array member to struct child_process that simplifies specifying the environment for children. It is freed automatically by finish_command() or if start_command() encounters an error. Suggested-by: Jeff King p...@peff.net Signed-off-by: Rene Scharfe l@web.de

Re: [PATCH] receive-pack: plug minor memory leak in unpack()

2014-10-19 Thread René Scharfe
Am 14.10.2014 um 11:16 schrieb Jeff King: On Mon, Oct 13, 2014 at 12:08:09PM -0700, Junio C Hamano wrote: I wonder if run-command should provide a managed env array similar to the args array. That's a good idea. I took a look at a few of them: I took a brief look, too. I had hoped we

[PATCH 2/2] use env_array member of struct child_process

2014-10-19 Thread René Scharfe
Convert users of struct child_process to using the managed env_array for specifying environment variables instead of supplying an array on the stack or bringing their own argv_array. This shortens and simplifies the code and ensures automatically that the allocated memory is freed after use.

[PATCH] receive-pack: plug minor memory leak in unpack()

2014-10-11 Thread René Scharfe
The argv_array used in unpack() is never freed. Instead of adding explicit calls to argv_array_clear() use the args member of struct child_process and let run_command() and friends clean up for us. Signed-off-by: Rene Scharfe l@web.de --- builtin/receive-pack.c | 18 -- 1

Re: [PATCH] use skip_prefix() to avoid more magic numbers

2014-10-09 Thread René Scharfe
Am 07.10.2014 um 20:23 schrieb Junio C Hamano: René Scharfe l@web.de writes: @@ -335,20 +337,18 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags, static struct { int kind; const char *prefix; -int pfxlen

Re: [PATCH 12/16] sha1_file: add for_each iterators for loose and packed objects

2014-10-05 Thread René Scharfe
Am 03.10.2014 um 22:32 schrieb Jeff King: We typically iterate over the reachable objects in a repository by starting at the tips and walking the graph. There's no easy way to iterate over all of the objects, including unreachable ones. Let's provide a way of doing so. Signed-off-by: Jeff King

Re: [PATCH 16/16] write_sha1_file: freshen existing objects

2014-10-05 Thread René Scharfe
Am 03.10.2014 um 22:41 schrieb Jeff King: When we try to write a loose object file, we first check whether that object already exists. If so, we skip the write as an optimization. However, this can interfere with prune's strategy of using mtimes to mark files in progress. For example, if a

Re: [PATCH 0/16] make prune mtime-checking more careful

2014-10-05 Thread René Scharfe
Am 05.10.2014 um 00:22 schrieb Junio C Hamano: Jeff King p...@peff.net writes: There's quite a lot of patches here, but most of them are preparatory cleanups. The meat is in patches 13, 15, and 16. [01/16]: foreach_alt_odb: propagate return value from callback [02/16]: isxdigit: cast

[PATCH] mailsplit: remove unnecessary unlink(2) call

2014-10-04 Thread René Scharfe
The output file hasn't been created at this point, yet, so there is no need to delete it when exiting early. Suggested-by: Jeff King p...@peff.net Signed-off-by: Rene Scharfe l@web.de --- Original thread: http://thread.gmane.org/gmane.comp.version-control.git/255140 builtin/mailsplit.c | 1

[PATCH] use skip_prefix() to avoid more magic numbers

2014-10-04 Thread René Scharfe
Continue where ae021d87 (use skip_prefix to avoid magic numbers) left off and use skip_prefix() in more places for determining the lengths of prefix strings to avoid using dependent constants and other indirect methods. Signed-off-by: Rene Scharfe l@web.de --- builtin/apply.c |

[PATCH] bundle: plug minor memory leak in is_tag_in_date_range()

2014-10-03 Thread René Scharfe
Free the buffer returned by read_sha1_file() even if no valid tagger line is found. Signed-off-by: Rene Scharfe l@web.de --- bundle.c | 16 ++-- 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bundle.c b/bundle.c index b2b89fe..9ed865c 100644 --- a/bundle.c +++

Re: [PATCH 01/16] foreach_alt_odb: propagate return value from callback

2014-10-03 Thread René Scharfe
Am 03.10.2014 um 22:21 schrieb Jeff King: We check the return value of the callback and stop iterating if it is non-zero. However, we do not make the non-zero return value available to the caller, so they have no way of knowing whether the operation succeeded or not (technically they can keep

[PATCH 1/2] sha1-array: add test-sha1-array and basic tests

2014-10-01 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- .gitignore| 1 + Makefile | 1 + t/t0064-sha1-array.sh | 64 +++ test-sha1-array.c | 34 +++ 4 files changed, 100 insertions(+) create mode 100755

[PATCH 2/2] sha1-lookup: fix handling of duplicates in sha1_pos()

2014-10-01 Thread René Scharfe
If the first 18 bytes of the SHA1's of all entries are the same then sha1_pos() dies and reports that the lower and upper limits of the binary search were the same that this wasn't supposed to happen. This is wrong because the remaining two bytes could still differ. Furthermore: It wouldn't be a

[PATCH 1/3] daemon: handle gethostbyname() error

2014-10-01 Thread René Scharfe
If the user-supplied hostname can't be found then we should not use it. We already avoid doing that in the non-NO_IPV6 case by checking if the return value of getaddrinfo() is zero (success). Do the same in the NO_IPV6 case and make sure the return value of gethostbyname() isn't NULL before

[PATCH 2/3] daemon: fix error message after bind()

2014-10-01 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon.c b/daemon.c index a6f467e..090f6a4 100644 --- a/daemon.c +++ b/daemon.c @@ -924,7 +924,7 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct

[PATCH 3/3] daemon: remove write-only variable maxfd

2014-10-01 Thread René Scharfe
It became unused when 6573faff (NO_IPV6 support for git daemon) replaced select() with poll(). Signed-off-by: Rene Scharfe l@web.de --- daemon.c | 4 1 file changed, 4 deletions(-) diff --git a/daemon.c b/daemon.c index 090f6a4..54a03bd 100644 --- a/daemon.c +++ b/daemon.c @@ -815,7

Re: [PATCH 2/2] sha1-lookup: fix handling of duplicates in sha1_pos()

2014-10-01 Thread René Scharfe
Am 01.10.2014 um 12:50 schrieb Jeff King: On Wed, Oct 01, 2014 at 11:43:21AM +0200, René Scharfe wrote: If the first 18 bytes of the SHA1's of all entries are the same then sha1_pos() dies and reports that the lower and upper limits of the binary search were the same that this wasn't supposed

Re: [PATCH v7 09/38] lock_file(): always initialize and register lock_file object

2014-10-01 Thread René Scharfe
Am 01.10.2014 um 12:28 schrieb Michael Haggerty: The purpose of this patch is to make the state diagram for lock_file objects simpler and deterministic. If locking fails, lock_file() sometimes leaves the lock_file object partly initialized, but sometimes not. It sometimes registers the object

Re: [PATCH 1/2] sha1-array: add test-sha1-array and basic tests

2014-10-01 Thread René Scharfe
Am 01.10.2014 um 16:11 schrieb Eric Sunshine: On Wed, Oct 1, 2014 at 5:40 AM, René Scharfe l@web.de wrote: Signed-off-by: Rene Scharfe l@web.de --- diff --git a/t/t0064-sha1-array.sh b/t/t0064-sha1-array.sh new file mode 100755 index 000..bd68789 --- /dev/null +++ b/t/t0064-sha1

[PATCH v2 1/2] sha1-array: add test-sha1-array and basic tests

2014-10-01 Thread René Scharfe
Helped-by: Jeff King p...@peff.net Helped-by: Eric Sunshine sunsh...@sunshineco.com Signed-off-by: Rene Scharfe l@web.de --- Added a test for looking up a non-existing entry in an array that contains duplicates, as suggested by Jeff. Changed echo20() to add a space after the prefix as needed,

[PATCH v2 2/2] sha1-lookup: handle duplicates in sha1_pos()

2014-10-01 Thread René Scharfe
If the first 18 bytes of the SHA1's of all entries are the same then sha1_pos() dies and reports that the lower and upper limits of the binary search were the same that this wasn't supposed to happen. This is wrong because the remaining two bytes could still differ. Furthermore: It wouldn't be a

[PATCH] t0090: avoid passing empty string to printf %d

2014-09-30 Thread René Scharfe
FreeBSD's printf(1) doesn't accept empty strings for numerical format specifiers: $ printf %d\n /dev/null; echo $? printf: : expected numeric value 1 Initialize the AWK variable c to make sure the shell variable subtree_count always contains a numerical value, in order

Re: [PATCH 1/2] add macro REALLOC_ARRAY

2014-09-24 Thread René Scharfe
Am 24.09.2014 um 09:32 schrieb Michael Haggerty: Is there a reason that ALLOC_GROW and REALLOC_ARRAY are defined in two separate header files (cache.h and git-compat-util.h, respectively)? It seems to me that they are close siblings and therefore I find it surprising that they are not defined

Re: [PATCH 2/2] use REALLOC_ARRAY for changing the allocation size of arrays

2014-09-24 Thread René Scharfe
Am 24.09.2014 um 20:47 schrieb Jonathan Nieder: René Scharfe wrote: --- a/khash.h +++ b/khash.h (not really about this patch) Where did this file come from? Do we want to be able to sync with upstream to get later bugfixes (e.g., https://github.com/attractivechaos/klib/commit/000f0890

[PATCH] remote: simplify match_name_with_pattern() using strbuf

2014-09-21 Thread René Scharfe
Make the code simpler and shorter by avoiding repetitive use of string length variables and leaving memory allocation to strbuf functions. Signed-off-by: Rene Scharfe l@web.de --- remote.c | 17 + 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/remote.c

[PATCH 1/2] graph: simplify graph_padding_line()

2014-09-20 Thread René Scharfe
Deduplicate code common to both branches of if statements. Signed-off-by: Rene Scharfe l@web.de --- graph.c | 17 - 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/graph.c b/graph.c index dfb99f6..52605e4 100644 --- a/graph.c +++ b/graph.c @@ -1161,20 +1161,11

Re: [PATCH 1/2] graph: simplify graph_padding_line()

2014-09-20 Thread René Scharfe
Am 20.09.2014 um 20:29 schrieb René Scharfe: Deduplicate code common to both branches of if statements. There is no 2/2, this patch is the only one at this time. René -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More

Re: [PATCH 1/2] add macro REALLOCARRAY

2014-09-16 Thread René Scharfe
Am 16.09.2014 um 05:04 schrieb Junio C Hamano: On Sun, Sep 14, 2014 at 9:55 AM, René Scharfe l@web.de wrote: +#define REALLOCARRAY(x, alloc) x = xrealloc((x), (alloc) * sizeof(*(x))) I have been wondering if x could be an expression that has an operator that binds weaker than

[PATCH 1/2] add macro REALLOC_ARRAY

2014-09-16 Thread René Scharfe
The macro ALLOC_GROW manages several aspects of dynamic memory allocations for arrays: It performs overprovisioning in order to avoid reallocations in future calls, updates the allocation size variable, multiplies the item size and thus allows users to simply specify the item count, performs the

[PATCH 2/2] use REALLOC_ARRAY for changing the allocation size of arrays

2014-09-16 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- attr.c | 3 +-- builtin/apply.c| 2 +- builtin/for-each-ref.c | 9 +++-- builtin/index-pack.c | 4 +--- builtin/log.c | 2 +- builtin/merge.c| 2 +- builtin/mv.c | 8

[PATCH 1/2] add macro REALLOCARRAY

2014-09-14 Thread René Scharfe
The macro ALLOC_GROW manages several aspects of dynamic memory allocations for arrays: It performs overprovisioning in order to avoid reallocations in future calls, updates the allocation size variable, multiplies the item size and thus allows users to simply specify the item count, performs the

[PATCH 2/2] use REALLOCARRAY for changing the allocation size of arrays

2014-09-14 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- attr.c | 3 +-- builtin/apply.c| 2 +- builtin/for-each-ref.c | 9 +++-- builtin/index-pack.c | 4 +--- builtin/log.c | 2 +- builtin/merge.c| 2 +- builtin/mv.c | 8

Re: [PATCH 2/3] make update-server-info more robust

2014-09-14 Thread René Scharfe
Am 13.09.2014 um 22:19 schrieb Jeff King: Since git update-server-info may be called automatically as part of a push or a gc --auto, we should be robust against two processes trying to update it simultaneously. However, we currently use a fixed tempfile, which means that two simultaneous

[PATCH] repack: call prune_packed_objects() and update_server_info() directly

2014-09-13 Thread René Scharfe
Call the functions behind git prune-packed and git update-server-info directly instead of using run_command(). This is shorter, easier and quicker. Signed-off-by: Rene Scharfe l@web.de --- builtin/repack.c | 23 ++- 1 file changed, 6 insertions(+), 17 deletions(-) diff

Re: [RFC PATCH 2/2] headers: include dependent headers

2014-09-09 Thread René Scharfe
Am 08.09.2014 um 19:50 schrieb Junio C Hamano: René Scharfe l@web.de writes: Am 06.09.2014 um 21:20 schrieb David Aguilar: Add dependent headers so that including a header does not require including additional headers. This makes it so that gcc -c $header succeeds for each header

Re: [RFH] renaming strcmp/strncmp-icase

2014-09-08 Thread René Scharfe
Am 08.09.2014 um 20:52 schrieb Junio C Hamano: There are these two functions in dir.c that has only a handful of callers outside: int strcmp_icase(const char *a, const char *b); int strncmp_icase(const char *a, const char *b, size_t count); How many of you would think these are about

Re: [PATCH 1/2] strbuf: export strbuf_addchars()

2014-09-08 Thread René Scharfe
Am 08.09.2014 um 20:32 schrieb Junio C Hamano: René Scharfe l@web.de writes: Move strbuf_addchars() to strbuf.c, where it belongs, and make it available for other callers. Signed-off-by: Rene Scharfe l@web.de Wow, fixing up v1.7.0.2~9^2~2? About time, isn't it? ;) Both patches

Re: [RFC PATCH v2 2/2] headers: include dependent headers

2014-09-07 Thread René Scharfe
Am 07.09.2014 um 02:30 schrieb David Aguilar: Add dependent headers so that including a header does not require including additional headers. This makes it so that gcc -c $header succeeds for each header. Signed-off-by: David Aguilar dav...@gmail.com --- Addresses René's note to not

[PATCH 1/2] strbuf: export strbuf_addchars()

2014-09-07 Thread René Scharfe
Move strbuf_addchars() to strbuf.c, where it belongs, and make it available for other callers. Signed-off-by: Rene Scharfe l@web.de --- Documentation/technical/api-strbuf.txt | 4 strbuf.c | 7 +++ strbuf.h | 1 + utf8.c

[PATCH 2/2] strbuf: use strbuf_addchars() for adding a char multiple times

2014-09-07 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- graph.c | 5 ++--- merge-recursive.c | 4 +--- pretty.c | 10 +++--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/graph.c b/graph.c index 6404331..dfb99f6 100644 --- a/graph.c +++ b/graph.c @@ -1145,7 +1145,7

Re: [PATCH v3 2/2] headers: include dependent headers

2014-09-07 Thread René Scharfe
Am 07.09.2014 um 11:36 schrieb David Aguilar: Add dependent headers so that including a header does not require including additional headers. This makes it so that gcc -c $header succeeds for each header. diff --git a/cache.h b/cache.h index 4d5b76c..8b827d7 100644 --- a/cache.h +++

Re: trace.c, line 219: error: identifier redeclared: trace_strbuf

2014-09-06 Thread René Scharfe
Am 06.09.2014 um 21:26 schrieb dev: Build on Solaris 10 of latest git tarball fails thus : CC tag.o CC trace.o trace.c, line 219: error: identifier redeclared: trace_strbuf current : function(pointer to const char, pointer to const struct strbuf {unsigned long

Re: [RFC PATCH 1/2] Makefile: add check-headers target

2014-09-06 Thread René Scharfe
Am 06.09.2014 um 21:20 schrieb David Aguilar: This allows us to ensure that each header can be included individually without needing to include other headers first. Sounds like a good objective. Signed-off-by: David Aguilar dav...@gmail.com --- This patch demonstrates how to verify PATCH

Re: [RFC PATCH 2/2] headers: include dependent headers

2014-09-06 Thread René Scharfe
Am 06.09.2014 um 21:20 schrieb David Aguilar: Add dependent headers so that including a header does not require including additional headers. This makes it so that gcc -c $header succeeds for each header. Signed-off-by: David Aguilar dav...@gmail.com --- diff --git a/branch.h b/branch.h

Re: [PATCH 2/2] index-pack: handle duplicate base objects gracefully

2014-08-31 Thread René Scharfe
Am 31.08.2014 um 17:17 schrieb Jeff King: On Sat, Aug 30, 2014 at 06:00:59PM +0200, René Scharfe wrote: My only nit with patch 2: Petr Stodulka pstod...@redhat.com and Martin von Gagern martin.vgag...@gmx.net should be mentioned as bug reporters. Yeah, I agree with that. And actually, you

Re: [BUG] resolved deltas

2014-08-25 Thread René Scharfe
Am 23.08.2014 um 13:18 schrieb Jeff King: On Sat, Aug 23, 2014 at 07:04:59AM -0400, Jeff King wrote: On Sat, Aug 23, 2014 at 06:56:40AM -0400, Jeff King wrote: So I think your patch is doing the right thing. By the way, if you want to add a test to your patch, there is infrastructure in

Re: [BUG] resolved deltas

2014-08-23 Thread René Scharfe
Am 22.08.2014 um 21:41 schrieb Martin von Gagern: On 21.08.2014 13:35, Petr Stodulka wrote: Hi guys, I wanted post you patch here for this bug, but I can't find primary source of this problem [0], because I don't understand some ideas in the code. […] Any next ideas/hints or explanation

[PATCH] sha1_name: avoid quadratic list insertion in handle_one_ref

2014-08-21 Thread René Scharfe
Similar to 16445242 (fetch-pack: avoid quadratic list insertion in mark_complete), sort only after all refs are collected instead of while inserting. The result is the same, but it's more efficient that way. The difference will only be measurable in repositories with a large number of refs.

[PATCH] walker: avoid quadratic list insertion in mark_complete

2014-08-21 Thread René Scharfe
Similar to 16445242 (fetch-pack: avoid quadratic list insertion in mark_complete), sort only after all refs are collected instead of while inserting. The result is the same, but it's more efficient that way. The difference will only be measurable in repositories with a large number of refs.

[PATCH v2 1/4] run-command: introduce CHILD_PROCESS_INIT

2014-08-19 Thread René Scharfe
Most struct child_process variables are cleared using memset first after declaration. Provide a macro, CHILD_PROCESS_INIT, that can be used to initialize them statically instead. That's shorter, doesn't require a function call and is slightly more readable (especially given that we already have

[PATCH v2 3/4] run-command: call run_command_v_opt_cd_env() instead of duplicating it

2014-08-19 Thread René Scharfe
Signed-off-by: Rene Scharfe l@web.de --- run-command.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/run-command.c b/run-command.c index 47ab21b..9196ee0 100644 --- a/run-command.c +++ b/run-command.c @@ -577,9 +577,7 @@ static void prepare_run_command_v_opt(struct

[PATCH v2 4/4] run-command: inline prepare_run_command_v_opt()

2014-08-19 Thread René Scharfe
Merge prepare_run_command_v_opt() and its only caller. This removes a pointer indirection and allows to initialize the struct child_process using CHILD_PROCESS_INIT. Signed-off-by: Rene Scharfe l@web.de --- run-command.c | 24 1 file changed, 8 insertions(+), 16

Re: [PATCH] run-command: introduce CHILD_PROCESS_INIT

2014-08-17 Thread René Scharfe
Am 17.08.2014 um 09:12 schrieb Jeff King: On Sun, Aug 17, 2014 at 12:55:23AM +0200, René Scharfe wrote: Most struct child_process variables are cleared using memset right after declaration. Provide a macro, CHILD_PROCESS_INIT, that can be used to initialize them statically instead. That's

[PATCH] clean: use f(void) instead of f() to declare a pointer to a function without arguments

2014-08-16 Thread René Scharfe
Explicitly state that menu_item functions like clean_cmd don't take any arguments by using void instead of an empty parameter list. Found using gcc -Wstrict-prototypes. Signed-off-by: Rene Scharfe l@web.de --- builtin/clean.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

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

2014-08-16 Thread René Scharfe
Is there a chance to squueze this in: $ git diff diff --git a/setup.c b/setup.c index 526cdf6..fb61860 100644 --- a/setup.c +++ b/setup.c @@ -734,7 +734,7 @@ static const char *setup_git_directory_gently_1(int *nongit_ok) string_list_clear(ceiling_dirs, 0);

[PATCH] run-command: introduce CHILD_PROCESS_INIT

2014-08-16 Thread René Scharfe
Most struct child_process variables are cleared using memset right after declaration. Provide a macro, CHILD_PROCESS_INIT, that can be used to initialize them statically instead. That's shorter, doesn't require a function call and is slightly more readable (especially given that we already have

Re: [PATCH] mailsplit.c: remove dead code

2014-08-12 Thread René Scharfe
Am 11.08.2014 um 23:11 schrieb Stefan Beller: This was found by coverity. (Id: 290001) the variable 'output' is only assigned to a value inequal to NUL, after all gotos to the corrupt label. Therefore we can conclude the two removed lines are actually dead code. After reading the above for

[PATCH] read-cache: check for leading symlinks when refreshing index

2014-08-09 Thread René Scharfe
Don't add paths with leading symlinks to the index while refreshing; we only track those symlinks themselves. We already ignore them while preloading (see read_index_preload.c). Reported-by: Nikolay Avdeev avd...@math.vsu.ru Signed-off-by: Rene Scharfe l@web.de --- read-cache.c

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

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

<    4   5   6   7   8   9   10   11   12   >