[PATCH v2] worktree: add --quiet option

2018-08-15 Thread Elia Pinto
Add the '--quiet' option to git worktree,
as for the other git commands. 'add' is the
only command affected by it since all other
commands, except 'list', are currently
silent by default.

Helped-by: Martin Ågren 
Helped-by: Duy Nguyen 
Helped-by: Eric Sunshine 
Signed-off-by: Elia Pinto 
---
This is the second version of the patch.

Changes from the first version
(https://public-inbox.org/git/CACsJy8A=zp7nfbuwyfep4uff3kssiaor3m0mtgvnhceyhsw...@mail.gmail.com/T/):

- deleted garbage in git-worktree.c and deleted
superfluous blank line in git-worktree.txt.
- when giving "--quiet" to 'add', call git symbolic-ref also with
"--quiet".
- changed the commit message to be more general, but
specifying why the "--quiet" option is meaningful only for
the 'add' command of git-worktree.
- in git-worktree.txt the option
"--quiet" is described near the "--verbose" option.

 Documentation/git-worktree.txt |  4 
 builtin/worktree.c | 16 +---
 t/t2025-worktree-add.sh|  5 +
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 9c26be40f..29a5b7e25 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -173,6 +173,10 @@ This can also be set up as the default behaviour by using 
the
This format will remain stable across Git versions and regardless of 
user
configuration.  See below for details.
 
+-q::
+--quiet::
+   With 'add', suppress feedback messages.
+
 -v::
 --verbose::
With `prune`, report all removals.
diff --git a/builtin/worktree.c b/builtin/worktree.c
index a763dbdcc..41e771439 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -27,6 +27,7 @@ static const char * const worktree_usage[] = {
 struct add_opts {
int force;
int detach;
+   int quiet;
int checkout;
int keep_locked;
 };
@@ -303,9 +304,13 @@ static int add_worktree(const char *path, const char 
*refname,
if (!is_branch)
argv_array_pushl(&cp.args, "update-ref", "HEAD",
 oid_to_hex(&commit->object.oid), NULL);
-   else
+   else {
argv_array_pushl(&cp.args, "symbolic-ref", "HEAD",
 symref.buf, NULL);
+   if (opts->quiet)
+   argv_array_push(&cp.args, "--quiet");
+   }
+
cp.env = child_env.argv;
ret = run_command(&cp);
if (ret)
@@ -315,6 +320,8 @@ static int add_worktree(const char *path, const char 
*refname,
cp.argv = NULL;
argv_array_clear(&cp.args);
argv_array_pushl(&cp.args, "reset", "--hard", NULL);
+   if (opts->quiet)
+   argv_array_push(&cp.args, "--quiet");
cp.env = child_env.argv;
ret = run_command(&cp);
if (ret)
@@ -437,6 +444,7 @@ static int add(int ac, const char **av, const char *prefix)
OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named 
commit")),
OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new 
working tree")),
OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working 
tree locked")),
+   OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
OPT_PASSTHRU(0, "track", &opt_track, NULL,
 N_("set up tracking mode (see git-branch(1))"),
 PARSE_OPT_NOARG | PARSE_OPT_OPTARG),
@@ -491,8 +499,8 @@ static int add(int ac, const char **av, const char *prefix)
}
}
}
-
-   print_preparing_worktree_line(opts.detach, branch, new_branch, 
!!new_branch_force);
+   if (!opts.quiet)
+   print_preparing_worktree_line(opts.detach, branch, new_branch, 
!!new_branch_force);
 
if (new_branch) {
struct child_process cp = CHILD_PROCESS_INIT;
@@ -500,6 +508,8 @@ static int add(int ac, const char **av, const char *prefix)
argv_array_push(&cp.args, "branch");
if (new_branch_force)
argv_array_push(&cp.args, "--force");
+   if (opts.quiet)
+   argv_array_push(&cp.args, "--quiet");
argv_array_push(&cp.args, new_branch);
argv_array_push(&cp.args, branch);
if (opt_track)
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index be6e09314..658647d83 100755
--- a/t/t2025-worktre

Re: [PATCH] worktree: add --quiet option

2018-08-07 Thread Elia Pinto
2018-08-07 16:37 GMT+02:00 Martin Ågren :
> Hi Elia
>
> On 7 August 2018 at 15:21, Elia Pinto  wrote:
>> Add the '--quiet' option to git worktree add,
>> as for the other git commands.
>>
>> Signed-off-by: Elia Pinto 
>> ---
>>  Documentation/git-worktree.txt |  4 +++-
>>  builtin/worktree.c | 11 +--
>>  2 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
>> index 9c26be40f..508cde55c 100644
>> --- a/Documentation/git-worktree.txt
>> +++ b/Documentation/git-worktree.txt
>> @@ -115,7 +115,9 @@ Unlock a working tree, allowing it to be pruned, moved 
>> or deleted.
>>
>>  OPTIONS
>>  ---
>> -
>
> Grepping through Documentation/, it is clear that we sometimes have a
> blank line here, sometimes not. I'm not sure what to make of that.
>
>> +-q::
>> +--quiet::
>> +   With 'add', suppress feedback messages.
>>  -f::
>
> But I do think that for consistency, we'd prefer a blank line before `-f::`.
>
> Both the commit message and this documentation makes me wonder if this
> focuses on "add" because it's the only subcommand where `--quiet` makes
> sense, conceptually, or because this is where you happen to need it
> personally, or due to some other $reason. Could you say something more
> about this?
>
> I'm not a worktree power-user, so please forgive my ignorance...
>
>> @@ -315,6 +316,9 @@ static int add_worktree(const char *path, const char 
>> *refname,
>> cp.argv = NULL;
>> argv_array_clear(&cp.args);
>> argv_array_pushl(&cp.args, "reset", "--hard", NULL);
>> +   if (opts->quiet)
>> +   argv_array_push(&cp.args, "--quiet");
>> +   printf("%s\n","soo qia");
>
> This last line looks like debug cruft.
>
>> @@ -437,6 +441,7 @@ static int add(int ac, const char **av, const char 
>> *prefix)
>> OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named 
>> commit")),
>> OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new 
>> working tree")),
>> OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new 
>> working tree locked")),
>> +   OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
>
> This matches other users. Good.
>
> I did some simple testing and this appears to be quite quiet, modulo
> the "soo qia" that I already mentioned. Could you add a test to
> demonstrate the quietness and to keep it from regressing? Something like
> `git worktree add ../foo >out && test_must_be_empty out" in e.g.,
> t2025-worktree-add.sh might do the trick (capture stderr as well?).
>
> Hope this helps
> Martin


Thank you all. sorry for the trash in the patch I will resend it.


[PATCH] worktree: add --quiet option

2018-08-07 Thread Elia Pinto
Add the '--quiet' option to git worktree add,
as for the other git commands.

Signed-off-by: Elia Pinto 
---
 Documentation/git-worktree.txt |  4 +++-
 builtin/worktree.c | 11 +--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 9c26be40f..508cde55c 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -115,7 +115,9 @@ Unlock a working tree, allowing it to be pruned, moved or 
deleted.
 
 OPTIONS
 ---
-
+-q::
+--quiet::
+   With 'add', suppress feedback messages.
 -f::
 --force::
By default, `add` refuses to create a new working tree when
diff --git a/builtin/worktree.c b/builtin/worktree.c
index a763dbdcc..c47feb4a4 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -27,6 +27,7 @@ static const char * const worktree_usage[] = {
 struct add_opts {
int force;
int detach;
+   int quiet;
int checkout;
int keep_locked;
 };
@@ -315,6 +316,9 @@ static int add_worktree(const char *path, const char 
*refname,
cp.argv = NULL;
argv_array_clear(&cp.args);
argv_array_pushl(&cp.args, "reset", "--hard", NULL);
+   if (opts->quiet)
+   argv_array_push(&cp.args, "--quiet");
+   printf("%s\n","soo qia");
cp.env = child_env.argv;
ret = run_command(&cp);
if (ret)
@@ -437,6 +441,7 @@ static int add(int ac, const char **av, const char *prefix)
OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named 
commit")),
OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new 
working tree")),
OPT_BOOL(0, "lock", &opts.keep_locked, N_("keep the new working 
tree locked")),
+   OPT__QUIET(&opts.quiet, N_("suppress progress reporting")),
OPT_PASSTHRU(0, "track", &opt_track, NULL,
 N_("set up tracking mode (see git-branch(1))"),
 PARSE_OPT_NOARG | PARSE_OPT_OPTARG),
@@ -491,8 +496,8 @@ static int add(int ac, const char **av, const char *prefix)
}
}
}
-
-   print_preparing_worktree_line(opts.detach, branch, new_branch, 
!!new_branch_force);
+   if (!opts.quiet)
+   print_preparing_worktree_line(opts.detach, branch, new_branch, 
!!new_branch_force);
 
if (new_branch) {
struct child_process cp = CHILD_PROCESS_INIT;
@@ -500,6 +505,8 @@ static int add(int ac, const char **av, const char *prefix)
argv_array_push(&cp.args, "branch");
if (new_branch_force)
argv_array_push(&cp.args, "--force");
+   if (opts.quiet)
+   argv_array_push(&cp.args, "--quiet");
argv_array_push(&cp.args, new_branch);
argv_array_push(&cp.args, branch);
if (opt_track)
-- 
2.18.0.721.gc1f18ed



[PATCH] Fixes compile warning with -Wimplicit-fallthrough CFLAGS

2018-01-22 Thread Elia Pinto
This patch add explicit fallthrough compiler attribute
when needed on switch case statement eliminating
the compile warning [-Werror=implicit-fallthrough=].
It does this by means of a macro that takes into account
the versions of the compilers that include that attribute.

The fallthrough (or clang::fallthrough) attribute is used to annotate
intentional fall-through between switch labels.
Traditionally these are marked with a specific comment, but
this attribute is meant to replace comments with a more strict
annotation, which can be checked by the compiler (gcc-7 or clang).
The flags in question were introduced in gcc 7 and are also enabled
with -Wextra.

It would also have been possible to introduce a specific comment
accepted by gcc 7 instead of the fallthrough attribute for this warning,
but clang does not have a similar implementation. The macro replaces
the previous, not uniform, comments and can acts as a comment itself.

Signed-off-by: Elia Pinto 
---
 apply.c |  6 +++---
 builtin/blame.c |  2 +-
 builtin/cat-file.c  |  2 +-
 builtin/checkout.c  |  2 +-
 builtin/fast-export.c   |  4 ++--
 builtin/fetch.c |  2 +-
 builtin/init-db.c   |  2 +-
 builtin/log.c   |  4 ++--
 builtin/ls-files.c  |  2 +-
 builtin/remote-ext.c|  2 +-
 builtin/reset.c |  2 +-
 builtin/submodule--helper.c |  2 +-
 config.c|  4 ++--
 connect.c   |  6 +++---
 convert.c   |  4 ++--
 diff.c  |  2 +-
 dir.c   |  2 +-
 fsck.c  |  2 +-
 git-compat-util.h   | 17 +
 ll-merge.c  |  2 +-
 mailinfo.c  |  2 +-
 notes.c |  4 ++--
 pretty.c|  2 +-
 quote.c |  4 ++--
 read-cache.c|  4 ++--
 refs/files-backend.c|  2 +-
 revision.c  |  2 +-
 send-pack.c |  2 +-
 strbuf.c|  2 +-
 streaming.c |  2 +-
 upload-pack.c   |  3 +--
 wildmatch.c |  2 +-
 wt-status.c |  4 ++--
 33 files changed, 61 insertions(+), 45 deletions(-)

diff --git a/apply.c b/apply.c
index 321a9fa68..a22fb2881 100644
--- a/apply.c
+++ b/apply.c
@@ -1450,7 +1450,7 @@ static void recount_diff(const char *line, int size, 
struct fragment *fragment)
switch (*line) {
case ' ': case '\n':
newlines++;
-   /* fall through */
+   GIT_FALLTHROUGH;
case '-':
oldlines++;
continue;
@@ -2896,7 +2896,7 @@ static int apply_one_fragment(struct apply_state *state,
if (plen && (ws_rule & WS_BLANK_AT_EOF) &&
ws_blank_line(patch + 1, plen, ws_rule))
is_blank_context = 1;
-   /* fallthrough */
+   GIT_FALLTHROUGH;
case '-':
memcpy(old, patch + 1, plen);
add_line_info(&preimage, old, plen,
@@ -2904,7 +2904,7 @@ static int apply_one_fragment(struct apply_state *state,
old += plen;
if (first == '-')
break;
-   /* fallthrough */
+   GIT_FALLTHROUGH;
case '+':
/* --no-add does not add new lines */
if (first == '+' && state->no_add)
diff --git a/builtin/blame.c b/builtin/blame.c
index 005f55aaa..acc2c1e93 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -834,7 +834,7 @@ int cmd_blame(int argc, const char **argv, const char 
*prefix)
argv[1] = argv[3];
argv[3] = argv[2];
argv[2] = "--";
-   /* FALLTHROUGH */
+   GIT_FALLTHROUGH;
case 1: /* (1a) */
path = add_prefix(prefix, argv[--argc]);
argv[argc] = NULL;
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index cf9ea5c79..eb4fa9247 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -113,7 +113,7 @@ static int cat_one_file(int opt, const char *exp_type, 
const char *obj_name,
 
if (textconv_object(path, obj_context.mode, &oid, 1, &buf, 
&size))
break;
-   /* else fallthrough */
+   GIT_FALLTHROUGH;
 
case 'p':
type = sha1_object_info(oid.hash, NULL);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index c54c78df5..2db0e16d1 100644
--- 

[PATCHv4] builtin/commit.c: switch to strbuf, instead of snprintf()

2017-01-31 Thread Elia Pinto
Switch to dynamic allocation with strbuf, so we can avoid dealing
with magic numbers in the code and reduce the cognitive burden from
the programmers.  The original code is correct, but programmers no
longer have to count bytes needed for static allocation to know that.

As a side effect of this change, we also reduce the snprintf()
calls, that may silently truncate results if the programmer is not
careful.

Helped-by: René Scharfe 
Helped-by: Junio C Hamano 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
This is the fourth patch version.

Changes from the first version: I have split the original commit in two, as 
discussed here
http://public-inbox.org/git/20161213132717.42965-1-gitter.spi...@gmail.com/.

Changes from the second version:
- Changed the commit message to clarify the purpose of the patch (
as suggested by Junio)

Changes from the third version:
- Swith to use strbuf instead of xstrfmt (
as suggested by René Scharfe
here https://public-inbox.org/git/3165803b-6073-de97-bf33-71ad21108...@web.de/)


 builtin/commit.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 276c4f2e7..2de5f6cc6 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1525,12 +1525,10 @@ static int git_commit_config(const char *k, const char 
*v, void *cb)
 static int run_rewrite_hook(const unsigned char *oldsha1,
const unsigned char *newsha1)
 {
-   /* oldsha1 SP newsha1 LF NUL */
-   static char buf[2*40 + 3];
struct child_process proc = CHILD_PROCESS_INIT;
const char *argv[3];
int code;
-   size_t n;
+   struct strbuf sb = STRBUF_INIT;
 
argv[0] = find_hook("post-rewrite");
if (!argv[0])
@@ -1546,11 +1544,11 @@ static int run_rewrite_hook(const unsigned char 
*oldsha1,
code = start_command(&proc);
if (code)
return code;
-   n = snprintf(buf, sizeof(buf), "%s %s\n",
-sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
+   strbuf_addf(&sb, "%s %s\n", sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
sigchain_push(SIGPIPE, SIG_IGN);
-   write_in_full(proc.in, buf, n);
+   write_in_full(proc.in, sb.buf, sb.len);
close(proc.in);
+   strbuf_release(&sb);
sigchain_pop(SIGPIPE);
return finish_command(&proc);
 }
-- 
2.11.0.297.g2a7e328.dirty



Re: [PATCHv3 2/2] builtin/commit.c: switch to xstrfmt(), instead of snprintf,

2017-01-15 Thread Elia Pinto
2017-01-15 3:42 GMT+01:00 Junio C Hamano :
> Elia Pinto  writes:
>
>> Ok. I agree. But  is it strictly necessary to resend for this ?
>
> FWIW, the attacched is what I queued locally, after complaining
> "both have the same title?  They need to be explained better."
>
> In any case, I sense that 2/2 will be redone using strbuf, from the
> looks of what is discussed in a subthread nearby?

Yes, it seems to me correct, I resend the patch 2/2 based on the review

thank you all
>
> Thanks.
>
> commit 8d7aa4ba6a00b3ff69261e88b4842c0df5662125
> Author: Elia Pinto 
> Date:   Fri Jan 13 17:58:00 2017 +
>
> builtin/commit.c: remove the PATH_MAX limitation via dynamic allocation
>
> Remove the PATH_MAX limitation from the environment setting that
> points to a filename by switching to dynamic allocation.
>
> As a side effect of this change, we also reduce the snprintf()
> calls, that may silently truncate results if the programmer is not
> careful.
>
> Helped-by: Junio C Hamano 
> Helped-by: Jeff King 
> Signed-off-by: Elia Pinto 
>     Signed-off-by: Junio C Hamano 
>
> commit 2a7e328877982557d921a398af9442093290c613
> Author: Elia Pinto 
> Date:   Fri Jan 13 17:58:01 2017 +
>
> builtin/commit.c: switch to xstrfmt(), instead of snprintf()
>
> Switch to dynamic allocation with xstrfmt(), so we can avoid dealing
> with magic numbers in the code and reduce the cognitive burden from
> the programmers.  The original code is correct, but programmers no
> longer have to count bytes needed for static allocation to know that.
>
> As a side effect of this change, we also reduce the snprintf()
> calls, that may silently truncate results if the programmer is not
> careful.
>
> Helped-by: Junio C Hamano 
> Helped-by: Jeff King 
> Signed-off-by: Elia Pinto 
> Signed-off-by: Junio C Hamano 


Re: [PATCHv3 2/2] builtin/commit.c: switch to xstrfmt(), instead of snprintf,

2017-01-14 Thread Elia Pinto
Ok. I agree. But  is it strictly necessary to resend for this ?

Thanks

2017-01-13 19:33 GMT+01:00 Brandon Williams :
> On 01/13, Elia Pinto wrote:
>> In this patch, instead of using xnprintf instead of snprintf, which asserts
>> that we don't truncate, we are switching to dynamic allocation with  
>> xstrfmt(),
>> , so we can avoid dealing with magic numbers in the code and reduce the 
>> cognitive burden from
>> the programmers, because they no longer have to count bytes needed for 
>> static allocation.
>> As a side effect of this patch we have also reduced the snprintf() calls, 
>> that may silently truncate
>> results if the programmer is not careful.
>>
>> Helped-by: Junio C Hamano 
>> Helped-by: Jeff King 
>> Signed-off-by: Elia Pinto 
>
> Small nit's with the commit message:
> * Stray comma ',' of on its own
> * lines are longer than 80 characters
>
>> ---
>> This is the third  version of the patch.
>>
>> Changes from the first version: I have split the original commit in two, as 
>> discussed here
>> http://public-inbox.org/git/20161213132717.42965-1-gitter.spi...@gmail.com/.
>>
>> Changes from the second version:
>> - Changed the commit message to clarify the purpose of the patch (
>> as suggested by Junio)
>> https://public-inbox.org/git/xmqqtw95mfo3@gitster.mtv.corp.google.com/T/#m2e6405a8a78a8ca1ed770614c91398290574c4a1
>>
>>
>>
>>  builtin/commit.c | 10 --
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/builtin/commit.c b/builtin/commit.c
>> index 09bcc0f13..37228330c 100644
>> --- a/builtin/commit.c
>> +++ b/builtin/commit.c
>> @@ -1526,12 +1526,10 @@ static int git_commit_config(const char *k, const 
>> char *v, void *cb)
>>  static int run_rewrite_hook(const unsigned char *oldsha1,
>>   const unsigned char *newsha1)
>>  {
>> - /* oldsha1 SP newsha1 LF NUL */
>> - static char buf[2*40 + 3];
>> + char *buf;
>>   struct child_process proc = CHILD_PROCESS_INIT;
>>   const char *argv[3];
>>   int code;
>> - size_t n;
>>
>>   argv[0] = find_hook("post-rewrite");
>>   if (!argv[0])
>> @@ -1547,11 +1545,11 @@ static int run_rewrite_hook(const unsigned char 
>> *oldsha1,
>>   code = start_command(&proc);
>>   if (code)
>>   return code;
>> - n = snprintf(buf, sizeof(buf), "%s %s\n",
>> -  sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
>> + buf = xstrfmt("%s %s\n", sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
>>   sigchain_push(SIGPIPE, SIG_IGN);
>> - write_in_full(proc.in, buf, n);
>> + write_in_full(proc.in, buf, strlen(buf));
>>   close(proc.in);
>> + free(buf);
>>   sigchain_pop(SIGPIPE);
>>   return finish_command(&proc);
>>  }
>> --
>> 2.11.0.154.g5f5f154
>>
>
> --
> Brandon Williams


[PATCHv3 2/2] builtin/commit.c: switch to xstrfmt(), instead of snprintf,

2017-01-13 Thread Elia Pinto
In this patch, instead of using xnprintf instead of snprintf, which asserts
that we don't truncate, we are switching to dynamic allocation with  xstrfmt(),
, so we can avoid dealing with magic numbers in the code and reduce the 
cognitive burden from
the programmers, because they no longer have to count bytes needed for static 
allocation.
As a side effect of this patch we have also reduced the snprintf() calls, that 
may silently truncate 
results if the programmer is not careful.

Helped-by: Junio C Hamano 
Helped-by: Jeff King  
Signed-off-by: Elia Pinto 
---
This is the third  version of the patch.

Changes from the first version: I have split the original commit in two, as 
discussed here
http://public-inbox.org/git/20161213132717.42965-1-gitter.spi...@gmail.com/.

Changes from the second version:
- Changed the commit message to clarify the purpose of the patch (
as suggested by Junio)
https://public-inbox.org/git/xmqqtw95mfo3@gitster.mtv.corp.google.com/T/#m2e6405a8a78a8ca1ed770614c91398290574c4a1



 builtin/commit.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 09bcc0f13..37228330c 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1526,12 +1526,10 @@ static int git_commit_config(const char *k, const char 
*v, void *cb)
 static int run_rewrite_hook(const unsigned char *oldsha1,
const unsigned char *newsha1)
 {
-   /* oldsha1 SP newsha1 LF NUL */
-   static char buf[2*40 + 3];
+   char *buf;
struct child_process proc = CHILD_PROCESS_INIT;
const char *argv[3];
int code;
-   size_t n;
 
argv[0] = find_hook("post-rewrite");
if (!argv[0])
@@ -1547,11 +1545,11 @@ static int run_rewrite_hook(const unsigned char 
*oldsha1,
code = start_command(&proc);
if (code)
return code;
-   n = snprintf(buf, sizeof(buf), "%s %s\n",
-sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
+   buf = xstrfmt("%s %s\n", sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
sigchain_push(SIGPIPE, SIG_IGN);
-   write_in_full(proc.in, buf, n);
+   write_in_full(proc.in, buf, strlen(buf));
close(proc.in);
+   free(buf);
sigchain_pop(SIGPIPE);
return finish_command(&proc);
 }
-- 
2.11.0.154.g5f5f154



[PATCHv3 1/2] builtin/commit.c: removes the PATH_MAX limitation via dynamic allocation

2017-01-13 Thread Elia Pinto
This patch removes the PATH_MAX limitation from the environment 
setting that points to a filename, we'd want to handle larger
paths anyway, so we switch to dynamic allocation. As a side effect 
of this patch we have also reduced the snprintf() calls, that 
may silently truncate results if the programmer is not careful.

Helped-by: Junio C Hamano 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
This is the third  version of the patch.

Changes from the first version: I have split the original commit in two, as 
discussed here
http://public-inbox.org/git/20161213132717.42965-1-gitter.spi...@gmail.com/.

Changes from the second version:
- Changed the commit message to clarify the purpose of the patch (
as suggested by Junio)
- drop the arg_array_clear call after exit(1)
https://public-inbox.org/git/xmqqtw95mfo3@gitster.mtv.corp.google.com/T/#m2e6405a8a78a8ca1ed770614c91398290574c4a1


 builtin/commit.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 0ed634b26..09bcc0f13 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -960,15 +960,15 @@ static int prepare_to_commit(const char *index_file, 
const char *prefix,
return 0;
 
if (use_editor) {
-   char index[PATH_MAX];
-   const char *env[2] = { NULL };
-   env[0] =  index;
-   snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
-   if (launch_editor(git_path_commit_editmsg(), NULL, env)) {
+   struct argv_array env = ARGV_ARRAY_INIT;
+
+   argv_array_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
+   if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
fprintf(stderr,
_("Please supply the message using either -m or -F 
option.\n"));
exit(1);
}
+   argv_array_clear(&env);
}
 
if (!no_verify &&
@@ -1557,23 +1557,22 @@ static int run_rewrite_hook(const unsigned char 
*oldsha1,
 
 int run_commit_hook(int editor_is_used, const char *index_file, const char 
*name, ...)
 {
-   const char *hook_env[3] =  { NULL };
-   char index[PATH_MAX];
+   struct argv_array hook_env = ARGV_ARRAY_INIT;
va_list args;
int ret;
 
-   snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
-   hook_env[0] = index;
+   argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
 
/*
 * Let the hook know that no editor will be launched.
 */
if (!editor_is_used)
-   hook_env[1] = "GIT_EDITOR=:";
+   argv_array_push(&hook_env, "GIT_EDITOR=:");
 
va_start(args, name);
-   ret = run_hook_ve(hook_env, name, args);
+   ret = run_hook_ve(hook_env.argv,name, args);
va_end(args);
+   argv_array_clear(&hook_env);
 
return ret;
 }
-- 
2.11.0.154.g5f5f154



[PATCHv2 1/2] builtin/commit.c: drop use snprintf via dynamic allocation

2017-01-10 Thread Elia Pinto
In general snprintf is bad because it may silently truncate results if we're
wrong. In this patch where we use PATH_MAX, we'd want to handle larger
paths anyway, so we switch to dynamic allocation.

Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
This is the second version of the patch.

I have split the original commit in two, as discussed here
http://public-inbox.org/git/20161213132717.42965-1-gitter.spi...@gmail.com/.

 builtin/commit.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 0ed634b26..09bcc0f13 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -960,15 +960,16 @@ static int prepare_to_commit(const char *index_file, 
const char *prefix,
return 0;
 
if (use_editor) {
-   char index[PATH_MAX];
-   const char *env[2] = { NULL };
-   env[0] =  index;
-   snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
-   if (launch_editor(git_path_commit_editmsg(), NULL, env)) {
+   struct argv_array env = ARGV_ARRAY_INIT;
+
+   argv_array_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
+   if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
fprintf(stderr,
_("Please supply the message using either -m or -F 
option.\n"));
+   argv_array_clear(&env);
exit(1);
}
+   argv_array_clear(&env);
}
 
if (!no_verify &&
@@ -1557,23 +1558,22 @@ static int run_rewrite_hook(const unsigned char 
*oldsha1,
 
 int run_commit_hook(int editor_is_used, const char *index_file, const char 
*name, ...)
 {
-   const char *hook_env[3] =  { NULL };
-   char index[PATH_MAX];
+   struct argv_array hook_env = ARGV_ARRAY_INIT;
va_list args;
int ret;
 
-   snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
-   hook_env[0] = index;
+   argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
 
/*
 * Let the hook know that no editor will be launched.
 */
if (!editor_is_used)
-   hook_env[1] = "GIT_EDITOR=:";
+   argv_array_push(&hook_env, "GIT_EDITOR=:");
 
va_start(args, name);
-   ret = run_hook_ve(hook_env, name, args);
+   ret = run_hook_ve(hook_env.argv,name, args);
va_end(args);
+   argv_array_clear(&hook_env);
 
return ret;
 }
-- 
2.11.0.154.g5f5f154



[PATCHv2 2/2] builtin/commit.c: drop use snprintf via dynamic allocation

2017-01-10 Thread Elia Pinto
In general snprintf is bad because it may silently truncate results
if we're wrong. In this patch, instead of using xnprintf, which asserts
that we don't truncate, we are switching to dynamic allocation, so we can
avoid dealing with magic numbers in the code.

Helped-by: Jeff King  
Signed-off-by: Elia Pinto 
---
This is the second version of the patch.

I have split the original commit in two, as discussed here
http://public-inbox.org/git/20161213132717.42965-1-gitter.spi...@gmail.com/.

 builtin/commit.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 09bcc0f13..37228330c 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1526,12 +1526,10 @@ static int git_commit_config(const char *k, const char 
*v, void *cb)
 static int run_rewrite_hook(const unsigned char *oldsha1,
const unsigned char *newsha1)
 {
-   /* oldsha1 SP newsha1 LF NUL */
-   static char buf[2*40 + 3];
+   char *buf;
struct child_process proc = CHILD_PROCESS_INIT;
const char *argv[3];
int code;
-   size_t n;
 
argv[0] = find_hook("post-rewrite");
if (!argv[0])
@@ -1547,11 +1545,11 @@ static int run_rewrite_hook(const unsigned char 
*oldsha1,
code = start_command(&proc);
if (code)
return code;
-   n = snprintf(buf, sizeof(buf), "%s %s\n",
-sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
+   buf = xstrfmt("%s %s\n", sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
sigchain_push(SIGPIPE, SIG_IGN);
-   write_in_full(proc.in, buf, n);
+   write_in_full(proc.in, buf, strlen(buf));
close(proc.in);
+   free(buf);
sigchain_pop(SIGPIPE);
return finish_command(&proc);
 }
-- 
2.11.0.154.g5f5f154



[PATCH] builtin/commit.c: convert trivial snprintf calls to xsnprintf

2016-12-13 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call from snprintf/sprintf/strcpy to xsnprintf.  This patch supersedes the
snprintf with several calls that make use of the heap rather than fixed
length buffers (eg. PATH_MAX) that may be incorrect on some systems.

Signed-off-by: Elia Pinto 
---
 builtin/commit.c | 32 +++-
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 0ed634b26..37228330c 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -960,15 +960,16 @@ static int prepare_to_commit(const char *index_file, 
const char *prefix,
return 0;
 
if (use_editor) {
-   char index[PATH_MAX];
-   const char *env[2] = { NULL };
-   env[0] =  index;
-   snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
-   if (launch_editor(git_path_commit_editmsg(), NULL, env)) {
+   struct argv_array env = ARGV_ARRAY_INIT;
+
+   argv_array_pushf(&env, "GIT_INDEX_FILE=%s", index_file);
+   if (launch_editor(git_path_commit_editmsg(), NULL, env.argv)) {
fprintf(stderr,
_("Please supply the message using either -m or -F 
option.\n"));
+   argv_array_clear(&env);
exit(1);
}
+   argv_array_clear(&env);
}
 
if (!no_verify &&
@@ -1525,12 +1526,10 @@ static int git_commit_config(const char *k, const char 
*v, void *cb)
 static int run_rewrite_hook(const unsigned char *oldsha1,
const unsigned char *newsha1)
 {
-   /* oldsha1 SP newsha1 LF NUL */
-   static char buf[2*40 + 3];
+   char *buf;
struct child_process proc = CHILD_PROCESS_INIT;
const char *argv[3];
int code;
-   size_t n;
 
argv[0] = find_hook("post-rewrite");
if (!argv[0])
@@ -1546,34 +1545,33 @@ static int run_rewrite_hook(const unsigned char 
*oldsha1,
code = start_command(&proc);
if (code)
return code;
-   n = snprintf(buf, sizeof(buf), "%s %s\n",
-sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
+   buf = xstrfmt("%s %s\n", sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
sigchain_push(SIGPIPE, SIG_IGN);
-   write_in_full(proc.in, buf, n);
+   write_in_full(proc.in, buf, strlen(buf));
close(proc.in);
+   free(buf);
sigchain_pop(SIGPIPE);
return finish_command(&proc);
 }
 
 int run_commit_hook(int editor_is_used, const char *index_file, const char 
*name, ...)
 {
-   const char *hook_env[3] =  { NULL };
-   char index[PATH_MAX];
+   struct argv_array hook_env = ARGV_ARRAY_INIT;
va_list args;
int ret;
 
-   snprintf(index, sizeof(index), "GIT_INDEX_FILE=%s", index_file);
-   hook_env[0] = index;
+   argv_array_pushf(&hook_env, "GIT_INDEX_FILE=%s", index_file);
 
/*
 * Let the hook know that no editor will be launched.
 */
if (!editor_is_used)
-   hook_env[1] = "GIT_EDITOR=:";
+   argv_array_push(&hook_env, "GIT_EDITOR=:");
 
va_start(args, name);
-   ret = run_hook_ve(hook_env, name, args);
+   ret = run_hook_ve(hook_env.argv,name, args);
va_end(args);
+   argv_array_clear(&hook_env);
 
return ret;
 }
-- 
2.11.0.153.gacc9cba



[PATCH] git-check-ref-format.txt: fixup documentation

2016-09-20 Thread Elia Pinto
die is not a standard shell function. Use
a different shell code for the example.

Signed-off-by: Elia Pinto 
---
 Documentation/git-check-ref-format.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-check-ref-format.txt 
b/Documentation/git-check-ref-format.txt
index 91a3622..8611a99 100644
--- a/Documentation/git-check-ref-format.txt
+++ b/Documentation/git-check-ref-format.txt
@@ -118,8 +118,8 @@ $ git check-ref-format --branch @{-1}
 * Determine the reference name to use for a new branch:
 +
 
-$ ref=$(git check-ref-format --normalize "refs/heads/$newbranch") ||
-die "we do not like '$newbranch' as a branch name."
+$ ref=$(git check-ref-format --normalize "refs/heads/$newbranch")||
+{ echo "we do not like '$newbranch' as a branch name." >&2 ; exit 1 ; }
 
 
 GIT
-- 
2.10.0.645.gc4ba6eb



[PATCHv1 3/4] t5550-http-fetch-dumb.sh: use the GIT_TRACE_CURL environment var

2016-09-05 Thread Elia Pinto
Use the new GIT_TRACE_CURL environment variable instead
of the deprecated GIT_CURL_VERBOSE.

Signed-off-by: Elia Pinto 
---
Drop leftover debugging junk from previous patch

 t/t5550-http-fetch-dumb.sh | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 3484b6f..dc9b87d 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -263,15 +263,15 @@ check_language () {
>expect
;;
?*)
-   echo "Accept-Language: $1" >expect
+   echo "=> Send header: Accept-Language: $1" >expect
;;
esac &&
-   GIT_CURL_VERBOSE=1 \
+   GIT_TRACE_CURL=true \
LANGUAGE=$2 \
git ls-remote "$HTTPD_URL/dumb/repo.git" >output 2>&1 &&
tr -d '\015' actual &&
+   sed -ne '/^=> Send header: Accept-Language:/ p' >actual &&
test_cmp expect actual
 }
 
@@ -295,8 +295,8 @@ ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, 
*;q=0.90" \
 '
 
 test_expect_success 'git client does not send an empty Accept-Language' '
-   GIT_CURL_VERBOSE=1 LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 
2>stderr &&
-   ! grep "^Accept-Language:" stderr
+   GIT_TRACE_CURL=true LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 
2>stderr &&
+   ! grep "^=> Send header: Accept-Language:" stderr
 '
 
 stop_httpd
-- 
2.10.0.308.gf73994d



Re: [PATCH 3/4] t5550-http-fetch-dumb.sh: use the GIT_TRACE_CURL environment var

2016-09-05 Thread Elia Pinto
2016-09-05 15:43 GMT+02:00 Eric Sunshine :
> On Mon, Sep 5, 2016 at 6:24 AM, Elia Pinto  wrote:
>> Use the new GIT_TRACE_CURL environment variable instead
>> of the deprecated GIT_CURL_VERBOSE.
>>
>> Signed-off-by: Elia Pinto 
>> ---
>> diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
>> @@ -263,15 +263,18 @@ check_language () {
>> >expect
>> ;;
>> ?*)
>> -   echo "Accept-Language: $1" >expect
>> +   echo "=> Send header: Accept-Language: $1" >expect
>> ;;
>> esac &&
>> -   GIT_CURL_VERBOSE=1 \
>> +   GIT_TRACE_CURL=true \
>> LANGUAGE=$2 \
>> git ls-remote "$HTTPD_URL/dumb/repo.git" >output 2>&1 &&
>> tr -d '\015' > sort -u |
>> -   sed -ne '/^Accept-Language:/ p' >actual &&
>> +   sed -ne '/^=> Send header: Accept-Language:/ p' >actual &&
>> +   cp expect expect.$$ &&
>> +   cp actual actual.$$ &&
>> +   cp output output.$$ &&
>
> What are these three cp's about? They don't seem to be related to the
> stated changes. Are they leftover debugging gunk?
Yes, i am very sorry. My bad. I will repost. Thanks


>
>> test_cmp expect actual
>>  }
>>
>> @@ -295,8 +298,8 @@ ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, 
>> *;q=0.90" \
>>  '
>>
>>  test_expect_success 'git client does not send an empty Accept-Language' '
>> -   GIT_CURL_VERBOSE=1 LANGUAGE= git ls-remote 
>> "$HTTPD_URL/dumb/repo.git" 2>stderr &&
>> -   ! grep "^Accept-Language:" stderr
>> +   GIT_TRACE_CURL=true LANGUAGE= git ls-remote 
>> "$HTTPD_URL/dumb/repo.git" 2>stderr &&
>> +   ! grep "^=> Send header: Accept-Language:" stderr
>>  '
>>
>>  stop_httpd


[PATCH 4/4] t5551-http-fetch-smart.sh: use the GIT_TRACE_CURL environment var

2016-09-05 Thread Elia Pinto
Use the new GIT_TRACE_CURL environment variable instead
of the deprecated GIT_CURL_VERBOSE.

Signed-off-by: Elia Pinto 
---
 t/t5551-http-fetch-smart.sh | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/t/t5551-http-fetch-smart.sh b/t/t5551-http-fetch-smart.sh
index 2f375eb..1ec5b27 100755
--- a/t/t5551-http-fetch-smart.sh
+++ b/t/t5551-http-fetch-smart.sh
@@ -43,12 +43,21 @@ cat >exp <err &&
+   GIT_TRACE_CURL=true git clone --quiet $HTTPD_URL/smart/repo.git clone 
2>err &&
test_cmp file clone/file &&
tr '\''\015'\'' Q  Send header, /d
+   /^=> Send header:$/d
+   /^<= Recv header, /d
+   /^<= Recv header:$/d
+   s/=> Send header: //
+   s/= Recv header://
+   /^<= Recv data/d
+   /^=> Send data/d
/^$/d
/^< $/d
 
@@ -261,9 +270,9 @@ test_expect_success CMDLINE_LIMIT \
 '
 
 test_expect_success 'large fetch-pack requests can be split across POSTs' '
-   GIT_CURL_VERBOSE=1 git -c http.postbuffer=65536 \
+   GIT_TRACE_CURL=true git -c http.postbuffer=65536 \
clone --bare "$HTTPD_URL/smart/repo.git" split.git 2>err &&
-   grep "^> POST" err >posts &&
+   grep "^=> Send header: POST" err >posts &&
test_line_count = 2 posts
 '
 
-- 
2.10.0.308.gf73994d



[PATCH 2/4] test-lib.sh: preserve GIT_TRACE_CURL from the environment

2016-09-05 Thread Elia Pinto
Turning on this variable can be useful when debugging http
tests. It can break a few tests in t5541 if not set
to an absolute path but it is not a variable
that the user is likely to have enabled accidentally.

Signed-off-by: Elia Pinto 
---
 t/test-lib.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index d731d66..986eba1 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -89,6 +89,7 @@ unset VISUAL EMAIL LANGUAGE COLUMNS $("$PERL_PATH" -e '
UNZIP
PERF_
CURL_VERBOSE
+   TRACE_CURL
));
my @vars = grep(/^GIT_/ && !/^GIT_($ok)/o, @env);
print join("\n", @vars);
-- 
2.10.0.308.gf73994d



[PATCH 1/4] t5541-http-push-smart.sh: use the GIT_TRACE_CURL environment var

2016-09-05 Thread Elia Pinto
Use the new GIT_TRACE_CURL environment variable instead
of the deprecated GIT_CURL_VERBOSE.

Signed-off-by: Elia Pinto 
---
 t/t5541-http-push-smart.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t5541-http-push-smart.sh b/t/t5541-http-push-smart.sh
index 4840c71..d38bf32 100755
--- a/t/t5541-http-push-smart.sh
+++ b/t/t5541-http-push-smart.sh
@@ -74,7 +74,7 @@ test_expect_success 'push to remote repository (standard)' '
test_tick &&
git commit -m path2 &&
HEAD=$(git rev-parse --verify HEAD) &&
-   GIT_CURL_VERBOSE=1 git push -v -v 2>err &&
+   GIT_TRACE_CURL=true git push -v -v 2>err &&
! grep "Expect: 100-continue" err &&
grep "POST git-receive-pack ([0-9]* bytes)" err &&
(cd "$HTTPD_DOCUMENT_ROOT_PATH"/test_repo.git &&
-- 
2.10.0.308.gf73994d



[PATCH 0/4] test suite: use the GIT_TRACE_CURL environment var

2016-09-05 Thread Elia Pinto
Use the new GIT_TRACE_CURL environment variable in the test suite 
instead of the deprecated GIT_CURL_VERBOSE.

Elia Pinto (4):
  t5541-http-push-smart.sh: use the GIT_TRACE_CURL environment var
  test-lib.sh: preserve GIT_TRACE_CURL from the environment
  t5550-http-fetch-dumb.sh: use the GIT_TRACE_CURL environment var
  t5551-http-fetch-smart.sh: use the GIT_TRACE_CURL environment var

 t/t5541-http-push-smart.sh  |  2 +-
 t/t5550-http-fetch-dumb.sh  | 13 -
 t/t5551-http-fetch-smart.sh | 15 ---
 t/test-lib.sh   |  1 +
 4 files changed, 22 insertions(+), 9 deletions(-)

-- 
2.10.0.308.gf73994d



[PATCH 3/4] t5550-http-fetch-dumb.sh: use the GIT_TRACE_CURL environment var

2016-09-05 Thread Elia Pinto
Use the new GIT_TRACE_CURL environment variable instead
of the deprecated GIT_CURL_VERBOSE.

Signed-off-by: Elia Pinto 
---
 t/t5550-http-fetch-dumb.sh | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/t/t5550-http-fetch-dumb.sh b/t/t5550-http-fetch-dumb.sh
index 3484b6f..75694ad 100755
--- a/t/t5550-http-fetch-dumb.sh
+++ b/t/t5550-http-fetch-dumb.sh
@@ -263,15 +263,18 @@ check_language () {
>expect
;;
?*)
-   echo "Accept-Language: $1" >expect
+   echo "=> Send header: Accept-Language: $1" >expect
;;
esac &&
-   GIT_CURL_VERBOSE=1 \
+   GIT_TRACE_CURL=true \
LANGUAGE=$2 \
git ls-remote "$HTTPD_URL/dumb/repo.git" >output 2>&1 &&
tr -d '\015' actual &&
+   sed -ne '/^=> Send header: Accept-Language:/ p' >actual &&
+   cp expect expect.$$ &&
+   cp actual actual.$$ &&
+   cp output output.$$ &&
test_cmp expect actual
 }
 
@@ -295,8 +298,8 @@ ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, 
*;q=0.90" \
 '
 
 test_expect_success 'git client does not send an empty Accept-Language' '
-   GIT_CURL_VERBOSE=1 LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 
2>stderr &&
-   ! grep "^Accept-Language:" stderr
+   GIT_TRACE_CURL=true LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 
2>stderr &&
+   ! grep "^=> Send header: Accept-Language:" stderr
 '
 
 stop_httpd
-- 
2.10.0.308.gf73994d



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

2016-06-15 Thread Elia Pinto
2016-06-15 0:08 GMT+02:00 Junio C Hamano :
> Here are the topics that have been cooking.  Commits prefixed with
> '-' are only in 'pu' (proposed updates) while commits prefixed with
> '+' are in 'next'.  The ones marked with '.' do not appear in any of
> the integration branches, but I am still holding onto them.
>
> Git 2.9 has been tagged.  Let's wait for a few days to clean up
> possible fallout and then start a new cycle by rewinding the tip of
> 'next'.  I expect I'd eject a few premature topics out of 'next'
> while doing so.
>
> You can find the changes described here in the integration branches
> of the repositories listed at
>
> http://git-blame.blogspot.com/p/git-public-repositories.html
>
> --
> [Graduated to "master"]
>
> * jc/t2300-setup (2016-06-01) 1 commit
>   (merged to 'next' on 2016-06-06 at 20f7f83)
>  + t2300: run git-sh-setup in an environment that better mimics the real life
>  (this branch is used by va/i18n-even-more.)
>
>  A test fix.
>
>
> * jk/diff-compact-heuristic (2016-06-10) 1 commit
>  - diff: disable compaction heuristic for now
>
>  It turns out that the earlier effort to update the heuristics may
>  want to use a bit more time to mature.  Turn it off by default.
>
>
> * jk/shell-portability (2016-06-01) 2 commits
>   (merged to 'next' on 2016-06-06 at 5de784e)
>  + t5500 & t7403: lose bash-ism "local"
>  + test-lib: add in-shell "env" replacement
>
>  test fixes.
>
> --
> [New Topics]
>
> * lv/status-say-working-tree-not-directory (2016-06-09) 1 commit
>  - Use "working tree" instead of "working directory" for git status
>
>  "git status" used to say "working directory" when it meant "working
>  tree".
>
>  Will merge to 'next'.
>
>
> * jk/parseopt-string-list (2016-06-13) 3 commits
>  - blame,shortlog: don't make local option variables static
>  - interpret-trailers: don't duplicate option strings
>  - parse_opt_string_list: stop allocating new strings
>  (this branch is used by jk/string-list-static-init.)
>
>  The command line argument parsing that uses OPT_STRING_LIST() often
>  made a copy of the argv[] element, which was unnecessary.
>
>  Will merge to 'next'.
>
>
> * jk/repack-keep-unreachable (2016-06-14) 3 commits
>  - repack: extend --keep-unreachable to loose objects
>  - repack: add --keep-unreachable option
>  - repack: document --unpack-unreachable option
>
>  "git repack" learned the "--keep-unreachable" option, which sends
>  loose unreachable objects to a pack instead of leaving them loose.
>  This helps heuristics based on the number of loose objects
>  (e.g. "gc --auto").
>
>  Will merge to 'next'.
>
>
> * lf/recv-sideband-cleanup (2016-06-13) 1 commit
>  - sideband.c: refactor recv_sideband()
>
>  Code simplification.  It however loses the atomicity of the output
>  9ac13ec9 (atomic write for sideband remote messages, 2006-10-11)
>  tried to add to an once-much-simpler codebase.
>
>  Expecting a reroll.
>
>
> * nd/test-lib-httpd-show-error-log-in-verbose (2016-06-13) 1 commit
>  - lib-httpd.sh: print error.log on error
>
>  Debugging aid.
>
>  Will merge to 'next'.
>
>
> * pc/occurred (2016-06-10) 2 commits
>  - config.c: fix misspelt "occurred" in an error message
>  - refs.h: fix misspelt "occurred" in a comment
>
>  Will merge to 'next'.
>
>
> * sb/submodule-clone-retry (2016-06-13) 2 commits
>  - submodule update: continue when a clone fails
>  - submodule--helper: initial clone learns retry logic
>  (this branch uses sb/submodule-recommend-shallowness.)
>
>  "git submodule update" that drives many "git clone" could
>  eventually hit flaky servers/network conditions on one of the
>  submodules; the command learned to retry the attempt.
>
>
> * jc/blame-reverse (2016-06-14) 2 commits
>  - blame: dwim "blame --reverse OLD" as "blame --reverse OLD.."
>  - blame: improve diagnosis for "--reverse NEW"
>
>
> * jc/deref-tag (2016-06-14) 1 commit
>  - blame, line-log: do not loop around deref_tag()
>
>  Code clean-up.
>
>  Will merge to 'next'.
>
>
> * jk/fetch-prune-doc (2016-06-14) 1 commit
>  - fetch: document that pruning happens before fetching
>
>  Will merge to 'next'.
>
>
> * km/fetch-do-not-free-remote-name (2016-06-14) 1 commit
>  - builtin/fetch.c: don't free remote->name after fetch
>
>  Will merge to 'next'.
>
>
> * nb/gnome-keyring-build (2016-06-14) 1 commit
>  - gnome-keyring: Don't hard-code pkg-config executable
>
>  Build improvements for gnome-keyring (in contrib/)
>
>  Will merge to 'next'.
>
>
> * pb/strbuf-read-file-doc (2016-06-14) 1 commit
>  - strbuf: describe the return value of strbuf_read_file
>
>  Will merge to 'next'.
>
> --
> [Stalled]
>
> * sb/bisect (2016-04-15) 22 commits
>  - SQUASH???
>  - bisect: get back halfway shortcut
>  - bisect: compute best bisection in compute_relevant_weights()
>  - bisect: use a bottom-up traversal to find relevant weights
>  - bisect: prepare fo

[PATCH 02/10] builtin/index-pack.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 builtin/index-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index e8c71fc..c032fe7 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1443,7 +1443,7 @@ static void final(const char *final_pack_name, const char 
*curr_pack_name,
printf("%s\n", sha1_to_hex(sha1));
} else {
char buf[48];
-   int len = snprintf(buf, sizeof(buf), "%s\t%s\n",
+   int len = xsnprintf(buf, sizeof(buf), "%s\t%s\n",
   report, sha1_to_hex(sha1));
write_or_die(1, buf, len);
 
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/10] fast-import.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 fast-import.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fast-import.c b/fast-import.c
index 59630ce..5beb63d 100644
--- a/fast-import.c
+++ b/fast-import.c
@@ -1240,10 +1240,7 @@ static void stream_blob(uintmax_t len, unsigned char 
*sha1out, uintmax_t mark)
sha1file_checkpoint(pack_file, &checkpoint);
offset = checkpoint.offset;
 
-   hdrlen = snprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1;
-   if (out_sz <= hdrlen)
-   die("impossibly large object header");
-
+   hdrlen = xsnprintf((char *)out_buf, out_sz, "blob %" PRIuMAX, len) + 1;
git_SHA1_Init(&c);
git_SHA1_Update(&c, out_buf, hdrlen);
 
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/10] diff.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 diff.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/diff.c b/diff.c
index d3734d3..fb61539 100644
--- a/diff.c
+++ b/diff.c
@@ -4491,7 +4491,7 @@ static int diff_get_patch_id(struct diff_options 
*options, unsigned char *sha1)
len1 = remove_space(p->one->path, strlen(p->one->path));
len2 = remove_space(p->two->path, strlen(p->two->path));
if (p->one->mode == 0)
-   len1 = snprintf(buffer, sizeof(buffer),
+   len1 = xsnprintf(buffer, sizeof(buffer),
"diff--gita/%.*sb/%.*s"
"newfilemode%06o"
"---/dev/null"
@@ -4501,7 +4501,7 @@ static int diff_get_patch_id(struct diff_options 
*options, unsigned char *sha1)
p->two->mode,
len2, p->two->path);
else if (p->two->mode == 0)
-   len1 = snprintf(buffer, sizeof(buffer),
+   len1 = xsnprintf(buffer, sizeof(buffer),
"diff--gita/%.*sb/%.*s"
"deletedfilemode%06o"
"---a/%.*s"
@@ -4511,7 +4511,7 @@ static int diff_get_patch_id(struct diff_options 
*options, unsigned char *sha1)
p->one->mode,
len1, p->one->path);
else
-   len1 = snprintf(buffer, sizeof(buffer),
+   len1 = xsnprintf(buffer, sizeof(buffer),
"diff--gita/%.*sb/%.*s"
"---a/%.*s"
"+++b/%.*s",
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/10] wrapper.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 wrapper.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/wrapper.c b/wrapper.c
index 5dc4e15..0d44835 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -433,16 +433,11 @@ int xmkstemp(char *template)
 int git_mkstemp(char *path, size_t len, const char *template)
 {
const char *tmp;
-   size_t n;
 
tmp = getenv("TMPDIR");
if (!tmp)
tmp = "/tmp";
-   n = snprintf(path, len, "%s/%s", tmp, template);
-   if (len <= n) {
-   errno = ENAMETOOLONG;
-   return -1;
-   }
+   (void)xsnprintf(path, len, "%s/%s", tmp, template);
return mkstemp(path);
 }
 
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/10] combine-diff.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 combine-diff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/combine-diff.c b/combine-diff.c
index 8f2313d..a91d9b3 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -293,7 +293,7 @@ static char *grab_blob(const struct object_id *oid, 
unsigned int mode,
 
if (S_ISGITLINK(mode)) {
blob = xmalloc(100);
-   *size = snprintf(blob, 100,
+   *size = xsnprintf(blob, 100,
 "Subproject commit %s\n", oid_to_hex(oid));
} else if (is_null_oid(oid)) {
/* deleted blob */
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/10] compat/inet_ntop.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 compat/inet_ntop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/inet_ntop.c b/compat/inet_ntop.c
index 6830726..a4a6546 100644
--- a/compat/inet_ntop.c
+++ b/compat/inet_ntop.c
@@ -139,7 +139,7 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
tp += strlen(tp);
break;
}
-   tp += snprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]);
+   tp += xsnprintf(tp, sizeof tmp - (tp - tmp), "%x", words[i]);
}
/* Was it a trailing run of 0x00's? */
if (best.base != -1 && (best.base + best.len) ==
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/10] builtin/tag.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 builtin/tag.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/tag.c b/builtin/tag.c
index 50e4ae5..0345ca3 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -225,7 +225,7 @@ static void create_tag(const unsigned char *object, const 
char *tag,
if (type <= OBJ_NONE)
die(_("bad object type."));
 
-   header_len = snprintf(header_buf, sizeof(header_buf),
+   header_len = xsnprintf(header_buf, sizeof(header_buf),
  "object %s\n"
  "type %s\n"
  "tag %s\n"
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/10] builtin/commit.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 builtin/commit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 443ff91..c65abaa 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -1552,7 +1552,7 @@ static int run_rewrite_hook(const unsigned char *oldsha1,
code = start_command(&proc);
if (code)
return code;
-   n = snprintf(buf, sizeof(buf), "%s %s\n",
+   n = xsnprintf(buf, sizeof(buf), "%s %s\n",
 sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
sigchain_push(SIGPIPE, SIG_IGN);
write_in_full(proc.in, buf, n);
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/10] transport-helper.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 transport-helper.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/transport-helper.c b/transport-helper.c
index bd666b2..18e9f44 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -317,9 +317,7 @@ static void standard_options(struct transport *t)
 
set_helper_option(t, "progress", t->progress ? "true" : "false");
 
-   n = snprintf(buf, sizeof(buf), "%d", v + 1);
-   if (n >= sizeof(buf))
-   die("impossibly large verbosity value");
+   n = xsnprintf(buf, sizeof(buf), "%d", v + 1);
set_helper_option(t, "verbosity", buf);
 
switch (t->family) {
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/10] refs.c: convert trivial snprintf calls to xsnprintf

2016-06-03 Thread Elia Pinto
With the commits f2f02675 and 5096d490 we have been converted in some files the 
call
from snprintf/sprintf/strcpy to xsnprintf. This patch converts the remaining 
calls
to snprintf with xsnprintf under the following conditions:

- The call to snprintf does not control the outcome of the command
  or the presence of truncation errors.
- A call to snprintf can generate a fatal error, directly or indirectly.

The other few remaining cases in which a call to snprintf can generate a soft 
error
have not been changed.

Signed-off-by: Elia Pinto 
---
 refs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/refs.c b/refs.c
index 87dc82f..c797ea0 100644
--- a/refs.c
+++ b/refs.c
@@ -912,7 +912,7 @@ char *shorten_unambiguous_ref(const char *refname, int 
strict)
for (i = 0; i < nr_rules; i++) {
assert(offset < total_len);
scanf_fmts[i] = (char *)&scanf_fmts[nr_rules] + offset;
-   offset += snprintf(scanf_fmts[i], total_len - offset,
+   offset += xsnprintf(scanf_fmts[i], total_len - offset,
   ref_rev_parse_rules[i], 2, "%s") + 1;
}
}
-- 
2.9.0.rc1.265.geb5d750

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 1/2] http.c: implement the GIT_TRACE_CURL environment variable

2016-05-23 Thread Elia Pinto
Implement the GIT_TRACE_CURL environment variable to allow a
greater degree of detail of GIT_CURL_VERBOSE, in particular
the complete transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more
thorough debugging analysis. Document the new GIT_TRACE_CURL
environment variable.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 Documentation/git.txt |   8 
 http.c| 125 +-
 http.h|   2 +
 3 files changed, 133 insertions(+), 2 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index dd6dbf7..a46a356 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -1077,6 +1077,14 @@ of clones and fetches.
cloning of shallow repositories.
See 'GIT_TRACE' for available trace output options.
 
+'GIT_TRACE_CURL'::
+   Enables a curl full trace dump of all incoming and outgoing data,
+   including descriptive information, of the git transport protocol.
+   This is similar to doing curl --trace-ascii on the command line.
+   This option overrides setting the GIT_CURL_VERBOSE environment
+   variable.
+   See 'GIT_TRACE' for available trace output options.
+
 'GIT_LITERAL_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs literally, rather than as glob patterns. For example,
diff --git a/http.c b/http.c
index df6dd01..d661408 100644
--- a/http.c
+++ b/http.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "transport.h"
 
+static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
 #if LIBCURL_VERSION_NUM >= 0x070a08
 long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
 #else
@@ -477,6 +478,126 @@ static void set_curl_keepalive(CURL *c)
 }
 #endif
 
+static void redact_sensitive_header(struct strbuf *header)
+{
+   const char *sensitive_header;
+
+   if (skip_prefix(header->buf, "Authorization:", &sensitive_header) ||
+   skip_prefix(header->buf, "Proxy-Authorization:", 
&sensitive_header)) {
+   /* The first token is the type, which is OK to log */
+   while (isspace(*sensitive_header))
+   sensitive_header++;
+   while (*sensitive_header && !isspace(*sensitive_header))
+   sensitive_header++;
+   /* Everything else is opaque and possibly sensitive */
+   strbuf_setlen(header,  sensitive_header - header->buf);
+   strbuf_addstr(header, " ");
+   }
+}
+
+static void curl_dump_header(const char *text, unsigned char *ptr, size_t 
size, int hide_sensitive_header)
+{
+   struct strbuf out = STRBUF_INIT;
+   const char *sensitive_header;
+   struct strbuf **headers, **header;
+
+   strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+   trace_strbuf(&trace_curl, &out);
+   strbuf_reset(&out);
+   strbuf_add(&out, ptr, size);
+   headers = strbuf_split_max(&out, '\n', 0);
+
+   for (header = headers; *header; header++) {
+   if (hide_sensitive_header)
+   redact_sensitive_header(*header);
+   strbuf_insert((*header), 0, text, strlen(text));
+   strbuf_insert((*header), strlen(text), ": ", 2);
+   strbuf_rtrim((*header));
+   strbuf_addch((*header), '\n');
+   trace_strbuf(&trace_curl, (*header));
+   }
+   strbuf_list_free(headers);
+   strbuf_release(&out);
+}
+
+static void curl_dump_data(const char *text, unsigned char *ptr, size_t size)
+{
+   size_t i;
+   struct strbuf out = STRBUF_INIT;
+   unsigned int width = 60;
+
+   strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+   trace_strbuf(&trace_curl, &out);
+
+   for (i = 0; i < size; i += width) {
+   size_t w;
+
+   strbuf_reset(&out);
+   strbuf_addf(&out, "%s: ", text);
+   for (w = 0; (w < width) && (i + w < size); w++) {
+   unsigned char ch = ptr[i + w];
+
+   strbuf_addch(&out,
+  (ch >= 0x20) && (ch < 0x80)
+  ? ch : '.');
+   }
+   strbuf_addch(&out, '\n');
+   trace_strbuf(&trace_curl, &out);
+   }
+   strbuf_release(&out);
+}
+
+static int curl_trace(CURL *handle, curl_infotype type, char 

[PATCH v7 2/2] imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

2016-05-23 Thread Elia Pinto
Permit the use of the GIT_TRACE_CURL environment variable calling
the setup_curl_trace http.c helper routine.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 imap-send.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/imap-send.c b/imap-send.c
index 938c691..50377c5 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1443,6 +1443,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
 
if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+   setup_curl_trace(curl);
 
return curl;
 }
-- 
2.8.3.614.g2da74fb.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v7 0/2] Implement the GIT_TRACE_CURL environment variable

2016-05-23 Thread Elia Pinto
This is the  seventh version but in reality is the complete rewriting of the 
patches discussed here
(here called V1)

$gmane/290520
$gmane/290521

*Changes from V6
($gmane/295158)
- updated with junio suggestions ($gmane/295207)
  * http.c: add redact_sensitive_header() helper
  * http.c: renamed  header_list and ptr_list to
headers and header
  * http.c: reduce width in curl_dump_data
  * http.c: curl_dump_data. cut strbuf_addch at a sensible place
  * http.c: drop the nopriv_header variable: add an enum instead


*Changes from V5
($gmane/293236)

- don't export curl_trace anymore. Define it static
- fix a minor cleanup (style) in setup_curl_trace
- and, finally, i rewrote completely curl_dump, separating it
into two functions (one for http header and one for the http data),
hoping for a coherent implementation with curl --ascii-trace output
but easier to read than the previous implementation that
used a hard-to-read double-loop.

 
*Changes from V4
($gmane/292867)

-  add a better abstraction with the routine setup_curl_trace
-  curl_dump : drop the noex parameter, define nopriv boolean as int
-  use decimal constant where appropiate
-  fix multi-line comment
-  redo the authorization header skip with a replace of possible sensitive data.
   We prefer to print only:
   09:00:53.238330 http.c:534  => Send header: Authorization:  

   intested of
   09:00:53.238330 http.c:534  => Send header: Authorization:  
Basic(o other scheme) 
   as it was done in the original proposed suggestion by Jeff King.
   This is because i think it's better not to print even the authorization 
scheme.
   We add also the (previously missing) proxy-authorization case
-  curl_dump: fix strbuf memory leak

as suggested by Jeff King
($gmane/292891)
($gmane/292892)

In this series i keep the original curl_dump parsing code, even though it is
objectively difficult to read. This is because the same code is used internally 
by curl
to do "ascii-trace" and is also reported in the libcurl code examples and test.
I think this may make maintenance of code easier in the future (libcurl
new dev, new features and so on)

Of course if the maintainer (or other) believes it is really necessary
to rewrite the above code to accept the patches i will do.

*Changes from V3
($gmane/292040)

- add missing static to curl_dump
- reorder the patch order
- tried to fix all (but i am not sure) the problems reported by Julio 
($gmane/292055)
- * squash the documentation with the http.c commit.
  * in the trace prefix each line to indicate it is about sending a header, and 
drop the
initial hex count
  * auto-censor Authorization headers by default

as suggested by Jeff King ($gmane/292074)

*Changes from V2
($gmane/291868)

- fix garbage comment in http.c (i am very sorry for that)
- add final '.' to the commit message for imap-send.c and to other commit 
messages
- typofix double ; in http.c
- merge the nice cleanup and code refactoring of Ramsay Jones (Thank you very 
much !!)
- squash the previous commit 2/4

*Changes from V1

- introduced GIT_TRACE_CURL variable with its documentation
- changed the name of the temporary variable "i" in "w" in the helper routine
- used the c escape sequences instead of the hex equivalent
- dropped the previous GIT_DEBUG_CURL env var
- curl_dump and curl_trace factored out to a shared implementation
in http.c



Elia Pinto (2):
  http.c: implement the GIT_TRACE_CURL environment variable
  imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

 Documentation/git.txt |   8 
 http.c| 125 +-
 http.h|   2 +
 imap-send.c   |   1 +
 4 files changed, 134 insertions(+), 2 deletions(-)

-- 
2.8.3.614.g2da74fb.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 0/2] Implement the GIT_TRACE_CURL environment variable

2016-05-20 Thread Elia Pinto
This is the sixty version but in reality is the complete rewriting of the 
patches discussed here
(here called V1)

$gmane/290520
$gmane/290521

*Changes from V5
($gmane/293236)

- don't export curl_trace anymore. Define it static
- fix a minor cleanup (style) in setup_curl_trace
- and, finally, i rewrote completely curl_dump, separating it
into two functions (one for http header and one for the http data),
hoping for a coherent implementation with curl --ascii-trace output
but easier to read than the previous implementation that
used a hard-to-read double-loop.

 
*Changes from V4
($gmane/292867)

-  add a better abstraction with the routine setup_curl_trace
-  curl_dump : drop the noex parameter, define nopriv boolean as int
-  use decimal constant where appropiate
-  fix multi-line comment
-  redo the authorization header skip with a replace of possible sensitive data.
   We prefer to print only:
   09:00:53.238330 http.c:534  => Send header: Authorization:  

   intested of
   09:00:53.238330 http.c:534  => Send header: Authorization:  
Basic(o other scheme) 
   as it was done in the original proposed suggestion by Jeff King.
   This is because i think it's better not to print even the authorization 
scheme.
   We add also the (previously missing) proxy-authorization case
-  curl_dump: fix strbuf memory leak

as suggested by Jeff King
($gmane/292891)
($gmane/292892)

In this series i keep the original curl_dump parsing code, even though it is
objectively difficult to read. This is because the same code is used internally 
by curl
to do "ascii-trace" and is also reported in the libcurl code examples and test.
I think this may make maintenance of code easier in the future (libcurl
new dev, new features and so on)

Of course if the maintainer (or other) believes it is really necessary
to rewrite the above code to accept the patches i will do.

*Changes from V3
($gmane/292040)

- add missing static to curl_dump
- reorder the patch order
- tried to fix all (but i am not sure) the problems reported by Julio 
($gmane/292055)
- * squash the documentation with the http.c commit.
  * in the trace prefix each line to indicate it is about sending a header, and 
drop the
initial hex count
  * auto-censor Authorization headers by default

as suggested by Jeff King ($gmane/292074)

*Changes from V2
($gmane/291868)

- fix garbage comment in http.c (i am very sorry for that)
- add final '.' to the commit message for imap-send.c and to other commit 
messages
- typofix double ; in http.c
- merge the nice cleanup and code refactoring of Ramsay Jones (Thank you very 
much !!)
- squash the previous commit 2/4

*Changes from V1

- introduced GIT_TRACE_CURL variable with its documentation
- changed the name of the temporary variable "i" in "w" in the helper routine
- used the c escape sequences instead of the hex equivalent
- dropped the previous GIT_DEBUG_CURL env var
- curl_dump and curl_trace factored out to a shared implementation
in http.c




Elia Pinto (2):
  http.c: implement the GIT_TRACE_CURL environment variable
  imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

 Documentation/git.txt |   8 
 http.c| 123 +-
 http.h|   2 +
 imap-send.c   |   1 +
 4 files changed, 132 insertions(+), 2 deletions(-)

-- 
2.8.2.435.g7c6234f.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 2/2] imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

2016-05-20 Thread Elia Pinto
Permit the use of the GIT_TRACE_CURL environment variable calling
the setup_curl_trace http.c helper routine.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 imap-send.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/imap-send.c b/imap-send.c
index 938c691..50377c5 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1443,6 +1443,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
 
if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+   setup_curl_trace(curl);
 
return curl;
 }
-- 
2.8.2.435.g7c6234f.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v6 1/2] http.c: implement the GIT_TRACE_CURL environment variable

2016-05-20 Thread Elia Pinto
Implement the GIT_TRACE_CURL environment variable to allow a
greater degree of detail of GIT_CURL_VERBOSE, in particular
the complete transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more
thorough debugging analysis. Document the new GIT_TRACE_CURL
environment variable.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 Documentation/git.txt |   8 
 http.c| 124 +-
 http.h|   2 +
 3 files changed, 132 insertions(+), 2 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index dd6dbf7..a46a356 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -1077,6 +1077,14 @@ of clones and fetches.
cloning of shallow repositories.
See 'GIT_TRACE' for available trace output options.
 
+'GIT_TRACE_CURL'::
+   Enables a curl full trace dump of all incoming and outgoing data,
+   including descriptive information, of the git transport protocol.
+   This is similar to doing curl --trace-ascii on the command line.
+   This option overrides setting the GIT_CURL_VERBOSE environment
+   variable.
+   See 'GIT_TRACE' for available trace output options.
+
 'GIT_LITERAL_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs literally, rather than as glob patterns. For example,
diff --git a/http.c b/http.c
index df6dd01..ba32bac 100644
--- a/http.c
+++ b/http.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "transport.h"
 
+static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
 #if LIBCURL_VERSION_NUM >= 0x070a08
 long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
 #else
@@ -477,6 +478,125 @@ static void set_curl_keepalive(CURL *c)
 }
 #endif
 
+static void curl_dump_header(const char *text, unsigned char *ptr, size_t 
size, int nopriv_header)
+{
+   struct strbuf out = STRBUF_INIT;
+   const char *header;
+   struct strbuf **header_list, **ptr_list;
+
+   strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+   trace_strbuf(&trace_curl, &out);
+   strbuf_reset(&out);
+   strbuf_add(&out,ptr,size);
+   header_list = strbuf_split_max(&out, '\n', 0);
+
+   for (ptr_list = header_list; *ptr_list; ptr_list++) {
+   /*
+* if we are called with nopriv_header substitute a dummy value
+* in the Authorization or Proxy-Authorization http header if
+* present.
+*/
+   if (nopriv_header &&
+   (skip_prefix((*ptr_list)->buf , "Authorization:", &header)
+   || skip_prefix((*ptr_list)->buf , "Proxy-Authorization:", 
&header))) { 
+   /* The first token is the type, which is OK to log */
+   while (isspace(*header))
+   header++;
+   while (*header && !isspace(*header))
+   header++;
+   /* Everything else is opaque and possibly sensitive */
+   strbuf_setlen((*ptr_list),  header - (*ptr_list)->buf );
+   strbuf_addstr((*ptr_list), " ");
+   }
+   strbuf_insert((*ptr_list), 0, text, strlen(text));
+   strbuf_insert((*ptr_list), strlen(text), ": ", 2);
+   strbuf_rtrim((*ptr_list));
+   strbuf_addch((*ptr_list), '\n');
+   trace_strbuf(&trace_curl, (*ptr_list));
+   }
+   strbuf_list_free(header_list);
+   strbuf_release(&out);
+}
+static void curl_dump_data(const char *text, unsigned char *ptr, size_t size)
+{
+   size_t i;
+   struct strbuf out = STRBUF_INIT;
+   unsigned int width = 80;
+
+   strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+   trace_strbuf(&trace_curl, &out);
+
+   for (i = 0; i < size; i += width) {
+   size_t w;
+
+   strbuf_reset(&out);
+   strbuf_addf(&out, "%s: ", text);
+   for (w = 0; (w < width) && (i + w < size); w++) {
+   strbuf_addch(&out, (ptr[i + w] >= 0x20)
+   && (ptr[i + w] < 0x80) ? ptr[i + w] : '.');
+   }
+   strbuf_addch(&out, '\n');
+   trace_strbuf(&trace_curl, &out);
+   }
+   strbuf_release(&out);
+}
+
+static int curl_trace(CURL *handle, curl_infotype type, char *data, size_t 
size, void *userp)
+{
+   const char *text;
+   int nopriv_header = 0;  /*
+* default: there ar

[PATCHv5 1/2] http.c: implement the GIT_TRACE_CURL environment variable

2016-05-02 Thread Elia Pinto
Implement the GIT_TRACE_CURL environment variable to allow a
greater degree of detail of GIT_CURL_VERBOSE, in particular
the complete transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more
thorough debugging analysis. Document the new GIT_TRACE_CURL
environment variable.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 Documentation/git.txt |   8 
 http.c| 115 +-
 http.h|   4 ++
 3 files changed, 125 insertions(+), 2 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index 34ff007..5e59576 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -1076,6 +1076,14 @@ of clones and fetches.
cloning of shallow repositories.
See 'GIT_TRACE' for available trace output options.
 
+'GIT_TRACE_CURL'::
+   Enables a curl full trace dump of all incoming and outgoing data,
+   including descriptive information, of the git transport protocol.
+   This is similar to doing curl --trace-ascii on the command line.
+   This option overrides setting the GIT_CURL_VERBOSE environment
+   variable.
+   See 'GIT_TRACE' for available trace output options.
+
 'GIT_LITERAL_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs literally, rather than as glob patterns. For example,
diff --git a/http.c b/http.c
index 985b995..5e2bc19 100644
--- a/http.c
+++ b/http.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "transport.h"
 
+static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
 #if LIBCURL_VERSION_NUM >= 0x070a08
 long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
 #else
@@ -478,6 +479,116 @@ static void set_curl_keepalive(CURL *c)
 }
 #endif
 
+static void curl_dump(const char *text, unsigned char *ptr, size_t size, int 
nopriv)
+{
+   size_t i;
+   struct strbuf out = STRBUF_INIT;
+   unsigned int width = 80;
+
+   strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+   trace_strbuf(&trace_curl, &out);
+
+   for (i = 0; i < size; i += width) {
+   size_t w;
+   size_t prefix_len;
+   const char *header;
+
+   strbuf_reset(&out);
+   strbuf_addf(&out, "%s: ", text);
+   prefix_len = out.len;
+   for (w = 0; (w < width) && (i + w < size); w++) {
+   if ((i + w + 1 < size) && ptr[i + w] == '\r'
+   && ptr[i + w + 1] == '\n') {
+   i += (w + 2 - width);
+   break;
+   }
+   strbuf_addch(&out, (ptr[i + w] >= 0x20)
+   && (ptr[i + w] < 0x80) ? ptr[i + w] : '.');
+   if ((i + w + 2 < size)
+   && ptr[i + w + 1] == '\r'
+   && ptr[i + w + 2] == '\n') {
+   i += (w + 3 - width);
+   break;
+   }
+   }
+
+   /*
+* if we are called with nopriv substitute a dummy value
+* in the Authorization or Proxy-Authorization http header if
+* present.
+*/
+   if (nopriv &&
+   (skip_prefix(out.buf + prefix_len, "Authorization:", 
&header)
+   || skip_prefix(out.buf + prefix_len, 
"Proxy-Authorization:", &header))) {
+   /* The first token is the type, which is OK to log */
+   while (isspace(*header))
+   header++;
+   /* Everything else is opaque and possibly sensitive */
+   strbuf_setlen(&out, header - out.buf);
+   strbuf_addstr(&out, " ");
+   }
+   strbuf_addch(&out, '\n');
+   trace_strbuf(&trace_curl, &out);
+   }
+   strbuf_release(&out);
+}
+
+void setup_curl_trace(CURL *handle)
+{
+   if (!trace_want(&trace_curl)) return;
+   curl_easy_setopt(handle, CURLOPT_VERBOSE, 1L);
+   curl_easy_setopt(handle, CURLOPT_DEBUGFUNCTION, curl_trace);
+   curl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);
+}
+
+int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size, void 
*userp)
+{
+   const char *text;
+   (void)handle;   /* prevent

[PATCHv5 0/2] Implement the GIT_TRACE_CURL environment variable

2016-05-02 Thread Elia Pinto
This is the fifth version but in reality is the complete rewriting of the 
patches discussed here
(here called V1)

$gmane/290520
$gmane/290521

*Changes from V4
($gmane/292867)

-  add a better abstraction with the routine setup_curl_trace
-  curl_dump : drop the noex parameter, define nopriv boolean as int
-  use decimal constant where appropiate
-  fix multi-line comment
-  redo the authorization header skip with a replace of possible sensitive 
data. 
   We prefer to print only:
   09:00:53.238330 http.c:534  => Send header: Authorization:  

   intested of 
   09:00:53.238330 http.c:534  => Send header: Authorization:  
Basic(o other scheme) 
   as it was done in the original proposed suggestion by Jeff King. 
   This is because i think it's better not to print even the authorization 
scheme.
   We add also the (previously missing) proxy-authorization case
-  curl_dump: fix strbuf memory leak 

as suggested by Jeff King 
($gmane/292891) 
($gmane/292892) 

In this series i keep the original curl_dump parsing code, even though it is 
objectively difficult to read. This is because the same code is used internally 
by curl 
to do "ascii-trace" and is also reported in the libcurl code examples and test. 
I think this may make maintenance of code easier in the future (libcurl 
new dev, new features and so on) 

Of course if the maintainer (or other) believes it is really necessary 
to rewrite the above code to accept the patches i will do.

*Changes from V3
($gmane/292040)

- add missing static to curl_dump
- reorder the patch order
- tried to fix all (but i am not sure) the problems reported by Julio 
($gmane/292055)
- * squash the documentation with the http.c commit.
  * in the trace prefix each line to indicate it is about sending a header, and 
drop the
initial hex count
  * auto-censor Authorization headers by default

as suggested by Jeff King ($gmane/292074)

*Changes from V2
($gmane/291868)

- fix garbage comment in http.c (i am very sorry for that)
- add final '.' to the commit message for imap-send.c and to other commit 
messages
- typofix double ; in http.c
- merge the nice cleanup and code refactoring of Ramsay Jones (Thank you very 
much !!)
- squash the previous commit 2/4

*Changes from V1

- introduced GIT_TRACE_CURL variable with its documentation
- changed the name of the temporary variable "i" in "w" in the helper routine
- used the c escape sequences instead of the hex equivalent
- dropped the previous GIT_DEBUG_CURL env var
- curl_dump and curl_trace factored out to a shared implementation
in http.c


Elia Pinto (2):
  http.c: implement the GIT_TRACE_CURL environment variable
  imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

 Documentation/git.txt |   8 
 http.c| 115 +-
 http.h|   4 ++
 imap-send.c   |   1 +
 4 files changed, 126 insertions(+), 2 deletions(-)

-- 
2.8.2.435.ga07a3e0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv5 2/2] imap-send.c: introduce the GIT_TRACE_CURL environment variable

2016-05-02 Thread Elia Pinto
Permit the use of the GIT_TRACE_CURL environment variable calling
the curl_trace and curl_dump http.c helper routine.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 imap-send.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/imap-send.c b/imap-send.c
index 938c691..50377c5 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1443,6 +1443,7 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
 
if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+   setup_curl_trace(curl);
 
return curl;
 }
-- 
2.8.2.435.ga07a3e0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv4 2/2] imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

2016-04-28 Thread Elia Pinto
Permit the use of the GIT_TRACE_CURL environment variable calling
the curl_trace and curl_dump http.c helper routine.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 imap-send.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/imap-send.c b/imap-send.c
index 938c691..61c6787 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1444,6 +1444,12 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
 
+   if (curl_trace_want()) {
+   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+   curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curl_trace);
+   curl_easy_setopt(curl, CURLOPT_DEBUGDATA, NULL);
+   }
+
return curl;
 }
 
-- 
2.8.1.487.gf8c3767.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv4 1/2] http.c: implement the GIT_TRACE_CURL environment variable

2016-04-28 Thread Elia Pinto
Implement the GIT_TRACE_CURL environment variable to allow a
greater degree of detail of GIT_CURL_VERBOSE, in particular
the complete transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more
thorough debugging analysis. Document the new GIT_TRACE_CURL
environment variable.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 Documentation/git.txt |   8 
 http.c| 109 +-
 http.h|   4 ++
 3 files changed, 120 insertions(+), 1 deletion(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index 8afe349..958db0f 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -1075,6 +1075,14 @@ of clones and fetches.
cloning of shallow repositories.
See 'GIT_TRACE' for available trace output options.
 
+'GIT_TRACE_CURL'::
+   Enables a curl full trace dump of all incoming and outgoing data,
+   including descriptive information, of the git transport protocol.
+   This is similar to doing curl --trace-ascii on the command line.
+   This option overrides setting the GIT_CURL_VERBOSE environment
+   variable.
+   See 'GIT_TRACE' for available trace output options.
+
 'GIT_LITERAL_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs literally, rather than as glob patterns. For example,
diff --git a/http.c b/http.c
index 985b995..5c2c729 100644
--- a/http.c
+++ b/http.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "transport.h"
 
+static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
 #if LIBCURL_VERSION_NUM >= 0x070a08
 long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
 #else
@@ -478,6 +479,108 @@ static void set_curl_keepalive(CURL *c)
 }
 #endif
 
+static void curl_dump(const char *text, unsigned char *ptr, size_t size, char 
nohex, char nopriv)
+{
+   size_t i;
+   struct strbuf out = STRBUF_INIT;
+   unsigned int width = 0x10;
+
+   /* without the hex output, we can fit more on screen */
+   if (nohex) width = 0x50;
+
+   strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+   trace_strbuf(&trace_curl, &out);
+   strbuf_reset(&out);
+
+   for (i = 0; i < size; i += width) {
+   size_t w;
+   strbuf_addf(&out, "%s: ", text);
+   if (!nohex) {
+   for (w = 0; w < width; w++)
+   if (i + w < size)
+   strbuf_addf(&out, "%02x ", ptr[i + w]);
+   else
+   strbuf_addf(&out,"   ");
+   }
+   for (w = 0; (w < width) && (i + w < size); w++) {
+   if (nohex && (i + w + 1 < size) && ptr[i + w] == '\r'
+   && ptr[i + w + 1] == '\n') {
+   i += (w + 2 - width);
+   break;
+   }
+   strbuf_addch(&out, (ptr[i + w] >= 0x20)
+   && (ptr[i + w] < 0x80) ? ptr[i + w] : '.');
+   if (nohex && (i + w + 2 < size)
+   && ptr[i + w + 1] == '\r'
+   && ptr[i + w + 2] == '\n') {
+   i += (w + 3 - width);
+   break;
+   }
+   }
+   /* if we are called with nopriv we skip the Authorization field 
if present
+* and print a blank line
+   */
+   if ( nopriv && strstr(out.buf, "Authorization:"))
+   strbuf_reset(&out);
+
+   strbuf_addch(&out, '\n');
+   trace_strbuf(&trace_curl, &out);
+   strbuf_release(&out);
+   }
+}
+
+int curl_trace_want(void)
+{
+   return trace_want(&trace_curl);
+}
+
+int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size, void 
*userp)
+{
+   const char *text;
+   (void)handle;   /* prevent compiler unused parameter warning if 
checked */
+   (void)userp;/* prevent compiler unused parameter warning if 
checked */
+   char nopriv = 0;/* default: there are no sensitive data
+* in the trace to be skipped
+   */
+
+   switch (type) {
+   case CURLINFO_TEXT:
+   trace_printf_k

[PATCHv4 0/2] Implement the GIT_TRACE_CURL environment variable

2016-04-28 Thread Elia Pinto
This is the fourth version but in reality is the complete rewriting of the 
patches discussed here
(here called V1)

$gmane/290520
$gmane/290521

*Changes from V3
($gmane/292040)

- add missing static to curl_dump
- reorder the patch order
- tried to fix all (but i am not sure) the problems reported by Julio 
($gmane/292055)
- * squash the documentation with the http.c commit.
  * in the trace prefix each line to indicate it is about sending a header, and 
drop the 
initial hex count
  * auto-censor Authorization headers by default 

as suggested by Jeff King ($gmane/292074)

*Changes from V2
($gmane/291868)

- fix garbage comment in http.c (i am very sorry for that)
- add final '.' to the commit message for imap-send.c and to other commit 
messages
- typofix double ; in http.c
- merge the nice cleanup and code refactoring of Ramsay Jones (Thank you very 
much !!)
- squash the previous commit 2/4

*Changes from V1

- introduced GIT_TRACE_CURL variable with its documentation
- changed the name of the temporary variable "i" in "w" in the helper routine
- used the c escape sequences instead of the hex equivalent
- dropped the previous GIT_DEBUG_CURL env var
- curl_dump and curl_trace factored out to a shared implementation
in http.c
Elia Pinto (2):
  http.c: implement the GIT_TRACE_CURL environment variable
  imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

 Documentation/git.txt |   8 
 http.c| 109 +-
 http.h|   4 ++
 imap-send.c   |   6 +++
 4 files changed, 126 insertions(+), 1 deletion(-)

-- 
2.8.1.487.gf8c3767.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 3/3] http.c: implements the GIT_TRACE_CURL environment variable

2016-04-20 Thread Elia Pinto
Implements the GIT_TRACE_CURL environment variable to allow a
greater degree of detail of GIT_CURL_VERBOSE, in particular
the complete transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more
thorough debugging analysis.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 http.c | 101 -
 http.h |   6 
 2 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/http.c b/http.c
index 4304b80..507c386 100644
--- a/http.c
+++ b/http.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "transport.h"
 
+static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
 #if LIBCURL_VERSION_NUM >= 0x070a08
 long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
 #else
@@ -464,6 +465,100 @@ static void set_curl_keepalive(CURL *c)
 }
 #endif
 
+
+void curl_dump(const char *text, unsigned char *ptr, size_t size, char nohex)
+{
+   size_t i;
+   size_t w;
+   struct strbuf out = STRBUF_INIT;
+
+   unsigned int width = 0x10;
+
+   if (nohex)
+   /* without the hex output, we can fit more on screen */
+   width = 0x40;
+
+   strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+
+   for (i = 0; i < size; i += width) {
+
+   strbuf_addf(&out, "%4.4lx: ", (long)i);
+
+   if (!nohex) {
+   /* hex not disabled, show it */
+   for (w = 0; w < width; w++)
+   if (i + w < size)
+   strbuf_addf(&out, "%02x ", ptr[i + w]);
+   else
+   strbuf_addf(&out,"   ");
+   }
+
+   for (w = 0; (w < width) && (i + w < size); w++) {
+   /* check for 0D0A; if found, skip past and start a new 
line of output */
+   if (nohex && (i + w + 1 < size) && ptr[i + w] == '\r'
+   && ptr[i + w + 1] == '\n') {
+   i += (w + 2 - width);
+   break;
+   }
+   strbuf_addch(&out, (ptr[i + w] >= 0x20)
+   && (ptr[i + w] < 0x80) ? ptr[i + w] : '.');
+   /* check again for 0D0A, to avoid an extra \n if it's 
at width */
+   if (nohex && (i + w + 2 < size)
+   && ptr[i + w + 1] == '\r'
+   && ptr[i + w + 2] == '\n') {
+   i += (w + 3 - width);
+   break;
+   }
+   }
+   strbuf_addch(&out, '\n');
+   trace_strbuf(&trace_curl, &out);
+   strbuf_release(&out);
+   }
+}
+
+int curl_trace_want(void)
+{
+   return trace_want(&trace_curl);
+}
+
+int curl_trace(CURL *handle, curl_infotype type,
+char *data, size_t size, void *userp)
+{
+   const char *text;
+   (void)handle;   /* prevent compiler warning */
+
+   switch (type) {
+   case CURLINFO_TEXT:
+   trace_printf_key(&trace_curl, "== Info: %s", data);
+   default:/* in case a new one is introduced to shock us 
*/
+   return 0;
+
+   case CURLINFO_HEADER_OUT:
+   text = "=> Send header";
+   break;
+   case CURLINFO_DATA_OUT:
+   text = "=> Send data";
+   break;
+   case CURLINFO_SSL_DATA_OUT:
+   text = "=> Send SSL data";
+   break;
+   case CURLINFO_HEADER_IN:
+   text = "<= Recv header";
+   break;
+   case CURLINFO_DATA_IN:
+   text = "<= Recv data";
+   break;
+   case CURLINFO_SSL_DATA_IN:
+   text = "<= Recv SSL data";
+   break;
+   }
+
+   curl_dump(text, (unsigned char *)data, size, 1);
+   return 0;
+}
+
+
 static CURL *get_curl_handle(void)
 {
CURL *result = curl_easy_init();
@@ -563,7 +658,11 @@ static CURL *get_curl_handle(void)
"your curl version is too old (>= 7.19.4)");
 #endif
 
-   if (getenv("GIT_CURL_VERBOSE"))
+   if (curl_trace_want()) {
+   curl_easy_setopt(result, CURLOPT_VERBOSE, 1L);
+   curl_easy_setopt(result, CURLOPT_DEBUGFUNCTION, curl_trace);
+ 

[PATCHv3 1/3] git.txt: document the new GIT_TRACE_CURL environment variable

2016-04-20 Thread Elia Pinto
Describe the purpose of the GIT_TRACE_CURL environment variable.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 Documentation/git.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index 8afe349..958db0f 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -1075,6 +1075,14 @@ of clones and fetches.
cloning of shallow repositories.
See 'GIT_TRACE' for available trace output options.
 
+'GIT_TRACE_CURL'::
+   Enables a curl full trace dump of all incoming and outgoing data,
+   including descriptive information, of the git transport protocol.
+   This is similar to doing curl --trace-ascii on the command line.
+   This option overrides setting the GIT_CURL_VERBOSE environment
+   variable.
+   See 'GIT_TRACE' for available trace output options.
+
 'GIT_LITERAL_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs literally, rather than as glob patterns. For example,
-- 
2.8.1.383.g31b84cc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 0/3] Implements the GIT_TRACE_CURL environment variable

2016-04-20 Thread Elia Pinto

This is the third version but in reality is the complete rewriting of the 
patches discussed here
(here called V1)

$gmane/290520
$gmane/290521

*Changes from V2
($gmane/291868)

- fix garbage comment in http.c (i am very sorry for that)
- add final '.' to the commit message for imap-send.c and to other commit 
messages
- typofix double ; in http.c
- merge the nice cleanup and code refactoring of Ramsay Jones (Thank you very 
much !!)
- squash the previous commit 2/4

*Changes from V1

- introduced GIT_TRACE_CURL variable with its documentation
- changed the name of the temporary variable "i" in "w" in the helper routine
- used the c escape sequences instead of the hex equivalent
- dropped the previous GIT_DEBUG_CURL env var
- curl_dump and curl_trace factored out to a shared implementation
in http.c

Elia Pinto (3):
  git.txt: document the new GIT_TRACE_CURL environment variable
  imap-send.c: introduce the GIT_TRACE_CURL enviroment variable
  http.c: implements the GIT_TRACE_CURL environment variable

 Documentation/git.txt |   8 
 http.c| 101 +-
 http.h|   6 +++
 imap-send.c   |   6 +++
 4 files changed, 120 insertions(+), 1 deletion(-)

-- 
2.8.1.383.g31b84cc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 2/3] imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

2016-04-20 Thread Elia Pinto
Permit the use of the GIT_TRACE_CURL environment variable calling
the curl_trace and curl_dump http.c helper routine.

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 imap-send.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/imap-send.c b/imap-send.c
index 938c691..61c6787 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1444,6 +1444,12 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
 
+   if (curl_trace_want()) {
+   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+   curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curl_trace);
+   curl_easy_setopt(curl, CURLOPT_DEBUGDATA, NULL);
+   }
+
return curl;
 }
 
-- 
2.8.1.383.g31b84cc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] git.txt: document the new GIT_TRACE_CURL environment variable

2016-04-19 Thread Elia Pinto
Describe the purpose of the GIT_TRACE_CURL environment variable

Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine  
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 Documentation/git.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index 8afe349..958db0f 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -1075,6 +1075,14 @@ of clones and fetches.
cloning of shallow repositories.
See 'GIT_TRACE' for available trace output options.
 
+'GIT_TRACE_CURL'::
+   Enables a curl full trace dump of all incoming and outgoing data,
+   including descriptive information, of the git transport protocol.
+   This is similar to doing curl --trace-ascii on the command line.
+   This option overrides setting the GIT_CURL_VERBOSE environment
+   variable.
+   See 'GIT_TRACE' for available trace output options.
+
 'GIT_LITERAL_PATHSPECS'::
Setting this variable to `1` will cause Git to treat all
pathspecs literally, rather than as glob patterns. For example,
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] http.h: Add debug callback and helper routine for implementing the GIT_TRACE_CURL environment variable in http.c

2016-04-19 Thread Elia Pinto
Add the debug callback and helper routine prototype used by
curl_easy_setopt CURLOPT_DEBUGFUNCTION in http.c
for implementing the GIT_TRACE_CURL environment variable


Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine  
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 http.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/http.h b/http.h
index 4ef4bbd..a2d10bc 100644
--- a/http.h
+++ b/http.h
@@ -224,4 +224,10 @@ extern int finish_http_object_request(struct 
http_object_request *freq);
 extern void abort_http_object_request(struct http_object_request *freq);
 extern void release_http_object_request(struct http_object_request *freq);
 
+/* Debug callback and helper routine for curl_easy_setopt 
CURLOPT_DEBUGFUNCTION */
+static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
+int curl_trace(CURL *handle, curl_infotype type, char *data, size_t size, void 
*userp);
+void curl_dump(const char *text, unsigned char *ptr, size_t size, char nohex);
+
+
 #endif /* HTTP_H */
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

2016-04-19 Thread Elia Pinto
Permit the use of the GIT_TRACE_CURL environment variable calling
the curl_trace and curl_dump http.c helper routine


Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine  
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 imap-send.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/imap-send.c b/imap-send.c
index 938c691..b371a78 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1444,6 +1444,12 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
 
+   if (trace_want(&trace_curl)) {
+   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+   curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curl_trace);
+   curl_easy_setopt(curl, CURLOPT_DEBUGDATA, NULL);
+   }
+
return curl;
 }
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 0/4] Implements the GIT_TRACE_CURL environment variable

2016-04-19 Thread Elia Pinto
This is the second version but in reality is the complete rewriting of the 
patches discussed here

$gmane/290520
$gmane/290521

Changes from V1

- introduced GIT_TRACE_CURL variable with its documentation
- changed the name of the temporary variable "i" in "w" in the helper routine
- used the c escape sequences instead of the hex equivalent
- dropped the previous GIT_DEBUG_CURL env var
- curl_dump and curl_trace factored out to a shared implementation
in http.c 

  
Elia Pinto (4):
  http.h: Add debug callback and helper routine for implementing the
GIT_TRACE_CURL environment variable in http.c
  http.c: implements the GIT_TRACE_CURL environment variable
  git.txt: document the new GIT_TRACE_CURL environment variable
  imap-send.c: introduce the GIT_TRACE_CURL enviroment variable

 Documentation/git.txt |  8 +
 http.c| 98 ++-
 http.h|  6 
 imap-send.c   |  6 
 4 files changed, 117 insertions(+), 1 deletion(-)

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] http.c: implements the GIT_TRACE_CURL environment variable

2016-04-19 Thread Elia Pinto
Implements the GIT_TRACE_CURL environment variable to allow a
greater degree of detail of GIT_CURL_VERBOSE, in particular
the complete transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more
thorough debugging analysis


Helped-by: Torsten Bögershausen 
Helped-by: Ramsay Jones 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine  
Helped-by: Jeff King 
Signed-off-by: Elia Pinto 
---
 http.c | 98 +-
 1 file changed, 97 insertions(+), 1 deletion(-)

diff --git a/http.c b/http.c
index 4304b80..278991e 100644
--- a/http.c
+++ b/http.c
@@ -11,6 +11,9 @@
 #include "gettext.h"
 #include "transport.h"
 
+/*
+tatic struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
+*/
 #if LIBCURL_VERSION_NUM >= 0x070a08
 long int git_curl_ipresolve = CURL_IPRESOLVE_WHATEVER;
 #else
@@ -464,6 +467,95 @@ static void set_curl_keepalive(CURL *c)
 }
 #endif
 
+
+void curl_dump(const char *text, unsigned char *ptr, size_t size, char nohex)
+{
+   size_t i;
+   size_t w;
+   struct strbuf out = STRBUF_INIT;;
+
+   unsigned int width = 0x10;
+
+   if (nohex)
+   /* without the hex output, we can fit more on screen */
+   width = 0x40;
+
+   strbuf_addf(&out, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+
+   for (i = 0; i < size; i += width) {
+
+   strbuf_addf(&out, "%4.4lx: ", (long)i);
+
+   if (!nohex) {
+   /* hex not disabled, show it */
+   for (w = 0; w < width; w++)
+   if (i + w < size)
+   strbuf_addf(&out, "%02x ", ptr[i + w]);
+   else
+   strbuf_addf(&out,"   ");
+   }
+
+   for (w = 0; (w < width) && (i + w < size); w++) {
+   /* check for 0D0A; if found, skip past and start a new 
line of output */
+   if (nohex && (i + w + 1 < size) && ptr[i + w] == '\r'
+   && ptr[i + w + 1] == '\n') {
+   i += (w + 2 - width);
+   break;
+   }
+   strbuf_addch(&out, (ptr[i + w] >= 0x20)
+   && (ptr[i + w] < 0x80) ? ptr[i + w] : '.');
+   /* check again for 0D0A, to avoid an extra \n if it's 
at width */
+   if (nohex && (i + w + 2 < size)
+   && ptr[i + w + 1] == '\r'
+   && ptr[i + w + 2] == '\n') {
+   i += (w + 3 - width);
+   break;
+   }
+   }
+   strbuf_addch(&out, '\n');
+   trace_strbuf(&trace_curl, &out);
+   strbuf_release(&out);
+   }
+}
+
+int curl_trace(CURL *handle, curl_infotype type,
+char *data, size_t size, void *userp)
+{
+   const char *text;
+   (void)handle;   /* prevent compiler warning */
+
+   switch (type) {
+   case CURLINFO_TEXT:
+   trace_printf_key(&trace_curl, "== Info: %s", data);
+   default:/* in case a new one is introduced to shock us 
*/
+   return 0;
+
+   case CURLINFO_HEADER_OUT:
+   text = "=> Send header";
+   break;
+   case CURLINFO_DATA_OUT:
+   text = "=> Send data";
+   break;
+   case CURLINFO_SSL_DATA_OUT:
+   text = "=> Send SSL data";
+   break;
+   case CURLINFO_HEADER_IN:
+   text = "<= Recv header";
+   break;
+   case CURLINFO_DATA_IN:
+   text = "<= Recv data";
+   break;
+   case CURLINFO_SSL_DATA_IN:
+   text = "<= Recv SSL data";
+   break;
+   }
+
+   curl_dump(text, (unsigned char *)data, size, 1);
+   return 0;
+}
+
+
 static CURL *get_curl_handle(void)
 {
CURL *result = curl_easy_init();
@@ -563,7 +655,11 @@ static CURL *get_curl_handle(void)
"your curl version is too old (>= 7.19.4)");
 #endif
 
-   if (getenv("GIT_CURL_VERBOSE"))
+   if (trace_want(&trace_curl)) {
+   curl_easy_setopt(result, CURLOPT_VERBOSE, 1L);
+   curl_easy_setopt(result, CURLOPT_DEBUGFUNCTION, curl_trace);
+   curl_easy_setopt(result, CURLOPT_DEBUGDATA, NULL);
+   } else if (getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
 
curl_easy_setopt(result, CURLOPT_USERAGENT,
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [ANNOUNCE] Git v2.8.1 (and call-for-help to "make rpmbuild" users)

2016-04-05 Thread Elia Pinto
2016-04-03 21:21 GMT+02:00 Junio C Hamano :
> If you do not build RPM binary packages from our pristine source,
> you can safely ignore this release and stop reading this message.
>
> Now that the audience of this message has been limited to a narrow
> target, before I make an announcement, here is a call-for-help to
> you.
>
> Git v2.8 removed README file and added a corresponding README.md
> file.  The change however did not adjust git.spec.in that still
> referred to README, causing "make rpmbuild" to fail.  The breakage
> was not noticed by anybody who tested v2.8.0-rc0 and later release
> candidates, and ended up in the final v2.8 release, and we saw a
> handful of bug reports on the list after the release happened.
>
> This maintenance release is to correct this bug for those who run
> "make rpmbuild". It has no other changes.
>
> It is clear that nobody who relies on being able to "make rpmbuild"
> ever tried any of the 5 release candidate snapshots that happened
> during Feb 26-Mar 28.  We had a whole month and nobody noticed?
>
> This incident clearly shows that something needs to happen, if
> people want "make rpmbuild" to keep working.  Even though this
> maintenance release may fix this single bug, breakages similar to it
> that only affect "make rpmbuild" users are guaranteed to appear in
> future releases, unless those who can prevent them from happening
> start helping to test at least release candidate snapshots.
>
> It is even more preferrable if they can test the tip of 'next'
> branch regularly, in order to prevent such breakages from hitting
> the 'master' branch to be included in the next release, which is
> what the other parts of the system aims at.
>
> The other obvious option is for us to stop pretending that "make
> rpmbuild" does anything useful to do and drop the build target and
> the unmaintained git.spec.in file on which nobody in the active
> development community keeps eyes.  I do not mean this as a threat
> "help us or else"; there is a precedent.  We used to ship our own
> debian/rules and friends for those who wanted to debbuild from the
> source, but the Debian packagers wanted to have their own proper
> ones and ours ended up confusing the users, and we made the world
> a better place by removing our copy.  If "make rpmbuild" people want
> us to take this route, that is also OK for us.
>
> So that's the call for help.  Now to the announcement.

How old contributor to rpm5.org (as devzero2000) I have been following
these issues in the past.
Unfortunately, to my knowledge, no one has ever come to a convergence
of views between the distros
that use rpm on the various differences.
Keeping for a project a spec file that then no distro uses (and i
think also a local sysadmin)
i do not think it is worth the effort.

http://lists.rpm.org/pipermail/rpm-maint/2008-June/002185.html

IMHO

Best

>
> The latest maintenance release Git v2.8.1 is now available at
> the usual places.
>
> The tarballs are found at:
>
> https://www.kernel.org/pub/software/scm/git/
>
> The following public repositories all have a copy of the 'v2.8.1'
> tag and the 'maint' branch that the tag points at:
>
>   url = https://kernel.googlesource.com/pub/scm/git/git
>   url = git://repo.or.cz/alt-git.git
>   url = git://git.sourceforge.jp/gitroot/git-core/git.git
>   url = git://git-core.git.sourceforge.net/gitroot/git-core/git-core
>   url = https://github.com/gitster/git
>
> 
>
> Git v2.8.1 Release Notes
> 
>
> Fixes since v2.8
> 
>
>  * "make rpmbuild" target was broken as its input, git.spec.in, was
>not updated to match a file it describes that has been renamed
>recently.  This has been fixed.
>
> 
>
> Changes since v2.8.0 are as follows:
>
> Junio C Hamano (1):
>   Git 2.8.1
>
> Matthieu Moy (1):
>   git.spec.in: use README.md, not README
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] imap-send.c: implements the GIT_CURL_DEBUG environment variable

2016-04-05 Thread Elia Pinto
2016-04-01 22:25 GMT+02:00 Eric Sunshine :
> On Fri, Apr 1, 2016 at 6:44 AM, Elia Pinto  wrote:
>> Implements the GIT_CURL_DEBUG environment variable to allow a greater
>> degree of detail of GIT_CURL_VERBOSE, in particular the complete
>> transport header and all the data payload exchanged.
>> It might be useful if a particular situation could require a more
>> thorough debugging analysis.
>
> In addition to review comments by others, why are the new curl_dump()
> and curl_trace() functions duplicated in both patches rather than
> factored out to a shared implementation?
It's right. Do you think i can use some existing file or should I
create a new object file ?

Thank you very much
>
>> Signed-off-by: Elia Pinto 
>> ---
>> diff --git a/imap-send.c b/imap-send.c
>> @@ -1395,6 +1395,96 @@ static int append_msgs_to_imap(struct 
>> imap_server_conf *server,
>>  }
>>
>>  #ifdef USE_CURL_FOR_IMAP_SEND
>> +
>> +static
>> +void curl_dump(const char *text,
>> + FILE * stream, unsigned char *ptr, size_t size, char nohex)
>> +{
>> +   size_t i;
>> +   size_t c;
>> +
>> +   unsigned int width = 0x10;
>> +
>> +   if (nohex)
>> +   /* without the hex output, we can fit more on screen */
>> +   width = 0x40;
>> +
>> +   fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n",
>> +   text, (long)size, (long)size);
>> +
>> +   for (i = 0; i < size; i += width) {
>> +
>> +   fprintf(stream, "%4.4lx: ", (long)i);
>> +
>> +   if (!nohex) {
>> +   /* hex not disabled, show it */
>> +   for (c = 0; c < width; c++)
>> +   if (i + c < size)
>> +   fprintf(stream, "%02x ", ptr[i + c]);
>> +   else
>> +   fputs("   ", stream);
>> +   }
>> +
>> +   for (c = 0; (c < width) && (i + c < size); c++) {
>> +   /* check for 0D0A; if found, skip past and start a 
>> new line of output */
>> +   if (nohex && (i + c + 1 < size) && ptr[i + c] == 0x0D
>> +   && ptr[i + c + 1] == 0x0A) {
>> +   i += (c + 2 - width);
>> +   break;
>> +   }
>> +   fprintf(stream, "%c",
>> +   (ptr[i + c] >= 0x20)
>> +   && (ptr[i + c] < 0x80) ? ptr[i + c] : '.');
>> +   /* check again for 0D0A, to avoid an extra \n if 
>> it's at width */
>> +   if (nohex && (i + c + 2 < size)
>> +   && ptr[i + c + 1] == 0x0D
>> +   && ptr[i + c + 2] == 0x0A) {
>> +   i += (c + 3 - width);
>> +   break;
>> +   }
>> +   }
>> +   fputc('\n', stream);/* newline */
>> +   }
>> +   fflush(stream);
>> +}
>> +
>> +static
>> +int curl_trace(CURL * handle, curl_infotype type,
>> +char *data, size_t size, void *userp)
>> +{
>> +   const char *text;
>> +   (void)handle;   /* prevent compiler warning */
>> +
>> +   switch (type) {
>> +   case CURLINFO_TEXT:
>> +   fprintf(stderr, "== Info: %s", data);
>> +   default:/* in case a new one is introduced to shock 
>> us */
>> +   return 0;
>> +
>> +   case CURLINFO_HEADER_OUT:
>> +   text = "=> Send header";
>> +   break;
>> +   case CURLINFO_DATA_OUT:
>> +   text = "=> Send data";
>> +   break;
>> +   case CURLINFO_SSL_DATA_OUT:
>> +   text = "=> Send SSL data";
>> +   break;
>> +   case CURLINFO_HEADER_IN:
>> +   text = "<= Recv header";
>> +   break;
>> +   case CURLINFO_DATA_IN:
>> +   text = "<= Recv data";
>> +   break;
>> +   case CURLINFO_SSL_DATA_IN:
>> +   text = "<= Recv SSL data";
>> +   break;
>> +   }
>> +
>> +   curl_dump(text, stderr, (unsigned char *)data, size, 1);
>> +   return 0;
>> +}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] api-trace.txt: fix typo

2016-04-05 Thread Elia Pinto
The correct api is trace_printf_key

Signed-off-by: Elia Pinto 
---
 Documentation/technical/api-trace.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/technical/api-trace.txt 
b/Documentation/technical/api-trace.txt
index 389ae16..45a0ecd 100644
--- a/Documentation/technical/api-trace.txt
+++ b/Documentation/technical/api-trace.txt
@@ -28,7 +28,7 @@ static struct trace_key trace_foo = TRACE_KEY_INIT(FOO);
 
 static void trace_print_foo(const char *message)
 {
-   trace_print_key(&trace_foo, message);
+   trace_printf_key(&trace_foo, message);
 }
 
 +
-- 
2.8.0.270.g9d4de1f.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] imap-send.c: implements the GIT_CURL_DEBUG environment variable

2016-04-04 Thread Elia Pinto
2016-04-01 17:35 GMT+02:00 Junio C Hamano :
> Elia Pinto  writes:
>
>> Implements the GIT_CURL_DEBUG environment variable to allow a greater
>> degree of detail of GIT_CURL_VERBOSE, in particular the complete
>> transport header and all the data payload exchanged.
>> It might be useful if a particular situation could require a more
>> thorough debugging analysis.
>
> My impression is that using GIT_TRACE_* is the more mainstream
> trend, and it may be beneficial to work any new debugging aid like
> this one to fit within that mechanism.

I thought about it, and I agree with you. The idea could be

- Call the variable GIT_TRACE_CURL_DEBUG instead
- Add the new GIT_TRACE_CURL_VERBOSE variable, keeping
GIT_CURL_VERBOSE for compatibility
- Documenting these GIT_TRACE_CURL_XXX variables (GIT_CURL_VERBOSE
it is not even documented i think)
- perhaps use the git trace api in doing these new patches

Look reasonable? It seems reasonable? I'd like your own opinion

Thank you for your suggestion
>
> I am not saying new GIT_*_DEBUG is wrong.  I just wanted to make
> sure you have considered doing this as a new trace in GIT_TRACE_*
> family and rejected that apporach with a very good reason, in
> which case that rationale deserves to be in the log message.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] imap-send.c: implements the GIT_CURL_DEBUG environment variable

2016-04-04 Thread Elia Pinto
2016-04-01 16:56 GMT+02:00 Ramsay Jones :
>
>
> On 01/04/16 11:44, Elia Pinto wrote:
>> Implements the GIT_CURL_DEBUG environment variable to allow a greater
>> degree of detail of GIT_CURL_VERBOSE, in particular the complete
>> transport header and all the data payload exchanged.
>> It might be useful if a particular situation could require a more
>> thorough debugging analysis.
>>
>> Signed-off-by: Elia Pinto 
>> ---
>>  imap-send.c | 99 
>> +++--
>>  1 file changed, 97 insertions(+), 2 deletions(-)
>>
>> diff --git a/imap-send.c b/imap-send.c
>> index 4d3b773..cf79e7f 100644
>> --- a/imap-send.c
>> +++ b/imap-send.c
> [snip]
>
>> @@ -1442,8 +1532,13 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
>>
>>   curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
>>
>> - if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
>> - curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
>> + if (0 < verbosity )
It was already so in the previous code, I have not changed it. If it
is a desirable change it would take another patch
>
> previously it was sufficient to set GIT_CURL_VERBOSE, now I have to
> set verbosity too?

>
> [Does it matter that you change "1L" to "1" in the curl_easy_setopt()
> call? In http.c (line 567) it also uses "1", but ...]
>
>> + if (getenv("GIT_CURL_DEBUG")) {
>> + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
>> + curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, 
>> curl_trace);
>> + } else if (getenv("GIT_CURL_VERBOSE"))
>> + curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
>> +
OK.
>>
>>   return curl;
>>  }
>>
>
> I would have expected something like:
>
> if (0 < verbosity || getenv("GIT_CURL_VERBOSE")) {
> curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
> if (getenv("GIT_CURL_DEBUG"))
> curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, curl_trace);
> }
>
No. Thank you. But actually it is not a desirable change
> Hope That Helps.
>
> ATB,
> Ramsay Jones
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] http.c: implements the GIT_CURL_DEBUG environment variable

2016-04-04 Thread Elia Pinto
2016-04-01 17:03 GMT+02:00 Ramsay Jones :
>
>
> On 01/04/16 11:44, Elia Pinto wrote:
>> Implements the GIT_CURL_DEBUG environment variable to allow a greater
>> degree of detail of GIT_CURL_VERBOSE, in particular the complete
>> transport header and all the data payload exchanged.
>> It might be useful if a particular situation could require a more
>> thorough debugging analysis.
>>
>> Signed-off-by: Elia Pinto 
>> ---
>>  http.c | 97 
>> +-
>>  1 file changed, 96 insertions(+), 1 deletion(-)
>>
>> diff --git a/http.c b/http.c
>> index dfc53c1..079779d 100644
>> --- a/http.c
>> +++ b/http.c
> [snip]
>
>> @@ -532,7 +623,11 @@ static CURL *get_curl_handle(void)
>>   "your curl version is too old (>= 7.19.4)");
>>  #endif
>>
>> - if (getenv("GIT_CURL_VERBOSE"))
>> + if (getenv("GIT_CURL_DEBUG")) {
>> + curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
>> + curl_easy_setopt(result, CURLOPT_DEBUGFUNCTION, curl_trace);
>> + curl_easy_setopt(result, CURLOPT_DEBUGDATA, NULL);
>> + } else if (getenv("GIT_CURL_VERBOSE"))
>>   curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
>>
>>   curl_easy_setopt(result, CURLOPT_USERAGENT,
>>
>
> Again, maybe something like:
>
> if (getenv("GIT_CURL_VERBOSE")) {
> curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
> if (getenv("GIT_CURL_DEBUG"))
> curl_easy_setopt(result, CURLOPT_DEBUGFUNCTION, curl_trace);
> }
>
> Although that does make GIT_CURL_DEBUG subordinate to GIT_CURL_VERBOSE.
> So, that may not be desired ...

Thank you. But actually it is not a desirable change, for me almost, I
prefer that the two definitions are independent. And it is true the
opposite: if it is defined the curl DEBUG flag then it is implicitly
defined the curl VERBOSE flag, because it is a prerequisite of the
DEBUG functionality.

Thanks in any case for the review.

Best
>
> ATB,
> Ramsay Jones
>
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] imap-send.c: implements the GIT_CURL_DEBUG environment variable

2016-04-01 Thread Elia Pinto
Implements the GIT_CURL_DEBUG environment variable to allow a greater
degree of detail of GIT_CURL_VERBOSE, in particular the complete
transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more
thorough debugging analysis.

Signed-off-by: Elia Pinto 
---
 imap-send.c | 99 +++--
 1 file changed, 97 insertions(+), 2 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index 4d3b773..cf79e7f 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1395,6 +1395,96 @@ static int append_msgs_to_imap(struct imap_server_conf 
*server,
 }
 
 #ifdef USE_CURL_FOR_IMAP_SEND
+
+static
+void curl_dump(const char *text,
+ FILE * stream, unsigned char *ptr, size_t size, char nohex)
+{
+   size_t i;
+   size_t c;
+
+   unsigned int width = 0x10;
+
+   if (nohex)
+   /* without the hex output, we can fit more on screen */
+   width = 0x40;
+
+   fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+
+   for (i = 0; i < size; i += width) {
+
+   fprintf(stream, "%4.4lx: ", (long)i);
+
+   if (!nohex) {
+   /* hex not disabled, show it */
+   for (c = 0; c < width; c++)
+   if (i + c < size)
+   fprintf(stream, "%02x ", ptr[i + c]);
+   else
+   fputs("   ", stream);
+   }
+
+   for (c = 0; (c < width) && (i + c < size); c++) {
+   /* check for 0D0A; if found, skip past and start a new 
line of output */
+   if (nohex && (i + c + 1 < size) && ptr[i + c] == 0x0D
+   && ptr[i + c + 1] == 0x0A) {
+   i += (c + 2 - width);
+   break;
+   }
+   fprintf(stream, "%c",
+   (ptr[i + c] >= 0x20)
+   && (ptr[i + c] < 0x80) ? ptr[i + c] : '.');
+   /* check again for 0D0A, to avoid an extra \n if it's 
at width */
+   if (nohex && (i + c + 2 < size)
+   && ptr[i + c + 1] == 0x0D
+   && ptr[i + c + 2] == 0x0A) {
+   i += (c + 3 - width);
+   break;
+   }
+   }
+   fputc('\n', stream);/* newline */
+   }
+   fflush(stream);
+}
+
+static
+int curl_trace(CURL * handle, curl_infotype type,
+char *data, size_t size, void *userp)
+{
+   const char *text;
+   (void)handle;   /* prevent compiler warning */
+
+   switch (type) {
+   case CURLINFO_TEXT:
+   fprintf(stderr, "== Info: %s", data);
+   default:/* in case a new one is introduced to shock us 
*/
+   return 0;
+
+   case CURLINFO_HEADER_OUT:
+   text = "=> Send header";
+   break;
+   case CURLINFO_DATA_OUT:
+   text = "=> Send data";
+   break;
+   case CURLINFO_SSL_DATA_OUT:
+   text = "=> Send SSL data";
+   break;
+   case CURLINFO_HEADER_IN:
+   text = "<= Recv header";
+   break;
+   case CURLINFO_DATA_IN:
+   text = "<= Recv data";
+   break;
+   case CURLINFO_SSL_DATA_IN:
+   text = "<= Recv SSL data";
+   break;
+   }
+
+   curl_dump(text, stderr, (unsigned char *)data, size, 1);
+   return 0;
+}
+
 static CURL *setup_curl(struct imap_server_conf *srvc)
 {
CURL *curl;
@@ -1442,8 +1532,13 @@ static CURL *setup_curl(struct imap_server_conf *srvc)
 
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
 
-   if (0 < verbosity || getenv("GIT_CURL_VERBOSE"))
-   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+   if (0 < verbosity )
+   if (getenv("GIT_CURL_DEBUG")) {
+   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+   curl_easy_setopt(curl, CURLOPT_DEBUGFUNCTION, 
curl_trace);
+   } else if (getenv("GIT_CURL_VERBOSE"))
+   curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
+
 
return curl;
 }
-- 
2.7.0.416.gbf6b42c.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] http.c: implements the GIT_CURL_DEBUG environment variable

2016-04-01 Thread Elia Pinto
Implements the GIT_CURL_DEBUG environment variable to allow a greater
degree of detail of GIT_CURL_VERBOSE, in particular the complete
transport header and all the data payload exchanged.
It might be useful if a particular situation could require a more
thorough debugging analysis.

Signed-off-by: Elia Pinto 
---
 http.c | 97 +-
 1 file changed, 96 insertions(+), 1 deletion(-)

diff --git a/http.c b/http.c
index dfc53c1..079779d 100644
--- a/http.c
+++ b/http.c
@@ -437,6 +437,97 @@ static void set_curl_keepalive(CURL *c)
 }
 #endif
 
+
+static
+void curl_dump(const char *text,
+ FILE * stream, unsigned char *ptr, size_t size, char nohex)
+{
+   size_t i;
+   size_t c;
+
+   unsigned int width = 0x10;
+
+   if (nohex)
+   /* without the hex output, we can fit more on screen */
+   width = 0x40;
+
+   fprintf(stream, "%s, %10.10ld bytes (0x%8.8lx)\n",
+   text, (long)size, (long)size);
+
+   for (i = 0; i < size; i += width) {
+
+   fprintf(stream, "%4.4lx: ", (long)i);
+
+   if (!nohex) {
+   /* hex not disabled, show it */
+   for (c = 0; c < width; c++)
+   if (i + c < size)
+   fprintf(stream, "%02x ", ptr[i + c]);
+   else
+   fputs("   ", stream);
+   }
+
+   for (c = 0; (c < width) && (i + c < size); c++) {
+   /* check for 0D0A; if found, skip past and start a new 
line of output */
+   if (nohex && (i + c + 1 < size) && ptr[i + c] == 0x0D
+   && ptr[i + c + 1] == 0x0A) {
+   i += (c + 2 - width);
+   break;
+   }
+   fprintf(stream, "%c",
+   (ptr[i + c] >= 0x20)
+   && (ptr[i + c] < 0x80) ? ptr[i + c] : '.');
+   /* check again for 0D0A, to avoid an extra \n if it's 
at width */
+   if (nohex && (i + c + 2 < size)
+   && ptr[i + c + 1] == 0x0D
+   && ptr[i + c + 2] == 0x0A) {
+   i += (c + 3 - width);
+   break;
+   }
+   }
+   fputc('\n', stream);/* newline */
+   }
+   fflush(stream);
+}
+
+static
+int curl_trace(CURL * handle, curl_infotype type,
+char *data, size_t size, void *userp)
+{
+   const char *text;
+   (void)handle;   /* prevent compiler warning */
+
+   switch (type) {
+   case CURLINFO_TEXT:
+   fprintf(stderr, "== Info: %s", data);
+   default:/* in case a new one is introduced to shock us 
*/
+   return 0;
+
+   case CURLINFO_HEADER_OUT:
+   text = "=> Send header";
+   break;
+   case CURLINFO_DATA_OUT:
+   text = "=> Send data";
+   break;
+   case CURLINFO_SSL_DATA_OUT:
+   text = "=> Send SSL data";
+   break;
+   case CURLINFO_HEADER_IN:
+   text = "<= Recv header";
+   break;
+   case CURLINFO_DATA_IN:
+   text = "<= Recv data";
+   break;
+   case CURLINFO_SSL_DATA_IN:
+   text = "<= Recv SSL data";
+   break;
+   }
+
+   curl_dump(text, stderr, (unsigned char *)data, size, 1);
+   return 0;
+}
+
+
 static CURL *get_curl_handle(void)
 {
CURL *result = curl_easy_init();
@@ -532,7 +623,11 @@ static CURL *get_curl_handle(void)
"your curl version is too old (>= 7.19.4)");
 #endif
 
-   if (getenv("GIT_CURL_VERBOSE"))
+   if (getenv("GIT_CURL_DEBUG")) {
+   curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
+   curl_easy_setopt(result, CURLOPT_DEBUGFUNCTION, curl_trace);
+   curl_easy_setopt(result, CURLOPT_DEBUGDATA, NULL);
+   } else if (getenv("GIT_CURL_VERBOSE"))
curl_easy_setopt(result, CURLOPT_VERBOSE, 1);
 
curl_easy_setopt(result, CURLOPT_USERAGENT,
-- 
2.7.0.416.gbf6b42c.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] http: honor no_http env variable to bypass proxy

2016-03-10 Thread Elia Pinto
2016-03-07 21:33 GMT+01:00 Junio C Hamano :
> Junio C Hamano  writes:
>
> Second call for help.  I hate having to revert 30f302f7 (Merge
> branch 'kf/http-proxy-auth-methods', 2016-02-03) this late in the
> cycle.
Ok. I made the original merge commit for master. So,  if it is
sufficient, for me the patch is correct.

I am sorry for the delay in the response.

Best
>
>> Jiang Xin  writes:
>>
>>> From: Jiang Xin 
>>>
>>> Curl and its families honor several proxy related environment variables:
>>>
>>> * http_proxy and https_proxy define proxy for http/https connections.
>>> * no_proxy (a comma separated hosts) defines hosts bypass the proxy.
>>>
>>> This command will bypass the bad-proxy and connect to the host directly:
>>>
>>> no_proxy=* https_proxy=http://bad-proxy/ \
>>> curl -sk https://google.com/
>>>
>>> Before commit 372370f (http: use credential API to handle proxy auth...),
>>> Environment variable "no_proxy" will take effect if the config variable
>>> "http.proxy" is not set.  So the following comamnd won't fail if not
>>> behind a firewall.
>>>
>>> no_proxy=* https_proxy=http://bad-proxy/ \
>>> git ls-remote https://github.com/git/git
>>>
>>> But commit 372370f not only read git config variable "http.proxy", but
>>> also read "http_proxy" and "https_proxy" environment variables, and set
>>> the curl option using:
>>>
>>> curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
>>>
>>> This caused "no_proxy" environment variable not working any more.
>>>
>>> Set extra curl option "CURLOPT_NOPROXY" will fix this issue.
>>>
>>> Signed-off-by: Jiang Xin 
>>> ---
>>>  http.c | 6 ++
>>>  1 file changed, 6 insertions(+)
>>
>> Sounds sensible; I am guessing that this is 2.8.0-rc0 regression
>> that we need to fast-track?
>>
>> Knut, does this look good?
>>
>> Thanks.
>>
>>> diff --git a/http.c b/http.c
>>> index 1d5e3bb..69da445 100644
>>> --- a/http.c
>>> +++ b/http.c
>>> @@ -70,6 +70,7 @@ static long curl_low_speed_limit = -1;
>>>  static long curl_low_speed_time = -1;
>>>  static int curl_ftp_no_epsv;
>>>  static const char *curl_http_proxy;
>>> +static const char *curl_no_proxy;
>>>  static const char *http_proxy_authmethod;
>>>  static struct {
>>>  const char *name;
>>> @@ -624,6 +625,11 @@ static CURL *get_curl_handle(void)
>>>  }
>>>
>>>  curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
>>> +#if LIBCURL_VERSION_NUM >= 0x071304
>>> +var_override(&curl_no_proxy, getenv("NO_PROXY"));
>>> +var_override(&curl_no_proxy, getenv("no_proxy"));
>>> +curl_easy_setopt(result, CURLOPT_NOPROXY, curl_no_proxy);
>>> +#endif
>>>  }
>>>  init_curl_proxy_auth(result);
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] http: honor no_http env variable to bypass proxy

2016-03-10 Thread Elia Pinto
2016-02-29 16:16 GMT+01:00 Jiang Xin :
> From: Jiang Xin 
>
> Curl and its families honor several proxy related environment variables:
>
> * http_proxy and https_proxy define proxy for http/https connections.
> * no_proxy (a comma separated hosts) defines hosts bypass the proxy.
>
> This command will bypass the bad-proxy and connect to the host directly:
>
> no_proxy=* https_proxy=http://bad-proxy/ \
> curl -sk https://google.com/
>
> Before commit 372370f (http: use credential API to handle proxy auth...),
> Environment variable "no_proxy" will take effect if the config variable
> "http.proxy" is not set.  So the following comamnd won't fail if not
> behind a firewall.
>
> no_proxy=* https_proxy=http://bad-proxy/ \
> git ls-remote https://github.com/git/git
>
> But commit 372370f not only read git config variable "http.proxy", but
> also read "http_proxy" and "https_proxy" environment variables, and set
> the curl option using:
>
> curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
>
> This caused "no_proxy" environment variable not working any more.
>
> Set extra curl option "CURLOPT_NOPROXY" will fix this issue.
>
> Signed-off-by: Jiang Xin 
Signed-off-by: Elia Pinto 
> ---
>  http.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/http.c b/http.c
> index 1d5e3bb..69da445 100644
> --- a/http.c
> +++ b/http.c
> @@ -70,6 +70,7 @@ static long curl_low_speed_limit = -1;
>  static long curl_low_speed_time = -1;
>  static int curl_ftp_no_epsv;
>  static const char *curl_http_proxy;
> +static const char *curl_no_proxy;
>  static const char *http_proxy_authmethod;
>  static struct {
> const char *name;
> @@ -624,6 +625,11 @@ static CURL *get_curl_handle(void)
> }
>
> curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
> +#if LIBCURL_VERSION_NUM >= 0x071304
> +   var_override(&curl_no_proxy, getenv("NO_PROXY"));
> +   var_override(&curl_no_proxy, getenv("no_proxy"));
> +   curl_easy_setopt(result, CURLOPT_NOPROXY, curl_no_proxy);
> +#endif
> }
> init_curl_proxy_auth(result);
>
> --
> 2.8.0.rc0.1.g9eb3984.dirty
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/22] builtin/upload-archive.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 builtin/upload-archive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index dbfe14f..3d23106 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -46,7 +46,7 @@ int cmd_upload_archive_writer(int argc, const char **argv, 
const char *prefix)
return write_archive(sent_argv.argc, sent_argv.argv, prefix, 0, NULL, 
1);
 }
 
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static void error_clnt(const char *fmt, ...)
 {
struct strbuf buf = STRBUF_INIT;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/22] advice.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 advice.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/advice.h b/advice.h
index b341a55..eef82e1 100644
--- a/advice.h
+++ b/advice.h
@@ -20,8 +20,7 @@ extern int advice_object_name_warning;
 extern int advice_rm_hints;
 
 int git_default_advice_config(const char *var, const char *value);
-__attribute__((format (printf, 1, 2)))
-void advise(const char *advice, ...);
+FORMATPRINTF(1,2) void advise(const char *advice, ...);
 int error_resolve_conflict(const char *me);
 extern void NORETURN die_resolve_conflict(const char *me);
 void NORETURN die_conclude_merge(void);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/22] builtin/receive-pack.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 builtin/receive-pack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index f2d6761..956278f 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -277,8 +277,8 @@ struct command {
char ref_name[FLEX_ARRAY]; /* more */
 };
 
-static void rp_error(const char *err, ...) __attribute__((format (printf, 1, 
2)));
-static void rp_warning(const char *err, ...) __attribute__((format (printf, 1, 
2)));
+static void rp_error(const char *err, ...) FORMATPRINTF(1,2);
+static void rp_warning(const char *err, ...) FORMATPRINTF(1,2);
 
 static void report_message(const char *prefix, const char *err, va_list params)
 {
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/22] builtin/index-pack.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 builtin/index-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 6a01509..5941963 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -339,7 +339,7 @@ static void parse_pack_header(void)
 }
 
 static NORETURN void bad_object(unsigned long offset, const char *format,
-  ...) __attribute__((format (printf, 2, 3)));
+  ...) FORMATPRINTF(2,3);
 
 static NORETURN void bad_object(unsigned long offset, const char *format, ...)
 {
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/22] git-compat-util.h: add the FORMATPRINTF macro

2016-02-11 Thread Elia Pinto
Add the FORMATPRINTF macro for declaring the gcc function attribute 'format 
printf'
for code style consistency with similar macro that git already use for other gcc
attributes.

Signed-off-by: Elia Pinto 
---
 git-compat-util.h | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index 693a336..17349d9 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -388,6 +388,8 @@ static inline char *git_find_last_dir_sep(const char *path)
 #endif
 #endif
 
+#define FORMATPRINTF(a,b) __attribute__((format (printf, a, b)))
+
 /* The sentinel attribute is valid from gcc version 4.0 */
 #if defined(__GNUC__) && (__GNUC__ >= 4)
 #define LAST_ARG_MUST_BE_NULL __attribute__((sentinel))
@@ -404,11 +406,11 @@ struct strbuf;
 /* General helper functions */
 extern void vreportf(const char *prefix, const char *err, va_list params);
 extern NORETURN void usage(const char *err);
-extern NORETURN void usagef(const char *err, ...) __attribute__((format 
(printf, 1, 2)));
-extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 
1, 2)));
-extern NORETURN void die_errno(const char *err, ...) __attribute__((format 
(printf, 1, 2)));
-extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
-extern void warning(const char *err, ...) __attribute__((format (printf, 1, 
2)));
+extern NORETURN void usagef(const char *err, ...) FORMATPRINTF(1,2);
+extern NORETURN void die(const char *err, ...) FORMATPRINTF(1,2);
+extern NORETURN void die_errno(const char *err, ...) FORMATPRINTF(1,2);
+extern int error(const char *err, ...) FORMATPRINTF(1,2);
+extern void warning(const char *err, ...) FORMATPRINTF(1,2);
 
 #ifndef NO_OPENSSL
 #ifdef APPLE_COMMON_CRYPTO
@@ -759,7 +761,7 @@ static inline size_t xsize_t(off_t len)
return (size_t)len;
 }
 
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 extern int xsnprintf(char *dst, size_t max, const char *fmt, ...);
 
 /* in ctype.c, for kwset users */
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 16/22] pkt-line.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 pkt-line.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pkt-line.h b/pkt-line.h
index 3cb9d91..d3ba3be 100644
--- a/pkt-line.h
+++ b/pkt-line.h
@@ -20,9 +20,9 @@
  * side can't, we stay with pure read/write interfaces.
  */
 void packet_flush(int fd);
-void packet_write(int fd, const char *fmt, ...) __attribute__((format (printf, 
2, 3)));
+void packet_write(int fd, const char *fmt, ...) FORMATPRINTF(2,3);
 void packet_buf_flush(struct strbuf *buf);
-void packet_buf_write(struct strbuf *buf, const char *fmt, ...) 
__attribute__((format (printf, 2, 3)));
+void packet_buf_write(struct strbuf *buf, const char *fmt, ...) 
FORMATPRINTF(2,3);
 
 /*
  * Read a packetized line into the buffer, which must be at least size bytes
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/22] daemon.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 daemon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/daemon.c b/daemon.c
index 46b411c..b4a9207 100644
--- a/daemon.c
+++ b/daemon.c
@@ -95,7 +95,7 @@ static void logreport(int priority, const char *err, va_list 
params)
}
 }
 
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static void logerror(const char *err, ...)
 {
va_list params;
@@ -104,7 +104,7 @@ static void logerror(const char *err, ...)
va_end(params);
 }
 
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static void loginfo(const char *err, ...)
 {
va_list params;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/22] http-backend.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 http-backend.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/http-backend.c b/http-backend.c
index 8870a26..c05e99f 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -58,7 +58,7 @@ static const char *get_parameter(const char *name)
return i ? i->util : NULL;
 }
 
-__attribute__((format (printf, 2, 3)))
+FORMATPRINTF(2,3)
 static void format_write(int fd, const char *fmt, ...)
 {
static char buffer[1024];
@@ -116,7 +116,7 @@ static void end_headers(void)
write_or_die(1, "\r\n", 2);
 }
 
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static NORETURN void not_found(const char *err, ...)
 {
va_list params;
@@ -132,7 +132,7 @@ static NORETURN void not_found(const char *err, ...)
exit(0);
 }
 
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static NORETURN void forbidden(const char *err, ...)
 {
va_list params;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/22] strbuf.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 strbuf.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/strbuf.h b/strbuf.h
index f72fd14..c887dab 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -331,17 +331,17 @@ extern void strbuf_humanise_bytes(struct strbuf *buf, 
off_t bytes);
 /**
  * Add a formatted string to the buffer.
  */
-__attribute__((format (printf,2,3)))
+FORMATPRINTF(2,3)
 extern void strbuf_addf(struct strbuf *sb, const char *fmt, ...);
 
 /**
  * Add a formatted string prepended by a comment character and a
  * blank to the buffer.
  */
-__attribute__((format (printf, 2, 3)))
+FORMATPRINTF(2,3)
 extern void strbuf_commented_addf(struct strbuf *sb, const char *fmt, ...);
 
-__attribute__((format (printf,2,0)))
+FORMATPRINTF(2,0)
 extern void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap);
 
 /**
@@ -556,9 +556,9 @@ extern int strbuf_check_branch_ref(struct strbuf *sb, const 
char *name);
 extern void strbuf_addstr_urlencode(struct strbuf *, const char *,
int reserved);
 
-__attribute__((format (printf,1,2)))
+FORMATPRINTF(1,2)
 extern int printf_ln(const char *fmt, ...);
-__attribute__((format (printf,2,3)))
+FORMATPRINTF(2,3)
 extern int fprintf_ln(FILE *fp, const char *fmt, ...);
 
 char *xstrdup_tolower(const char *);
@@ -567,9 +567,9 @@ char *xstrdup_tolower(const char *);
  * Create a newly allocated string using printf format. You can do this easily
  * with a strbuf, but this provides a shortcut to save a few lines.
  */
-__attribute__((format (printf, 1, 0)))
+FORMATPRINTF(1,0)
 char *xstrvfmt(const char *fmt, va_list ap);
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 char *xstrfmt(const char *fmt, ...);
 
 #endif /* STRBUF_H */
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/22] imap-send.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 imap-send.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/imap-send.c b/imap-send.c
index 4d3b773..6739a7c 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -59,14 +59,14 @@ static struct option imap_send_options[] = {
 #define DRV_BOX_BAD -2
 #define DRV_STORE_BAD   -3
 
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static void imap_info(const char *, ...);
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static void imap_warn(const char *, ...);
 
 static char *next_arg(char **);
 
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 static int nfsnprintf(char *buf, int blen, const char *fmt, ...);
 
 static int nfvasprintf(char **strp, const char *fmt, va_list ap)
@@ -578,7 +578,7 @@ static struct imap_cmd *issue_imap_cmd(struct imap_store 
*ctx,
return cmd;
 }
 
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 static int imap_exec(struct imap_store *ctx, struct imap_cmd_cb *cb,
 const char *fmt, ...)
 {
@@ -594,7 +594,7 @@ static int imap_exec(struct imap_store *ctx, struct 
imap_cmd_cb *cb,
return get_cmd_result(ctx, cmdp);
 }
 
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 static int imap_exec_m(struct imap_store *ctx, struct imap_cmd_cb *cb,
   const char *fmt, ...)
 {
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/22] color.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 color.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/color.h b/color.h
index e155d13..8f763d7 100644
--- a/color.h
+++ b/color.h
@@ -86,9 +86,9 @@ int git_config_colorbool(const char *var, const char *value);
 int want_color(int var);
 int color_parse(const char *value, char *dst);
 int color_parse_mem(const char *value, int len, char *dst);
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
 void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb);
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/22] merge-recursive.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 merge-recursive.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 8eabde2..891d909 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -156,7 +156,7 @@ static void flush_output(struct merge_options *o)
}
 }
 
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 static void output(struct merge_options *o, int v, const char *fmt, ...)
 {
va_list ap;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/22] remote.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 remote.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/remote.c b/remote.c
index 35940a5..579cfcb 100644
--- a/remote.c
+++ b/remote.c
@@ -1672,7 +1672,7 @@ int branch_merge_matches(struct branch *branch,
return refname_match(branch->merge[i]->src, refname);
 }
 
-__attribute((format (printf,2,3)))
+FORMATPRINTF(2,3)
 static const char *error_buf(struct strbuf *err, const char *fmt, ...)
 {
if (err) {
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/22] argv-array.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 argv-array.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/argv-array.h b/argv-array.h
index a2fa0aa..e303dfd 100644
--- a/argv-array.h
+++ b/argv-array.h
@@ -13,7 +13,7 @@ struct argv_array {
 
 void argv_array_init(struct argv_array *);
 void argv_array_push(struct argv_array *, const char *);
-__attribute__((format (printf,2,3)))
+FORMATPRINTF(2,3)
 void argv_array_pushf(struct argv_array *, const char *fmt, ...);
 LAST_ARG_MUST_BE_NULL
 void argv_array_pushl(struct argv_array *, ...);
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/22] transport-helper.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 transport-helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/transport-helper.c b/transport-helper.c
index a6bff8b..94c7aab 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1069,7 +1069,7 @@ int transport_helper_init(struct transport *transport, 
const char *name)
 #define PBUFFERSIZE 8192
 
 /* Print bidirectional transfer loop debug message. */
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static void transfer_debug(const char *fmt, ...)
 {
va_list args;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 21/22] utf8.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 utf8.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/utf8.h b/utf8.h
index 7930b44..3dc301c 100644
--- a/utf8.h
+++ b/utf8.h
@@ -10,7 +10,7 @@ int utf8_strwidth(const char *string);
 int is_utf8(const char *text);
 int is_encoding_utf8(const char *name);
 int same_encoding(const char *, const char *);
-__attribute__((format (printf, 2, 3)))
+FORMATPRINTF(2,3)
 int utf8_fprintf(FILE *, const char *, ...);
 
 extern const char utf8_bom[];
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/22] trace.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 trace.h | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/trace.h b/trace.h
index 179b249..14df130 100644
--- a/trace.h
+++ b/trace.h
@@ -22,23 +22,23 @@ extern void trace_verbatim(struct trace_key *key, const 
void *buf, unsigned len)
 
 #ifndef HAVE_VARIADIC_MACROS
 
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 extern void trace_printf(const char *format, ...);
 
-__attribute__((format (printf, 2, 3)))
+FORMATPRINTF(2,3)
 extern void trace_printf_key(struct trace_key *key, const char *format, ...);
 
-__attribute__((format (printf, 2, 3)))
+FORMATPRINTF(2,3)
 extern void trace_argv_printf(const char **argv, const char *format, ...);
 
 extern void trace_strbuf(struct trace_key *key, const struct strbuf *data);
 
 /* Prints elapsed time (in nanoseconds) if GIT_TRACE_PERFORMANCE is enabled. */
-__attribute__((format (printf, 2, 3)))
+FORMATPRINTF(2,3)
 extern void trace_performance(uint64_t nanos, const char *format, ...);
 
 /* Prints elapsed time since 'start' if GIT_TRACE_PERFORMANCE is enabled. */
-__attribute__((format (printf, 2, 3)))
+FORMATPRINTF(2,3)
 extern void trace_performance_since(uint64_t start, const char *format, ...);
 
 #else
@@ -97,15 +97,15 @@ extern void trace_performance_since(uint64_t start, const 
char *format, ...);
 __VA_ARGS__)
 
 /* backend functions, use non-*fl macros instead */
-__attribute__((format (printf, 4, 5)))
+FORMATPRINTF(4,5)
 extern void trace_printf_key_fl(const char *file, int line, struct trace_key 
*key,
const char *format, ...);
-__attribute__((format (printf, 4, 5)))
+FORMATPRINTF(4,5)
 extern void trace_argv_printf_fl(const char *file, int line, const char **argv,
 const char *format, ...);
 extern void trace_strbuf_fl(const char *file, int line, struct trace_key *key,
const struct strbuf *data);
-__attribute__((format (printf, 4, 5)))
+FORMATPRINTF(4,5)
 extern void trace_performance_fl(const char *file, int line,
 uint64_t nanos, const char *fmt, ...);
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/22] fsck.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 fsck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fsck.c b/fsck.c
index c637f66..953b8e4 100644
--- a/fsck.c
+++ b/fsck.c
@@ -264,7 +264,7 @@ static void append_msg_id(struct strbuf *sb, const char 
*msg_id)
strbuf_addstr(sb, ": ");
 }
 
-__attribute__((format (printf, 4, 5)))
+FORMATPRINTF(4,5)
 static int report(struct fsck_options *options, struct object *object,
enum fsck_msg_id id, const char *fmt, ...)
 {
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 22/22] wt-status.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 wt-status.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/wt-status.h b/wt-status.h
index c9b3b74..f8b403a 100644
--- a/wt-status.h
+++ b/wt-status.h
@@ -104,9 +104,9 @@ void wt_status_get_state(struct wt_status_state *state, int 
get_detached_from);
 void wt_shortstatus_print(struct wt_status *s);
 void wt_porcelain_print(struct wt_status *s);
 
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 void status_printf_ln(struct wt_status *s, const char *color, const char *fmt, 
...);
-__attribute__((format (printf, 3, 4)))
+FORMATPRINTF(3,4)
 void status_printf(struct wt_status *s, const char *color, const char *fmt, 
...);
 
 #endif /* STATUS_H */
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/22] config.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/config.c b/config.c
index 86a5eb2..671bfd3 100644
--- a/config.c
+++ b/config.c
@@ -1604,7 +1604,7 @@ void git_die_config_linenr(const char *key, const char 
*filename, int linenr)
key, filename, linenr);
 }
 
-NORETURN __attribute__((format(printf, 2, 3)))
+NORETURN FORMATPRINTF(2,3)
 void git_die_config(const char *key, const char *err, ...)
 {
const struct string_list *values;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/22] builtin/update-index.c: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 builtin/update-index.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/update-index.c b/builtin/update-index.c
index 7c5c143..cc62b76 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -35,7 +35,7 @@ static int mark_skip_worktree_only;
 #define UNMARK_FLAG 2
 static struct strbuf mtime_dir = STRBUF_INIT;
 
-__attribute__((format (printf, 1, 2)))
+FORMATPRINTF(1,2)
 static void report(const char *fmt, ...)
 {
va_list vp;
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/22] cache.h: use the FORMATPRINTF macro to declare the gcc function attribute 'format printf'

2016-02-11 Thread Elia Pinto
Use the new FORMATPRINTF macro (in git-compat-util.h) to declare the gcc 
function
attribute 'format printf'

Signed-off-by: Elia Pinto 
---
 cache.h | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/cache.h b/cache.h
index 553b04b..fb29154 100644
--- a/cache.h
+++ b/cache.h
@@ -763,24 +763,24 @@ extern int check_repository_format(void);
  * using the safer "dup" or "strbuf" formats below (in some cases, the
  * unsafe versions have already been removed).
  */
-extern const char *mkpath(const char *fmt, ...) __attribute__((format (printf, 
1, 2)));
-extern const char *git_path(const char *fmt, ...) __attribute__((format 
(printf, 1, 2)));
+extern const char *mkpath(const char *fmt, ...) FORMATPRINTF(1,2);
+extern const char *git_path(const char *fmt, ...) FORMATPRINTF(1,2);
 
 extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
-   __attribute__((format (printf, 3, 4)));
+   FORMATPRINTF(3,4);
 extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
-   __attribute__((format (printf, 2, 3)));
+   FORMATPRINTF(2,3);
 extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
-   __attribute__((format (printf, 2, 3)));
+   FORMATPRINTF(2,3);
 extern void strbuf_git_path_submodule(struct strbuf *sb, const char *path,
  const char *fmt, ...)
-   __attribute__((format (printf, 3, 4)));
+   FORMATPRINTF(3,4);
 extern char *git_pathdup(const char *fmt, ...)
-   __attribute__((format (printf, 1, 2)));
+   FORMATPRINTF(1,2);
 extern char *mkpathdup(const char *fmt, ...)
-   __attribute__((format (printf, 1, 2)));
+   FORMATPRINTF(1,2);
 extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
-   __attribute__((format (printf, 2, 3)));
+   FORMATPRINTF(2,3);
 
 extern void report_linked_checkout_garbage(void);
 
@@ -1630,7 +1630,7 @@ struct key_value_info {
int linenr;
 };
 
-extern NORETURN void git_die_config(const char *key, const char *err, ...) 
__attribute__((format(printf, 2, 3)));
+extern NORETURN void git_die_config(const char *key, const char *err, ...) 
FORMATPRINTF(2,3);
 extern NORETURN void git_die_config_linenr(const char *key, const char 
*filename, int linenr);
 
 extern int committer_ident_sufficiently_given(void);
@@ -1643,7 +1643,7 @@ extern const char *git_mailmap_blob;
 
 /* IO helper functions */
 extern void maybe_flush_or_die(FILE *, const char *);
-__attribute__((format (printf, 2, 3)))
+FORMATPRINTF(2,3)
 extern void fprintf_or_die(FILE *, const char *fmt, ...);
 
 #define COPY_READ_ERROR (-2)
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/22] add the FORMATPRINTF macro to declare the gcc function

2016-02-11 Thread Elia Pinto
Add the FORMATPRINTF macro for declaring the gcc function attribute 'format 
printf'
for code style consistency with similar macro that git already use for other gcc
attributes. And use it where necessary.

Elia Pinto (22):
  git-compat-util.h: add the FORMATPRINTF macro
  advice.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  argv-array.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  builtin/index-pack.c: use the FORMATPRINTF macro to declare the gcc
function attribute 'format printf'
  builtin/receive-pack.c: use the FORMATPRINTF macro to declare the gcc
function attribute 'format printf'
  builtin/update-index.c: use the FORMATPRINTF macro to declare the gcc
function attribute 'format printf'
  builtin/upload-archive.c: use the FORMATPRINTF macro to declare the
gcc function attribute 'format printf'
  cache.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  color.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  config.c: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  daemon.c: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  fsck.c: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  http-backend.c: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  imap-send.c: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  merge-recursive.c: use the FORMATPRINTF macro to declare the gcc
function attribute 'format printf'
  pkt-line.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  remote.c: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  strbuf.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  trace.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  transport-helper.c: use the FORMATPRINTF macro to declare the gcc
function attribute 'format printf'
  utf8.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'
  wt-status.h: use the FORMATPRINTF macro to declare the gcc function
attribute 'format printf'

 advice.h |  3 +--
 argv-array.h |  2 +-
 builtin/index-pack.c |  2 +-
 builtin/receive-pack.c   |  4 ++--
 builtin/update-index.c   |  2 +-
 builtin/upload-archive.c |  2 +-
 cache.h  | 22 +++---
 color.h  |  4 ++--
 config.c |  2 +-
 daemon.c |  4 ++--
 fsck.c   |  2 +-
 git-compat-util.h| 14 --
 http-backend.c   |  6 +++---
 imap-send.c  | 10 +-
 merge-recursive.c|  2 +-
 pkt-line.h   |  4 ++--
 remote.c |  2 +-
 strbuf.h | 14 +++---
 trace.h  | 16 
 transport-helper.c   |  2 +-
 utf8.h   |  2 +-
 wt-status.h  |  4 ++--
 22 files changed, 63 insertions(+), 62 deletions(-)

-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 8/8] one ugly test to verify basic functionality

2016-02-05 Thread Elia Pinto
2016-02-05 14:20 GMT+01:00 Johannes Schindelin :
> Hi Elia,
>
> On Fri, 5 Feb 2016, Elia Pinto wrote:
>
>> From the git coding guideline : "We prefer $( ... ) for command
>> substitution; unlike ``, it properly nests.  It should have been the way
>> Bourne spelled it from day one, but unfortunately isn't."
>
> There was only one time in my life as a developer when I had to change a
> $(...) to a `...` construct. I do not really remember all the details, but
> I think it was on MacOSX, and it was inside a case ... esac and the
> closing parentheses was mistaken for a case arm (the $(...) construct
> might have been multi-line, is the only thing that would make sense in my
> mind.
>
> Did you hear of similar problems?

I not personally. The autoconf manual does not seem to me (for that i
can remember) to mention this possible incompatibility, for example.

Best

>
> Ciao,
> Dscho
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 8/8] one ugly test to verify basic functionality

2016-02-05 Thread Elia Pinto
2016-02-05 14:02 GMT+01:00 Duy Nguyen :
> On Fri, Feb 5, 2016 at 6:57 PM, Elia Pinto  wrote:
>>> +   mv `ls .git/objects/pack/*.pack` pack &&
>>
>> No, please. From the git coding guideline : "We prefer $( ... ) for
>> command substitution; unlike ``, it properly nests.
>
> I was being too subtle with the word "ugly". I assure you this test
> cannot be merged in its current form.
>
> But that's not important. It makes me think, can we catch `..`
> automatically? I know the test suite can catch broken && command
> sequence. Maybe we can do the same for`..`?
I dunno. But it might be a good idea
>
>> It should have been the way Bourne spelled it from day one, but
>> unfortunately isn't."
>>
>> http://stackoverflow.com/questions/4708549/whats-the-difference-between-command-and-command-in-shell-programming
> --
> Duy
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/15] git-am.sh: replace using expr for arithmetic operations with the equivalent shell builtin

2016-02-05 Thread Elia Pinto
2016-02-04 20:33 GMT+01:00 Junio C Hamano :
> As pointed out already, quoting of "$this" inside the arithmetic
> expansion would not work very well, so [14/15] needs fixing.
>
> I do not see 01/15 thru 13/15 here, by the way.  Is it just me?

Excuse me, everyone. Yesterday was a bad day. I did a bit of confusion :=(.
But this is not a patch series, yes. The patch is for git-am in
contrib: so it is not important.

Thank you
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 8/8] one ugly test to verify basic functionality

2016-02-05 Thread Elia Pinto
2016-02-05 9:57 GMT+01:00 Nguyễn Thái Ngọc Duy :
> Signed-off-by: Nguyễn Thái Ngọc Duy 
> ---
>  t/t5544-fetch-resume.sh (new +x) | 42 
> 
>  1 file changed, 42 insertions(+)
>  create mode 100755 t/t5544-fetch-resume.sh
>
> diff --git a/t/t5544-fetch-resume.sh b/t/t5544-fetch-resume.sh
> new file mode 100755
> index 000..dfa033d
> --- /dev/null
> +++ b/t/t5544-fetch-resume.sh
> @@ -0,0 +1,42 @@
> +#!/bin/sh
> +
> +test_description='what'
> +
> +. ./test-lib.sh
> +
> +test_expect_success 'what' '
> +   test_commit one &&
> +   git clone --no-local .git abc &&
> +   (
> +   cd abc &&
> +   mv `ls .git/objects/pack/*.pack` pack &&

No, please. From the git coding guideline : "We prefer $( ... ) for
command substitution; unlike ``, it properly nests.
It should have been the way Bourne spelled it from day one, but
unfortunately isn't."

http://stackoverflow.com/questions/4708549/whats-the-difference-between-command-and-command-in-shell-programming

Thank you
> +   git unpack-objects < pack &&
> +   rm pack &&
> +   git fsck
> +   ) &&
> +   test_commit two &&
> +   test_commit three &&
> +   (
> +   cd abc &&
> +   git fetch --resume-pack=foo origin HEAD &&
> +   git log --format=%s origin/master >actual &&
> +   echo one >expected &&
> +   test_cmp expected actual &&
> +   rm .git/FETCH_HEAD &&
> +   mv `ls .git/objects/pack/*.pack` pack &&
> +   head -c 123 pack >tmp &&
> +   git fetch --resume-pack=tmp origin &&
> +   test_path_is_missing tmp &&
> +   cmp pack .git/objects/pack/*.pack &&
> +   git fsck &&
> +   git log --format=%s origin/master >actual &&
> +   cat >expected < +three
> +two
> +one
> +EOF
> +   test_cmp expected actual
> +   )
> +'
> +
> +test_done
> --
> 2.7.0.377.g4cd97dd
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 14/15] git-am.sh: replace using expr for arithmetic operations with the equivalent shell builtin

2016-02-04 Thread Elia Pinto
2016-02-04 12:14 GMT+01:00 Johannes Schindelin :
> Hi Elia,
>
> On Thu, 4 Feb 2016, Elia Pinto wrote:
>
>> - this=$(expr "$this" + 1)
>> + this=$(( "$this" + 1 ))
>
> Why the funny spaces? We do not do that anywhere in the existing code
> except in three places (2x filter-branch, 1x rebase--interactive, all
> three *not* my fault) and in some tests.
>
> Also, I am *pretty* certain that the quotes break this code:
>
> me@work MINGW64 /usr/src/git (master)
> $ this=1
>
> me@work MINGW64 /usr/src/git (master)
> $ this=$(( "$this" + 1 ))
> bash: "1" + 1 : syntax error: operand expected (error token is ""1" + 
> 1 ")
>
> Whereas if you do *not* add the superfluous spaces and quotes, it works:
>
> me@work MINGW64 /usr/src/git (master)
> $ this=1
>
> me@work MINGW64 /usr/src/git (master)
Thanks for noticing.

You are right. I ran the test but did not notice mistakes, my fault.

I will resend. Thanks again.

Best

> $ this=$(($this+1))
>
> me@work MINGW64 /usr/src/git (master)
> $ echo $this
> 2
>
> Maybe this is only a problem with Bash 4.3.42 in MSYS2, but I do not think
> so.
>
> *Clicketyclick*
>
> Nope. It also happens in Ubuntu's Bash 4.3.42:
>
> me@ubuntu-vm  ~/git (master)
> $ this=1
>
> me@ubuntu-vm  ~/git (master)
> $ this=$(( "$this" + 1 ))
> bash: "1" + 1 : syntax error: operand expected (error token is ""1" + 
> 1 ")
>
> me@ubuntu-vm  ~/git (master)
> $ bash --version
> GNU bash, version 4.3.42(1)-release (x86_64-pc-linux-gnu)
> Copyright (C) 2013 Free Software Foundation, Inc.
> License GPLv3+: GNU GPL version 3 or later
> <http://gnu.org/licenses/gpl.html>
>
> This is free software; you are free to change and redistribute it.
> There is NO WARRANTY, to the extent permitted by law.
>
> ... which makes me wonder in which environment you tested this?
>
> Ciao,
> Dscho
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/15] git-am.sh: replace using expr for arithmetic operations with the equivalent shell builtin

2016-02-04 Thread Elia Pinto
expr is considered generally antiquated. It is best to use for arithmetic 
operations
the shell $((..)).

To quote POSIX:

"The expr utility has a rather difficult syntax [...] In many cases, the 
arithmetic
and string features provided as part of the shell command language are easier 
to use
than their equivalents in expr. Newly written scripts should avoid expr in 
favor of
the new features within the shell."

Signed-off-by: Elia Pinto 
---
 git-am.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/git-am.sh b/git-am.sh
index ee61a77..4f8148e 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -298,7 +298,7 @@ split_patches () {
this=0
for stgit in "$@"
do
-   this=$(expr "$this" + 1)
+   this=$(( "$this" + 1 ))
msgnum=$(printf "%0${prec}d" $this)
# Perl version of StGIT parse_patch. The first 
nonemptyline
# not starting with Author, From or Date is the
@@ -656,14 +656,14 @@ last=$(cat "$dotest/last")
 this=$(cat "$dotest/next")
 if test "$skip" = t
 then
-   this=$(expr "$this" + 1)
+   this=$(( "$this" + 1 ))
resume=
 fi
 
 while test "$this" -le "$last"
 do
msgnum=$(printf "%0${prec}d" $this)
-   next=$(expr "$this" + 1)
+   next=$(( "$this" + 1 ))
test -f "$dotest/$msgnum" || {
resume=
go_next
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 15/15] t4032-diff-inter-hunk-context.sh: replace using expr for arithmetic operations with the equivalent shell builtin

2016-02-04 Thread Elia Pinto
expr is considered generally antiquated. It is best to use for arithmetic 
operations
the shell $((..)).

To quote POSIX:

"The expr utility has a rather difficult syntax [...] In many cases, the 
arithmetic
and string features provided as part of the shell command language are 
easier to use
than their equivalents in expr. Newly written scripts should avoid expr in 
favor of
the new features within the shell."

Signed-off-by: Elia Pinto 
---
 t/t4032-diff-inter-hunk-context.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t4032-diff-inter-hunk-context.sh 
b/t/t4032-diff-inter-hunk-context.sh
index e4e3e28..0b0b60f 100755
--- a/t/t4032-diff-inter-hunk-context.sh
+++ b/t/t4032-diff-inter-hunk-context.sh
@@ -10,7 +10,7 @@ f() {
while test $i -le $2
do
echo $i
-   i=$(expr $i + 1)
+   i=$(( $i + 1 ))
done
echo $3
 }
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv2 2/2] http: use credential API to handle proxy authentication

2016-01-26 Thread Elia Pinto
From: Knut Franke 

Currently, the only way to pass proxy credentials to curl is by including them
in the proxy URL. Usually, this means they will end up on disk unencrypted, one
way or another (by inclusion in ~/.gitconfig, shell profile or history). Since
proxy authentication often uses a domain user, credentials can be security
sensitive; therefore, a safer way of passing credentials is desirable.

If the configured proxy contains a username but not a password, query the
credential API for one. Also, make sure we approve/reject proxy credentials
properly.

For consistency reasons, add parsing of http_proxy/https_proxy/all_proxy
environment variables, which would otherwise be evaluated as a fallback by curl.
Without this, we would have different semantics for git configuration and
environment variables.

Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Elia Pinto 
Signed-off-by: Knut Franke 
Signed-off-by: Elia Pinto 
Signed-off-by: Junio C Hamano 
---
This is the second version of the patch,
based on the rebase of kf/http-proxy-auth-methods on origin/next 
($gmane/283734).

I have tested that the fix introduced by the commit 6d7afe07 
still works properly. 
(http://stackoverflow.com/questions/15227130/using-a-socks-proxy-with-git-for-the-http-transport#15228479)

I do not know if it is correct that I add my signed off, if not free to delete 
it.

 Documentation/config.txt | 10 +--
 http.c   | 77 
 http.h   |  1 +
 3 files changed, 85 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 0a4d41e..02bcde6 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1610,9 +1610,13 @@ help.htmlPath::
 
 http.proxy::
Override the HTTP proxy, normally configured using the 'http_proxy',
-   'https_proxy', and 'all_proxy' environment variables (see
-   `curl(1)`).  This can be overridden on a per-remote basis; see
-   remote..proxy
+   'https_proxy', and 'all_proxy' environment variables (see `curl(1)`). In
+   addition to the syntax understood by curl, it is possible to specify a
+   proxy string with a user name but no password, in which case git will
+   attempt to acquire one in the same way it does for other credentials. 
See
+   linkgit:gitcredentials[7] for more information. The syntax thus is
+   '[protocol://][user[:password]@]proxyhost[:port]'. This can be 
overridden
+   on a per-remote basis; see remote..proxy
 
 http.proxyAuthMethod::
Set the method with which to authenticate against the HTTP proxy. This
diff --git a/http.c b/http.c
index f46bfc4..dfc53c1 100644
--- a/http.c
+++ b/http.c
@@ -80,6 +80,8 @@ static struct {
 * here, too
 */
 };
+static struct credential proxy_auth = CREDENTIAL_INIT;
+static const char *curl_proxyuserpwd;
 static const char *curl_cookie_file;
 static int curl_save_cookies;
 struct credential http_auth = CREDENTIAL_INIT;
@@ -177,6 +179,9 @@ static void finish_active_slot(struct active_request_slot 
*slot)
 #else
slot->results->auth_avail = 0;
 #endif
+
+   curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CONNECTCODE,
+   &slot->results->http_connectcode);
}
 
