Re: Interested in helping open source friends on HP-UX?

2015-02-21 Thread David Aguilar
On Wed, Feb 18, 2015 at 05:00:07PM +0100, H.Merijn Brand wrote:
 On Wed, 10 Dec 2014 23:46:25 -0800, Junio C Hamano gits...@pobox.com
 wrote:
 
  Hello, all.
  
  H. Merijn Brand runs a few HP-UX boxes to help perl5 and other open
  source communities, wants help porting more recent Git on these
  boxes, running HP-UX 10.20, 11.00, and 11.23, and looking for a
  volunteer.  Please contact him directly if you are interested.
 
 No-one. Disappointing :(
 
 I started to work on 2.3.0 on HP-UX 11.23/63 ia64
 
 
 Did *anyone* ever test with NO_ICONV?
 Too many tests fail without iconv
 
 It is *very* hard to decide from the current status if all
 remaining failures are related to (Asian) locale failures and (thus)
 can be safely ignored (in my environment).
 
 
 Specifics at the end
 
 
 FAILures from scratch with no iconv:
 
 [...snip...]
 t7610-mergetool.sh  Tests: 18 Failed:  1 Failed tests: 18
 t7800-difftool.sh   Tests: 56 Failed:  1 Failed tests: 49
 [...snip...]
 
 FAILures from scratch with iconv:
 
 [...snip...]
 t7610-mergetool.sh  Tests: 18 Failed:  1 Failed tests: 18
 t7800-difftool.sh   Tests: 56 Failed:  1 Failed tests: 49
 [...snip...]


I think it's safe to say that these mergetool and difftool
failures are not iconv-related.


 t/t7610-mergetool.sh
 
 HP-UX' mktemp obviously is not compatible with GNU mktemp (which I have
 not installed/available on HP-UX)
 
  SYNOPSIS
   mktemp [-c] [-d directory_name] [-p prefix]
 
 Resolved 'subdir/file3' using previous resolution.
 Automatic merge failed; fix conflicts and then commit the result.
 + git mergetool --no-prompt --tool myecho -- both
 + 1 actual
 error: mktemp is needed when 'mergetool.writeToTemp' is true
 error: last command exited with $?=1
 not ok 18 - temporary filenames are used with mergetool.writeToTemp


We have prerequisites that can be used by tests to mark specific
tests as skippable.  It looks like inventing a prereq for mktemp
would be helpful here.

Maybe we don't need a global prereq, but certainly checking
whether mktemp is compliant for our use case could be used as a
criterion for skipping this test.

A further improvement would be to have have test coverage over
the failure scenario to ensure that the expected error message
is reported and that the correct exit code is returned when we
attempt to use a non-compliant mktemp.

I'd be happy to help review changes to this test.

I'm busy this week(end), but I might be able to poke around next
week if you wanted to give me a shell account.

That said, this error is non-fatal for most use cases ~ as long
as you don't set mergetool.writeToTemp then mergetool will work
fine as it will not attempt to use mktemp.


 t/t7800-difftool.sh
 ---
 HP-UX doesn't have readlink
 
 + git difftool --dir-diff --symlink --extcmd ./.git/CHECK_SYMLINKS branch HEAD
 ./.git/CHECK_SYMLINKS: line 5: readlink: command not found
 ./.git/CHECK_SYMLINKS: line 5: readlink: command not found
 ./.git/CHECK_SYMLINKS: line 5: readlink: command not found
 /pro/3gl/LINUX/git-2.3.0p/git-difftool line 472: No such file or directory
 fatal: 'difftool' appears to be a git command, but we were not
 able to execute it. Maybe git-difftool is broken?
 error: last command exited with $?=128
 not ok 49 - difftool --dir-diff --symlink without unstaged changes


This sounds like another case where a prereq would be helpful.
In this instance it'd be a readlink pre-req.

The --dir-diff code should probably be a little more careful
here, nonetheless.

The error about, fatal: 'difftool' appears to be a git command
seems like it might be something that can be improved.

It seems like difftool is returning an error code that the
caling code is misinterpreting as meaning, not able to execute
vs.  the real situation where difftool simply exited with an
(unexpected) error code.