/* Run callback if appropriate */
@@ -334,8 +339,32 @@ static void var_override(const char **var, char *value)
}
 }
 
+static void set_proxyauth_name_password(CURL *result)
+{
+#if LIBCURL_VERSION_NUM >= 0x071301
+   curl_easy_setopt(result, CURLOPT_PROXYUSERNAME,
+   proxy_auth.username);
+   curl_easy_setopt(result, CURLOPT_PROXYPASSWORD,
+   proxy_auth.password);
+#else
+   struct strbuf s = STRBUF_INIT;
+
+   strbuf_addstr_urlencode(&s, proxy_auth.username, 1);
+   strbuf_addch(&s, ':');
+   strbuf_addstr_urlencode(&s, proxy_auth.password, 1);
+   curl_proxyuserpwd = strbuf_detach(&s, NULL);
+   curl_easy_setopt(result, CURLOPT_PROXYUSERPWD, 
curl_proxyuserpwd);
+#endif
+}
+
 static void init_curl_proxy_auth(CURL *result)
 {
+   if (proxy_auth.username) {
+   if (!proxy_auth.password)
+   credential_fill(&proxy_auth);
+   set_proxyauth_name_password(result);
+   }
+
var_override(&http_proxy_authmethod, 
getenv("GIT_HTTP_PROXY_AUTHMETHOD"));
 
 #if LIBCURL_VERSION_NUM >= 0x070a07 /* CURLOPT_PROXYAUTH and CURLAUTH_ANY */
@@ -517,6 +546,31 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);
 #endif
 
+   /*
+* CURL also examines these variables as a fallback; but we need to 
query
+* them here in order to decid

[PATCHv2 1/2] http: allow selection of proxy authentication method

2016-01-26 Thread Elia Pinto
From: Knut Franke 

CURLAUTH_ANY does not work with proxies which answer unauthenticated requests
with a 307 redirect to an error page instead of a 407 listing supported
authentication methods. Therefore, allow the authentication method to be set
using the environment variable GIT_HTTP_PROXY_AUTHMETHOD or configuration
variables http.proxyAuthmethod and remote..proxyAuthmethod (in analogy
to http.proxy and remote..proxy).

The following values are supported:

* anyauth (default)
* basic
* digest
* negotiate
* ntlm

Signed-off-by: Knut Franke 
Signed-off-by: Elia Pinto 
Helped-by: Junio C Hamano 
Helped-by: Eric Sunshine 
Helped-by: Elia Pinto 
Signed-off-by: Junio C Hamano 
---
This is the second version of the patch,
based on the rebase of kf/http-proxy-auth-methods on origin/next 
($gmane/283734).

I have tested that the fix introduced by the commit 6d7afe07
still works properly.
(http://stackoverflow.com/questions/15227130/using-a-socks-proxy-with-git-for-the-http-transport#15228479)

I do not know if it is correct that I add my signed off, if not free to delete 
it.

 Documentation/config.txt   | 26 ++
 Documentation/technical/api-remote.txt |  4 +++
 http.c | 65 --
 remote.c   |  3 ++
 remote.h   |  1 +
 5 files changed, 96 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 877cbc8..0a4d41e 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1614,6 +1614,27 @@ http.proxy::
`curl(1)`).  This can be overridden on a per-remote basis; see
remote..proxy
 
+http.proxyAuthMethod::
+   Set the method with which to authenticate against the HTTP proxy. This
+   only takes effect if the configured proxy string contains a user name 
part
+   (i.e. is of the form 'user@host' or 'user@host:port'). This can be
+   overridden on a per-remote basis; see `remote..proxyAuthMethod`.
+   Both can be overridden by the 'GIT_HTTP_PROXY_AUTHMETHOD' environment
+   variable.  Possible values are:
++
+--
+* `anyauth` - Automatically pick a suitable authentication method. It is
+  assumed that the proxy answers an unauthenticated request with a 407
+  status code and one or more Proxy-authenticate headers with supported
+  authentication methods. This is the default.
+* `basic` - HTTP Basic authentication
+* `digest` - HTTP Digest authentication; this prevents the password from being
+  transmitted to the proxy in clear text
+* `negotiate` - GSS-Negotiate authentication (compare the --negotiate option
+  of `curl(1)`)
+* `ntlm` - NTLM authentication (compare the --ntlm option of `curl(1)`)
+--
+
 http.cookieFile::
File containing previously stored cookie lines which should be used
in the Git http session, if they match the server. The file format
@@ -2423,6 +2444,11 @@ remote..proxy::
the proxy to use for that remote.  Set to the empty string to
disable proxying for that remote.
 
+remote..proxyAuthMethod::
+   For remotes that require curl (http, https and ftp), the method to use 
for
+   authenticating against the proxy in use (probably set in
+   `remote..proxy`). See `http.proxyAuthMethod`.
+
 remote..fetch::
The default set of "refspec" for linkgit:git-fetch[1]. See
linkgit:git-fetch[1].
diff --git a/Documentation/technical/api-remote.txt 
b/Documentation/technical/api-remote.txt
index 2cfdd22..f10941b 100644
--- a/Documentation/technical/api-remote.txt
+++ b/Documentation/technical/api-remote.txt
@@ -51,6 +51,10 @@ struct remote
 
The proxy to use for curl (http, https, ftp, etc.) URLs.
 
+`http_proxy_authmethod`::
+
+   The method used for authenticating against `http_proxy`.
+
 struct remotes can be found by name with remote_get(), and iterated
 through with for_each_remote(). remote_get(NULL) will return the
 default remote, given the current branch and configuration.
diff --git a/http.c b/http.c
index 0da9e66..f46bfc4 100644
--- a/http.c
+++ b/http.c
@@ -62,6 +62,24 @@ static long curl_low_speed_limit = -1;
 static long curl_low_speed_time = -1;
 static int curl_ftp_no_epsv;
 static const char *curl_http_proxy;
+static const char *http_proxy_authmethod;
+static struct {
+   const char *name;
+   long curlauth_param;
+} proxy_authmethods[] = {
+   { "basic", CURLAUTH_BASIC },
+   { "digest", CURLAUTH_DIGEST },
+   { "negotiate", CURLAUTH_GSSNEGOTIATE },
+   { "ntlm", CURLAUTH_NTLM },
+#ifdef LIBCURL_CAN_HANDLE_AUTH_ANY
+   { "anyauth", CURLAUTH_ANY },
+#endif
+   /*
+* CURLAUTH_DIGEST_IE has no corresponding command-line option in
+* curl(1) and is not included in CURLAUTH_ANY, so we leave it out
+* here, too
+*/
+};
 static const char *curl_