It seems like we'd want to catch the error within difftool and
exit with a known error code.
-- 
David
--
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 v2 1/3] connect.c: allow ssh://user@[2001:db8::1]/repo.git

2015-02-21 Thread Torsten Bögershausen
The ssh:// syntax was added in 2386d65822c91, it accepted
ssh://user@2001:db8::1/repo.git, which is now legacy.

Over the years the parser was improved to support [] and port numbers,
but the combination of ssh://user@[2001:db8::1]:222/repo.git did
never work.

The only only way to use a user name, a literall IPV6 address and a port
number was ssh://[user@2001:db8::1]:222/repo.git

(Thanks to Christian Taube li...@hcf.yourweb.de for reporting this long
standing issue)

New users would use ssh://user@[2001:db8::1]:222/repo.git,
so change the parser to handle it correctly.

Support the old legacy URL's as well, to be backwards compatible,
and avoid regressions for users which upgrade an existing installation
to a later Git version.

Signed-off-by: Torsten Bögershausen tbo...@web.de
---

Thanks for the reviews
I hope the intention of being backward compatible is a little bit clearer now,
as well as the intention to accept URL's conforming to the RFC


 connect.c| 63 ++--
 t/t5601-clone.sh |  2 +-
 2 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/connect.c b/connect.c
index d47d0ec..b608976 100644
--- a/connect.c
+++ b/connect.c
@@ -274,28 +274,44 @@ static enum protocol get_protocol(const char *name)
die(I don't handle protocol '%s', name);
 }
 
+static char *host_end(char **hoststart, int removebrackets)
+{
+   char *host = *hoststart;
+   char *end;
+   char *start = strstr(host, @[);
+   if (start)
+   start++; /* Jump over '@' */
+   else
+   start = host;
+   if (start[0] == '[') {
+   end = strchr(start + 1, ']');
+   if (end) {
+   if (removebrackets) {
+   *end = 0;
+   memmove(start, start + 1, end - start);
+   end++;
+   }
+   } else
+   end = host;
+   } else
+   end = host;
+   return end;
+}
+
 #define STR_(s)# s
 #define STR(s) STR_(s)
 
 static void get_host_and_port(char **host, const char **port)
 {
char *colon, *end;
-
-   if (*host[0] == '[') {
-   end = strchr(*host + 1, ']');
-   if (end) {
-   *end = 0;
-   end++;
-   (*host)++;
-   } else
-   end = *host;
-   } else
-   end = *host;
+   end = host_end(host, 1);
colon = strchr(end, ':');
-
if (colon) {
-   *colon = 0;
-   *port = colon + 1;
+   long portnr = strtol(colon + 1, end, 10);
+   if (end != colon + 1  *end == '\0'  0 = portnr  portnr  
65536) {
+   *colon = 0;
+   *port = colon + 1;
+   }
}
 }
 
@@ -547,13 +563,16 @@ static struct child_process *git_proxy_connect(int fd[2], 
char *host)
return proxy;
 }
 