[PATCH 10/10] t/t5710-info-alternate.sh: use the $( ... ) construct for command substitution

2016-01-04 Thread Elia Pinto
The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command
substitution, and is supported by POSIX.  However, all but the
simplest uses become complicated quickly.  In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.

The patch was generated by:

for _f in $(find . -name "*.sh")
do
perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
done

and then carefully proof-read.

Signed-off-by: Elia Pinto 
---
 t/t5710-info-alternate.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t5710-info-alternate.sh b/t/t5710-info-alternate.sh
index 5a6e49d..9cd2626 100755
--- a/t/t5710-info-alternate.sh
+++ b/t/t5710-info-alternate.sh
@@ -21,7 +21,7 @@ test_valid_repo() {
test_line_count = 0 fsck.log
 }
 
-base_dir=`pwd`
+base_dir=$(pwd)
 
 test_expect_success 'preparing first repository' \
 'test_create_repo A && cd A &&
-- 
2.3.3.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/10] t/t5700-clone-reference.sh: use the $( ... ) construct for command substitution

2016-01-04 Thread Elia Pinto
The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command
substitution, and is supported by POSIX.  However, all but the
simplest uses become complicated quickly.  In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.

The patch was generated by:

for _f in $(find . -name "*.sh")
do
perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
done

and then carefully proof-read.