-static const char *get_port_numeric(const char *p)
+static char *get_port(char *host)
 {
char *end;
+   char *p = strchr(host, ':');
+
if (p) {
long port = strtol(p + 1, end, 10);
if (end != p + 1  *end == '\0'  0 = port  port  65536) {
-   return p;
+   *p = '\0';
+   return p+1;
}
}
 
@@ -595,14 +614,7 @@ static enum protocol parse_connect_url(const char 
*url_orig, char **ret_host,
 * Don't do destructive transforms as protocol code does
 * '[]' unwrapping in get_host_and_port()
 */
-   if (host[0] == '[') {
-   end = strchr(host + 1, ']');
-   if (end) {
-   end++;
-   } else
-   end = host;
-   } else
-   end = host;
+   end = host_end(host, 0);
 
if (protocol == PROTO_LOCAL)
path = end;
@@ -705,7 +717,8 @@ struct child_process *git_connect(int fd[2], const char 
*url,
char *ssh_host = hostandport;
const char *port = NULL;
get_host_and_port(ssh_host, port);
-   port = get_port_numeric(port);
+   if (!port)
+   port = get_port(ssh_host);
 
if (!ssh) ssh = ssh;
 
diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index e4f10c0..f901b8a 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -326,7 +326,7 @@ test_expect_success !MINGW,!CYGWIN 'clone local path 
foo:bar' '
 
 test_expect_success 'bracketed hostnames are still ssh' '
git clone [myhost:123]:src ssh-bracket-clone 
-   expect_ssh myhost:123 src
+   expect_ssh myhost '-p 123' src
 '
 
 counter=0
-- 
2.2.0.rc1.790.ge19fcd2


--
To unsubscribe from this list: send the line unsubscribe git in
the body 

[PATCH v2 3/3] t5500: show user name and host in diag-url

2015-02-21 Thread Torsten Bögershausen
The URL for ssh may have include a username before the hostname,
like ssh://user@host/repo.
When literal IPV6 addresses are used together with a username,
the substring user@[::1] must be converted into user@::1.

Make that conversion visible for the user, and write userandhost
in the diagnostics

Signed-off-by: Torsten Bögershausen tbo...@web.de
---
 connect.c | 35 +++
 t/t5500-fetch-pack.sh | 51 +--
 2 files changed, 56 insertions(+), 30 deletions(-)

diff --git a/connect.c b/connect.c
index b608976..84f8156 100644
--- a/connect.c
+++ b/connect.c
@@ -675,7 +675,7 @@ struct child_process *git_connect(int fd[2], const char 
*url,
signal(SIGCHLD, SIG_DFL);
 
protocol = parse_connect_url(url, hostandport, path);
-   if (flags  CONNECT_DIAG_URL) {
+   if ((flags  CONNECT_DIAG_URL)  (protocol != PROTO_SSH)) {
printf(Diag: url=%s\n, url ? url : NULL);
printf(Diag: protocol=%s\n, prot_name(protocol));
printf(Diag: hostandport=%s\n, hostandport ? hostandport : 
NULL);
@@ -719,18 +719,29 @@ struct child_process *git_connect(int fd[2], const char 
*url,
get_host_and_port(ssh_host, port);
if (!port)
port = get_port(ssh_host);
-
-   if (!ssh) ssh = ssh;
-
-   argv_array_push(conn-args, ssh);
-   if (putty  !strcasestr(ssh, tortoiseplink))
-   argv_array_push(conn-args, -batch);
-   if (port) {
-   /* P is for PuTTY, p is for OpenSSH */
-   argv_array_push(conn-args, putty ? -P : 
-p);
-   argv_array_push(conn-args, port);
+   if (flags  CONNECT_DIAG_URL) {
+   printf(Diag: url=%s\n, url ? url : NULL);
+   printf(Diag: protocol=%s\n, 
prot_name(protocol));
+   printf(Diag: userandhost=%s\n, ssh_host ? 
ssh_host : NULL);
+   printf(Diag: port=%s\n, port ? port : NONE);
+   printf(Diag: path=%s\n, path ? path : NULL);
+
+   free(hostandport);
+   free(path);
+   return NULL;
+   } else {
+   if (!ssh) ssh = ssh;
+
+   argv_array_push(conn-args, ssh);
+   if (putty  !strcasestr(ssh, tortoiseplink))
+   argv_array_push(conn-args, -batch);
+   if (port) {
+   /* P is for PuTTY, p is for OpenSSH */
+   argv_array_push(conn-args, putty ? 
-P : -p);
+   argv_array_push(conn-args, port);
+   }
+   argv_array_push(conn-args, ssh_host);
}
-   argv_array_push(conn-args, ssh_host);
} else {
/* remove repo-local variables from the environment */
conn-env = local_repo_env;
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 5b2b1c2..bd37f04 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -541,13 +541,30 @@ check_prot_path () {
test_cmp expected actual
 }
 
-check_prot_host_path () {
-   cat expected -EOF 
+check_prot_host_port_path () {
+   local diagport
+   case $2 in
+   *ssh*)
+   pp=ssh
+   uah=userandhost
+   ehost=$(echo $3 | tr -d [])
+   diagport=Diag: port=$4
+   ;;
+   *)
+   pp=$p
+   uah=hostandport
+   ehost=$(echo $3$4 | sed -e s/22$/:22/ -e s/NONE//)
+   diagport=
+   ;;
+   esac
+   cat exp -EOF 
Diag: url=$1
-   Diag: protocol=$2
-   Diag: hostandport=$3
-   Diag: path=$4
+   Diag: protocol=$pp
+   Diag: $uah=$ehost
+   $diagport
+   Diag: path=$5
EOF
+   grep -v ^$ exp expected
git fetch-pack --diag-url $1 actual 
test_cmp expected actual
 }
@@ -557,22 +574,20 @@ do
# git or ssh with scheme
for p in ssh+git git+ssh git ssh
do
-   for h in host host:12 [::1] [::1]:23
+   for h in host user@host user@[::1] user@::1
do
-   case $p in
-   *ssh*)
-   pp=ssh
-   ;;
-   *)
-   pp=$p
-   ;;
-   esac
   

[PATCH v2 2/3] t5601: add more test cases for IPV6

2015-02-21 Thread Torsten Bögershausen
Test the parsing of literall IPV6 addresses more systematically:
- with and without brackets (e.g. ::1 [::1])
- with brackets and port number: (e.g. [::1]:22)
- with username (e.g. user@::1)
- with username and brackets:
  Because user@[::1] was not supported on older Git version,
  [user@::1] had to be used as a workaround.
  Test that user@::1 user@[::1] and [user@::1] all do the same.

Signed-off-by: Torsten Bögershausen tbo...@web.de
---
 t/t5601-clone.sh | 57 +++-
 1 file changed, 40 insertions(+), 17 deletions(-)

diff --git a/t/t5601-clone.sh b/t/t5601-clone.sh
index f901b8a..02b40b1 100755
--- a/t/t5601-clone.sh
+++ b/t/t5601-clone.sh
@@ -301,11 +301,17 @@ expect_ssh () {
(cd $TRASH_DIRECTORY  rm -f ssh-expect  ssh-output)
' 
{
-   case $1 in
-   none)
+   case $# in
+   1)
;;
-   *)
+   2)
echo ssh: $1 git-upload-pack '$2'
+   ;;
+   3)
+   echo ssh: $1 $2 git-upload-pack '$3'
+   ;;
+   *)
+   echo ssh: $1 $2 git-upload-pack '$3' $4
esac
} $TRASH_DIRECTORY/ssh-expect 
(cd $TRASH_DIRECTORY  test_cmp ssh-expect ssh-output)
@@ -336,7 +342,8 @@ counter=0
 test_clone_url () {
counter=$(($counter + 1))
test_might_fail git clone $1 tmp$counter 
-   expect_ssh $2 $3
+   shift 
+   expect_ssh $@
 }
 
 test_expect_success !MINGW 'clone c:temp is ssl' '
@@ -359,7 +366,7 @@ done
 for repo in rep rep/home/project 123
 do
test_expect_success clone [::1]:$repo '
-   test_clone_url [::1]:$repo ::1 $repo
+   test_clone_url [::1]:$repo ::1 $repo
'
 done
 #home directory
@@ -400,24 +407,40 @@ test_expect_success 'clone ssh://host.xz:22/~repo' '
 '
 
 #IPv6
-test_expect_success 'clone ssh://[::1]/home/user/repo' '
-   test_clone_url ssh://[::1]/home/user/repo ::1 /home/user/repo
-'
+for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
+do
+   ehost=$(echo $tuah | tr -d [])
+   test_expect_success clone ssh://$tuah/home/user/repo 
+ test_clone_url ssh://$tuah/home/user/repo $ehost /home/user/repo
+   
+done
 
 #IPv6 from home directory
-test_expect_success 'clone ssh://[::1]/~repo' '
-   test_clone_url ssh://[::1]/~repo ::1 ~repo
-'
+for tuah in ::1 [::1] user@::1 user@[::1] [user@::1]
+do
+   euah=$(echo $tuah | tr -d [])
+   test_expect_success clone ssh://$tuah/~repo 
+ test_clone_url ssh://$tuah/~repo $euah '~repo'
+   
+done
 
 #IPv6 with port number
-test_expect_success 'clone ssh://[::1]:22/home/user/repo' '
-   test_clone_url ssh://[::1]:22/home/user/repo -p 22 ::1 
/home/user/repo
-'
+for tuah in [::1] user@[::1] [user@::1]
+do
+   euah=$(echo $tuah | tr -d [])
+   test_expect_success clone ssh://$tuah:22/home/user/repo 
+ test_clone_url ssh://$tuah:22/home/user/repo '-p 22' $euah 
/home/user/repo
+   
+done
 
 #IPv6 from home directory with port number
-test_expect_success 'clone ssh://[::1]:22/~repo' '
-   test_clone_url ssh://[::1]:22/~repo -p 22 ::1 ~repo
-'
+for tuah in [::1] user@[::1] [user@::1]
+do
+   euah=$(echo $tuah | tr -d [])
+   test_expect_success clone ssh://$tuah:22/~repo 
+ test_clone_url ssh://$tuah:22/~repo '-p 22' $euah '~repo'
+   
+done
 
 test_expect_success 'clone from a repository with two identical branches' '
 
-- 
2.2.0.rc1.790.ge19fcd2


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


[REQUEST] another --cleanup mode for commit

2015-02-21 Thread Christoph Anton Mitterer
Hey.

Right now, all --cleanup modes for commit (except verbatim) seem to
remove all unnecessary whitespace and collapse consecutive empty
lines.

I use already vim to show me any such things and when I don't remove it
then, this usually means I want to have it intentionally (especially
consecutive empty lines).

Now obviously I could do things like --no-status, but I actually like
the status to be shown - as I like it to be automatically removed. ;-)