Signed-off-by: Elia Pinto 
---
 t/t5700-clone-reference.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t5700-clone-reference.sh b/t/t5700-clone-reference.sh
index dfa1bf7..4320082 100755
--- a/t/t5700-clone-reference.sh
+++ b/t/t5700-clone-reference.sh
@@ -6,7 +6,7 @@
 test_description='test clone --reference'
 . ./test-lib.sh
 
-base_dir=`pwd`
+base_dir=$(pwd)
 
 U=$base_dir/UPLOAD_LOG
 
-- 
2.3.3.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/10] t/t5537-fetch-shallow.sh: use the $( ... ) construct for command substitution

2016-01-04 Thread Elia Pinto
The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command
substitution, and is supported by POSIX.  However, all but the
simplest uses become complicated quickly.  In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.

The patch was generated by:

for _f in $(find . -name "*.sh")
do
perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
done

and then carefully proof-read.

Signed-off-by: Elia Pinto 
---
 t/t5537-fetch-shallow.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t5537-fetch-shallow.sh b/t/t5537-fetch-shallow.sh
index a980574..df8d2f0 100755
--- a/t/t5537-fetch-shallow.sh
+++ b/t/t5537-fetch-shallow.sh
@@ -98,7 +98,7 @@ EOF
 test_expect_success 'fetch something upstream has but hidden by clients 