So it would be great if one could have another cleanup mode which
basically does just the following:
- remove any trailing lines that start with # and the one newline (which
  is automatically added with the status) before these
  e.g.
foo
#bar
  
#status
  yields in:
foo
#bar
  e.g.
foo
#bar
#status
  yields in:
foo

- apart form that, leave any whitespace, new lines, etc. as is

Cheers,
Chris.


smime.p7s
Description: S/MIME cryptographic signature


[cosmetic bug?] needlessly(?) executable files

2015-02-21 Thread Christoph Anton Mitterer
Hey.

Just a question about files like:
.git/config
.git/hooks/*.sample

Is there any reason that these are created executable? Especially the
config file?
I know the hooks are already disabled by being named .sample, but having
them executable just increases the chance that one accidentally fires
them up manually.


Cheers,
Chris.


smime.p7s
Description: S/MIME cryptographic signature


[BUG] git mangles up commit messages on rebase

2015-02-21 Thread Christoph Anton Mitterer
Hey.

When I do a simple interactive rebase, e.g. something like this:
edit 78f3ba8 editing or just rewriting this commit
pick b621076 foo
pick e06c28e this one had a verbatim commit message
pick c0a447f bar

and one of the commit messages from the children I edit/rewrite had a
commit message that was edited with --cleanup=verbatim (e.g. double
newlines, etc.).

Then these get lost once I --continue and it appears that the messages
are recreated but with the default of --cleanup=default .

IMO that's quite annoying, cause when one intentionally chose e.g.
-cleanup=verbatim and made commit messages with that, then this is
probably what one wanted and it should be dumped just because of
changing another commit.

Could that possibly be solved? :)

Cheers,
Chris.


smime.p7s
Description: S/MIME cryptographic signature


Re

2015-02-21 Thread Growth Financial Investment
Sind Sie dabei, eine geschäftliche oder persönliche Darlehen in Höhe von
bis zu $ 200.000.000,00 interessiert

  Erschwinglich: Unternehmenskredite ab Zinssatz 3,0% und unverbindlich.

  Behoben: gelten für 10 Minuten, die Finanzierung innerhalb von 2 Wochen.

  Name.

  Menge benötigt.

  Kreditlaufzeit.

  Stadt.

  Das Alter.

  geschlechtslos.

  telefonnummer.

  Adresse.

  Besatzung.

  Monatseinkommen.

  withrespect
  Carlie Richard (CEO)



--
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: git blame swallows up lines in case of mixed line endings

2015-02-21 Thread Torsten Bögershausen
On 2015-02-19 14.48, Sokolov, Konstantin (ext) wrote:
 Hi Folks,
 
 I encounter unexpected behavior in the following case:
 
 file content:
 
 line1CRLF
 line2CR
 line3CRLF
 line4
 
 This is what I get as console output (on Windows):
 
 git blame -s file.txt
 7db36436 1) line1
 line3436 2) line2
 7db36436 3) line4
 
 This is the real content:
 
 git blame -s file.txt  blame.txt
 
 blame.txt opened in Notepad++:
 
 7db36436 1) line1 CRLF
 7db36436 2) line2 CR
 line3 CRLF
 7db36436 3) line4 LF
 
 Admittedly, very stupid editors, such as Windows Notepad, cannot handle mixed 
 line endings as well. But is this also the way git blame should behave?
 
 Kind regards
 Konstantin

Git (and other tools) do not handle a single CR as a line ending.
A line ending in Git is either CRLF or LF.

A mixed line ending in Git sense is a mixture between CRLF and LF, 
but not a lone CR.
(And in this sense it is the expected behavior)

Are you sure you want to use it, or is it a typo ?

--
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: Undelivered Mail Returned to Sender

2015-02-21 Thread Alfred Perlstein

On Feb 20, 2015, at 9:16 PM, Technext wrote:

 Thanks Junio for the prompt reply! :) Yes, that's exactly how i would like
 things to be. I'll definitely try to push this thing and see if this flow
 can be implemented.
 
 However, can you please guide me whether there's any way i could have
 figured out about the git reset command that the developer executed on his
 local? (my first query)
 
 Also, am i right in thinking that a check cannot be implemented using hooks
 or any other similar way? (my second query)


We have this on our repo.git/config file:

[receive]
denyDeletes = true
denyNonFastForwards = true

This should prevent people from
denyDeletes - deleting a branch
denyNonFastForwards - force push/reset of a remote branch

-Alfred


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


question about resume support.

2015-02-21 Thread drathi...@gmail.com
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hi... Im wonder there is planned or maybe there is support of resuming
interrupted git operation e.g. cloning repositories? Not sure about how
hard that could be to implement, but greatly should decrease of
bandwidth used by persons with weak network connection...
-BEGIN PGP SIGNATURE-

iQJ8BAEBCgBmBQJU6NYHXxSAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRFMEZBMTE5Mjc5MTM0QTZFNDdGRTk3MEZB
RUEzMzk3NTlGNjNCMEZDAAoJEK6jOXWfY7D8CXsP/37F3cHNVgrNj+xzeR1H38xQ
q5zSLNMUYr771gUXBac/p8MfDYlS7gKwRV4Bxhl8AmfH9q28ybj4UFp+5A9u1mKF
E4rrMJE4mrwf/dOeYHMd4EK7aCFrEl9DVnD6uXlQ+QC6qQ23LyR2WHVX3u1a6EQV
tsFIuGLh1kBATWt2/Fim60BqI6P3/PX0gB2R+gPdnm5vG3cY5iNSw/UgZUbRNmMa
QgzBwpxNOTqlJ3GQ9cWgL5CH83VrFmjqHqa8xbVd2ATVaWXTk4pDJFBBafSNJg8s
RMumCGpWmMYBEtAJY/UgE32F2ms7ravLOY0hj9PCoW0FH+czdI9ZNQ8jvdThMByp
+6mHqU2SyYoetnBclcgSrOMdkiCivWB7GaOBscA5E1MM3FpQBdJSBrDlq5yhs9WG
uKhyBpts9+9IdiUPvd4ej4CVXXsE9/FKAEK7+ilr7HsLbRr0vXeAiWA7q+k+Avce
Ih8nwt9onAM37OH7BoW8va/4g/3yHr9EaYFg7ea9hJYUomVY3l/mIQxeG+KPFZnC
XnCVAEMSeMujwjIKqHUEWS8RuHOlxS+q8TEZS7caR/8ausondbQuYK4HLsVhiwFZ
AklwtLBmoIR2yNFn+NKfDOw1RWPsvHSN7yKEQIe+SdUEDDS8QvhfCeKDVSD77ezX
BpXSPfNLMDYqZNp5f+NB
=+Bnw
-END PGP SIGNATURE-


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

2015-02-21 Thread René Scharfe
Use skip_prefix() to get the part after color: (if present) and only
compare it with reset instead of comparing the whole string again.
This gets rid of the duplicate color: part of the string constant.

Signed-off-by: Rene Scharfe l@web.de
---
 builtin/for-each-ref.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 19be78a..83f9cf9 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -178,11 +178,10 @@ static const char *find_next(const char *cp)
 static int verify_format(const char *format)
 {
const char *cp, *sp;
-   static const char color_reset[] = color:reset;
 
need_color_reset_at_eol = 0;
for (cp = format; *cp  (sp = find_next(cp)); ) {
-   const char *ep = strchr(sp, ')');
+   const char *color, *ep = strchr(sp, ')');
int at;
 
if (!ep)
@@ -191,8 +190,8 @@ static int verify_format(const char *format)
at = parse_atom(sp + 2, ep);
cp = ep + 1;
 
-   if (starts_with(used_atom[at], color:))
-   need_color_reset_at_eol = !!strcmp(used_atom[at], 
color_reset);
+   if (skip_prefix(used_atom[at], color:, color))
+   need_color_reset_at_eol = !!strcmp(color, reset);
}
return 0;
 }
-- 
2.3.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] pretty: use starts_with() to check for a prefix

2015-02-21 Thread René Scharfe
Simplify the code and avoid duplication by using starts_with() instead
of strlen() and strncmp() to check if a line starts with encoding .

Signed-off-by: Rene Scharfe l@web.de
---
 pretty.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pretty.c b/pretty.c
index 9d34d02..7b49304 100644
--- a/pretty.c
+++ b/pretty.c
@@ -567,7 +567,7 @@ static char *replace_encoding_header(char *buf, const char 
*encoding)
char *cp = buf;
 
/* guess if there is an encoding header before a \n\n */
-   while (strncmp(cp, encoding , strlen(encoding ))) {
+   while (!starts_with(cp, encoding )) {
cp = strchr(cp, '\n');
if (!cp || *++cp == '\n')
return buf;
-- 
2.3.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] sha1_name: use strlcpy() to copy strings

2015-02-21 Thread René Scharfe
Use strlcpy() instead of calling strncpy() and then setting the last
byte of the target buffer to NUL explicitly.  This shortens and
simplifies the code a bit.

Signed-of-by: Rene Scharfe l@web.de
---
 sha1_name.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index cf2a83b..95f9f8f 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -1391,9 +1391,7 @@ static int get_sha1_with_context_1(const char *name,
namelen = strlen(cp);
}
 
-   strncpy(oc-path, cp,
-   sizeof(oc-path));
-   oc-path[sizeof(oc-path)-1] = '\0';
+   strlcpy(oc-path, cp, sizeof(oc-path));
 
if (!active_cache)
read_cache();
@@ -1443,9 +1441,7 @@ static int get_sha1_with_context_1(const char *name,
   name, len);
}
hashcpy(oc-tree, tree_sha1);
-   strncpy(oc-path, filename,
-   sizeof(oc-path));
-   oc-path[sizeof(oc-path)-1] = '\0';
+   strlcpy(oc-path, filename, sizeof(oc-path));
 
free(new_filename);
return ret;
-- 
2.3.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] connect: use strcmp() for string comparison

2015-02-21 Thread René Scharfe
Get rid of magic string length constants and simply compare the strings
using strcmp().  This makes the intent of the code a bit clearer.

Signed-off-by: Rene Scharfe l@web.de
---
 connect.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/connect.c b/connect.c
index 062e133..2a5c400 100644
--- a/connect.c
+++ b/connect.c
@@ -157,8 +157,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t 
src_len,
server_capabilities = xstrdup(name + name_len + 1);
}
 
-   if (extra_have 
-   name_len == 5  !memcmp(.have, name, 5)) {
+   if (extra_have  !strcmp(name, .have)) {
sha1_array_append(extra_have, old_sha1);
continue;
}
-- 
2.3.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