shallow boundaries' '
# the blob "1" is available in .git but hidden by the
# shallow2/.git/shallow and it should be resent
-   ! git --git-dir=shallow2/.git cat-file blob `echo 1|git hash-object 
--stdin` >/dev/null &&
+   ! git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object 
--stdin) >/dev/null &&
echo 1 >1.t &&
git add 1.t &&
git commit -m add-1-back &&
@@ -114,7 +114,7 @@ add-1-back
 EOF
test_cmp expect actual
) &&
-   git --git-dir=shallow2/.git cat-file blob `echo 1|git hash-object 
--stdin` >/dev/null
+   git --git-dir=shallow2/.git cat-file blob $(echo 1|git hash-object 
--stdin) >/dev/null
 
 '
 
-- 
2.3.3.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 03/10] t/t5532-fetch-proxy.sh: use the $( ... ) construct for command substitution

2016-01-04 Thread Elia Pinto
The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command
substitution, and is supported by POSIX.  However, all but the
simplest uses become complicated quickly.  In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.

The patch was generated by:

for _f in $(find . -name "*.sh")
do
perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
done

and then carefully proof-read.

Signed-off-by: Elia Pinto 
---
 t/t5532-fetch-proxy.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/t5532-fetch-proxy.sh b/t/t5532-fetch-proxy.sh
index 5531bd1..d75ef0e 100755
--- a/t/t5532-fetch-proxy.sh
+++ b/t/t5532-fetch-proxy.sh
@@ -15,7 +15,7 @@ test_expect_success 'setup remote repo' '
 cat >proxy <<'EOF'
 #!/bin/sh
 echo >&2 "proxying for $*"
-cmd=`"$PERL_PATH" -e '
+cmd=$("$PERL_PATH" -e '
read(STDIN, $buf, 4);
my $n = hex($buf) - 4;
read(STDIN, $buf, $n);
@@ -23,7 +23,7 @@ cmd=`"$PERL_PATH" -e '
# drop absolute-path on repo name
$cmd =~ s{ /}{ };
print $cmd;
-'`
+')
 echo >&2 "Running '$cmd'"
 exec $cmd
 EOF
-- 
2.3.3.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/10] t/t5601-clone.sh: use the $( ... ) construct for command substitution

2016-01-04 Thread Elia Pinto
The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command
substitution, and is supported by POSIX.  However, all but the
simplest uses become complicated quickly.  In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.

The patch was generated by:

for _f in $(find . -name "*.sh")
do
perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
done

and then carefully proof-read.

Signed-off-by: Elia Pinto 
---
 t/t5601-clone.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index 9b34f3c..61dc4ce 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -221,7 +221,7 @@ test_expect_success 'clone separate gitdir' '
 '
 
 test_expect_success 'clone separate gitdir: output' '
-   echo "gitdir: `pwd`/realgitdir" >expected &&
+   echo "gitdir: $(pwd)/realgitdir" >expected &&
test_cmp expected dst/.git
 '
 
-- 
2.3.3.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/10] t/t5570-git-daemon.sh: use the $( ... ) construct for command substitution

2016-01-04 Thread Elia Pinto
The Git CodingGuidelines prefer the $(...) construct for command
substitution instead of using the backquotes `...`.

The backquoted form is the traditional method for command
substitution, and is supported by POSIX.  However, all but the
simplest uses become complicated quickly.  In particular, embedded
command substitutions and/or the use of double quotes require
careful escaping with the backslash character.

The patch was generated by:

for _f in $(find . -name "*.sh")
do
perl -i -pe 'BEGIN{undef $/;} s/`(.+?)`/\$(\1)/smg'  "${_f}"
done

and then carefully proof-read.

Signed-off-by: Elia Pinto 
---
 t/t5570-git-daemon.sh | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index b7e2832..d76269a 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -57,7 +57,7 @@ test_expect_success 'prepare pack objects' '
 test_expect_success 'fetch notices corrupt pack' '
cp -R "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git 
"$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
(cd "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
-p=`ls objects/pack/pack-*.pack` &&
+p=$(ls objects/pack/pack-*.pack) &&
 chmod u+w $p &&
 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
) &&
@@ -65,14 +65,14 @@ test_expect_success 'fetch notices corrupt pack' '
(cd repo_bad1.git &&
 git --bare init &&
 test_must_fail git --bare fetch "$GIT_DAEMON_URL/repo_bad1.git" &&
-test 0 = `ls objects/pack/pack-*.pack | wc -l`
+test 0 = $(ls objects/pack/pack-*.pack | wc -l)
)
 '
 
 test_expect_success 'fetch notices corrupt idx' '
cp -R "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_pack.git 
"$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
(cd "$GIT_DAEMON_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
-p=`ls objects/pack/pack-*.idx` &&
+p=$(ls objects/pack/pack-*.idx) &&
 chmod u+w $p &&
 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
) &&
@@ -80,7 +80,7 @@ test_expect_success 'fetch notices corrupt idx' '
(cd repo_bad2.git &&
 git --bare init &&
 test_must_fail git --bare fetch "$GIT_DAEMON_URL/repo_bad2.git" &&
-test 0 = `ls objects/pack | wc -l`
+test 0 = $(ls objects/pack | wc -l)
)
 '
 
-- 
2.3.3.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   3   4   5   6   >