* git-remote SEGV on t5505 test. @ 2008-07-18 1:46 SungHyun Nam 2008-07-18 4:25 ` Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: SungHyun Nam @ 2008-07-18 1:46 UTC (permalink / raw) To: git Hello, The gdb backtrace said: (gdb) bt #0 0xff03455c in strlen () from /usr/lib/libc.so.1 #1 0xff087058 in _doprnt () from /usr/lib/libc.so.1 #2 0xff088c18 in printf () from /usr/lib/libc.so.1 #3 0x0007df20 in prune (argc=1556136, argv=0x139cd0) at builtin-remote.c:590 The codes in builtin-remote.c:590, printf(" * [%s] %s\n", dry_run ? "would prune" : "prune", skip_prefix(refname, "refs/remotes/")); And the 'skip_prefix()' returns NULL in this case. (The old skip_prefix() never returns NULL). It seems there is another place need to be checked: builtin-remote.c:464 : can pass NULL to the strdup(). Regards, namsh ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: git-remote SEGV on t5505 test. 2008-07-18 1:46 git-remote SEGV on t5505 test SungHyun Nam @ 2008-07-18 4:25 ` Junio C Hamano 2008-07-18 5:44 ` SungHyun Nam 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2008-07-18 4:25 UTC (permalink / raw) To: SungHyun Nam; +Cc: git SungHyun Nam <namsh@posdata.co.kr> writes: > And the 'skip_prefix()' returns NULL in this case. > (The old skip_prefix() never returns NULL). Thanks. Something like this? builtin-remote.c | 51 +++++++++++++++++++-------------------------------- 1 files changed, 19 insertions(+), 32 deletions(-) diff --git a/builtin-remote.c b/builtin-remote.c index 1491354..db12668 100644 --- a/builtin-remote.c +++ b/builtin-remote.c @@ -147,6 +147,15 @@ struct branch_info { static struct path_list branch_list; +static const char *abbrev_ref(const char *name, const char *prefix) +{ + const char *abbrev = skip_prefix(name, prefix); + if (abbrev) + return abbrev; + return name; +} +#define abbrev_branch(name) abbrev_ref((name), "refs/heads/") + static int config_read_branches(const char *key, const char *value, void *cb) { if (!prefixcmp(key, "branch.")) { @@ -176,18 +185,12 @@ static int config_read_branches(const char *key, const char *value, void *cb) info->remote = xstrdup(value); } else { char *space = strchr(value, ' '); - const char *ptr = skip_prefix(value, "refs/heads/"); - if (ptr) - value = ptr; + value = abbrev_branch(value); while (space) { char *merge; merge = xstrndup(value, space - value); path_list_append(merge, &info->merge); - ptr = skip_prefix(space + 1, "refs/heads/"); - if (ptr) - value = ptr; - else - value = space + 1; + value = abbrev_branch(space + 1); space = strchr(value, ' '); } path_list_append(xstrdup(value), &info->merge); @@ -219,12 +222,7 @@ static int handle_one_branch(const char *refname, refspec.dst = (char *)refname; if (!remote_find_tracking(states->remote, &refspec)) { struct path_list_item *item; - const char *name, *ptr; - ptr = skip_prefix(refspec.src, "refs/heads/"); - if (ptr) - name = ptr; - else - name = refspec.src; + const char *name = abbrev_branch(refspec.src); /* symbolic refs pointing nowhere were handled already */ if ((flags & REF_ISSYMREF) || unsorted_path_list_has_path(&states->tracked, @@ -253,7 +251,6 @@ static int get_ref_states(const struct ref *ref, struct ref_states *states) struct path_list *target = &states->tracked; unsigned char sha1[20]; void *util = NULL; - const char *ptr; if (!ref->peer_ref || read_ref(ref->peer_ref->name, sha1)) target = &states->new; @@ -262,10 +259,7 @@ static int get_ref_states(const struct ref *ref, struct ref_states *states) if (hashcmp(sha1, ref->new_sha1)) util = &states; } - ptr = skip_prefix(ref->name, "refs/heads/"); - if (!ptr) - ptr = ref->name; - path_list_append(ptr, target)->util = util; + path_list_append(abbrev_branch(ref->name), target)->util = util; } free_refs(fetch_map); @@ -460,10 +454,8 @@ static int append_ref_to_tracked_list(const char *refname, memset(&refspec, 0, sizeof(refspec)); refspec.dst = (char *)refname; - if (!remote_find_tracking(states->remote, &refspec)) { - path_list_append(skip_prefix(refspec.src, "refs/heads/"), - &states->tracked); - } + if (!remote_find_tracking(states->remote, &refspec)) + path_list_append(abbrev_branch(refspec.src), &states->tracked); return 0; } @@ -530,15 +522,10 @@ static int show(int argc, const char **argv) "es" : ""); for (i = 0; i < states.remote->push_refspec_nr; i++) { struct refspec *spec = states.remote->push + i; - const char *p = "", *q = ""; - if (spec->src) - p = skip_prefix(spec->src, "refs/heads/"); - if (spec->dst) - q = skip_prefix(spec->dst, "refs/heads/"); printf(" %s%s%s%s", spec->force ? "+" : "", - p ? p : spec->src, - spec->dst ? ":" : "", - q ? q : spec->dst); + abbrev_branch(spec->src), + spec->dst ? ":" : "", + spec->dst ? abbrev_branch(spec->dst) : ""); } printf("\n"); } @@ -588,7 +575,7 @@ static int prune(int argc, const char **argv) result |= delete_ref(refname, NULL); printf(" * [%s] %s\n", dry_run ? "would prune" : "pruned", - skip_prefix(refname, "refs/remotes/")); + abbrev_ref(refname, "refs/remotes/")); } /* NEEDSWORK: free remote */ ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: git-remote SEGV on t5505 test. 2008-07-18 4:25 ` Junio C Hamano @ 2008-07-18 5:44 ` SungHyun Nam 2008-07-18 6:18 ` Re* " Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: SungHyun Nam @ 2008-07-18 5:44 UTC (permalink / raw) To: git Junio C Hamano wrote: > SungHyun Nam <namsh@posdata.co.kr> writes: > >> And the 'skip_prefix()' returns NULL in this case. >> (The old skip_prefix() never returns NULL). > > Thanks. Something like this? With this patch, 'make test' passed all the tests successfully. I ran test with GIT_SKIP_TESTS="t90?? t91?? t92?? t94??". Regards, namsh P.S I skipped svn/cvs test because I don't need them (And no svn/cvs installed). But, I skipped send-email test because it fails. I thought I don't need to use send-email. And now I check what caused fail. The problem was this test script generates 'fake.sendmail' which uses '/bin/sh'. Is it possible that we can use 'SHELL_PATH' here? Or could you apply the patch below? diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index de5b980..0320aa1 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -16,7 +16,7 @@ test_expect_success \ '(echo "#!/bin/sh" echo shift echo output=1 - echo "while test -f commandline\$output; do output=\$((\$output+1)); done" + echo "while test -f commandline\$output; do output=\`expr \$output + 1\`; done" echo for a echo do echo " echo \"!\$a!\"" ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re* git-remote SEGV on t5505 test. 2008-07-18 5:44 ` SungHyun Nam @ 2008-07-18 6:18 ` Junio C Hamano 2008-07-18 6:26 ` Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2008-07-18 6:18 UTC (permalink / raw) To: SungHyun Nam; +Cc: git SungHyun Nam <namsh@posdata.co.kr> writes: > Is it possible that we can use 'SHELL_PATH' here? It is not just possible but we really should. There are other test scripts that use hardcoded /bin/sh, but by setting SHELL_PATH the user is already telling us that what the vendor has in /bin/sh isn't adequately POSIX enough, and we really should try to honor that. "git grep -n /bin/sh t/t*sh | grep -v ':1:#!'" would tell you which ones are suspect. --- t/t9001-send-email.sh | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index de5b980..1c857cf 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -13,7 +13,7 @@ test_expect_success \ test_expect_success \ 'Setup helper tool' \ - '(echo "#!/bin/sh" + '(echo "#!$SHELL_PATH" echo shift echo output=1 echo "while test -f commandline\$output; do output=\$((\$output+1)); done" @@ -138,7 +138,7 @@ test_expect_success 'Valid In-Reply-To when prompting' ' ' test_expect_success 'setup fake editor' ' - (echo "#!/bin/sh" && + (echo "#!$SHELL_PATH" && echo "echo fake edit >>\"\$1\"" ) >fake-editor && chmod +x fake-editor @@ -235,7 +235,7 @@ test_expect_success 'sendemail.cc unset' ' test_expect_success '--compose adds MIME for utf8 body' ' clean_fake_sendmail && - (echo "#!/bin/sh" && + (echo "#!$SHELL_PATH" && echo "echo utf8 body: àéìöú >>\"\$1\"" ) >fake-editor-utf8 && chmod +x fake-editor-utf8 && @@ -254,7 +254,7 @@ test_expect_success '--compose adds MIME for utf8 body' ' test_expect_success '--compose respects user mime type' ' clean_fake_sendmail && - (echo "#!/bin/sh" && + (echo "#!$SHELL_PATH" && echo "(echo MIME-Version: 1.0" echo " echo Content-Type: text/plain\\; charset=iso-8859-1" echo " echo Content-Transfer-Encoding: 8bit" ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Re* git-remote SEGV on t5505 test. 2008-07-18 6:18 ` Re* " Junio C Hamano @ 2008-07-18 6:26 ` Junio C Hamano 2008-07-18 9:07 ` SungHyun Nam 0 siblings, 1 reply; 7+ messages in thread From: Junio C Hamano @ 2008-07-18 6:26 UTC (permalink / raw) To: SungHyun Nam; +Cc: git Junio C Hamano <gitster@pobox.com> writes: > SungHyun Nam <namsh@posdata.co.kr> writes: > >> Is it possible that we can use 'SHELL_PATH' here? > > It is not just possible but we really should. There are other test > scripts that use hardcoded /bin/sh, but by setting SHELL_PATH the user is > already telling us that what the vendor has in /bin/sh isn't adequately > POSIX enough, and we really should try to honor that. > > "git grep -n /bin/sh t/t*sh | grep -v ':1:#!'" would tell you which ones > are suspect. SungHyun, I did not test this patch myself (all my shells grok $() command substitutions), so I won't be committing this until/unless I see a "tested on system X and works fine". ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re* git-remote SEGV on t5505 test. 2008-07-18 6:26 ` Junio C Hamano @ 2008-07-18 9:07 ` SungHyun Nam 2008-07-18 9:13 ` Junio C Hamano 0 siblings, 1 reply; 7+ messages in thread From: SungHyun Nam @ 2008-07-18 9:07 UTC (permalink / raw) To: git Junio C Hamano wrote: > Junio C Hamano <gitster@pobox.com> writes: > >> SungHyun Nam <namsh@posdata.co.kr> writes: >> >>> Is it possible that we can use 'SHELL_PATH' here? >> It is not just possible but we really should. There are other test >> scripts that use hardcoded /bin/sh, but by setting SHELL_PATH the user is >> already telling us that what the vendor has in /bin/sh isn't adequately >> POSIX enough, and we really should try to honor that. >> >> "git grep -n /bin/sh t/t*sh | grep -v ':1:#!'" would tell you which ones >> are suspect. > > SungHyun, I did not test this patch myself (all my shells grok $() command > substitutions), so I won't be committing this until/unless I see a "tested > on system X and works fine". I tested it on Solaris and works fine. ^^ $ uname -sro SunOS 5.9 Solaris $ SHELL_PATH=/bin/bash bash ./t9001-send-email.sh * ok 1: prepare reference tree * ok 2: Setup helper tool * ok 3: Extract patches * ok 4: Send patches * ok 5: Verify commandline * ok 6: Show all headers * ok 7: reject long lines * ok 8: no patch was sent * ok 9: allow long lines with --no-validate * ok 10: Invalid In-Reply-To * ok 11: Valid In-Reply-To when prompting * ok 12: setup fake editor * ok 13: --compose works * ok 14: first message is compose text * ok 15: second message is patch * ok 16: sendemail.cc set * ok 17: sendemail.cc unset * ok 18: --compose adds MIME for utf8 body * ok 19: --compose respects user mime type * ok 20: --compose adds MIME for utf8 subject * passed all 20 test(s) ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Re* git-remote SEGV on t5505 test. 2008-07-18 9:07 ` SungHyun Nam @ 2008-07-18 9:13 ` Junio C Hamano 0 siblings, 0 replies; 7+ messages in thread From: Junio C Hamano @ 2008-07-18 9:13 UTC (permalink / raw) To: SungHyun Nam; +Cc: git SungHyun Nam <namsh@posdata.co.kr> writes: >> SungHyun, I did not test this patch myself (all my shells grok $() command >> substitutions), so I won't be committing this until/unless I see a "tested >> on system X and works fine". > > I tested it on Solaris and works fine. ^^ Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-07-18 9:14 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-07-18 1:46 git-remote SEGV on t5505 test SungHyun Nam 2008-07-18 4:25 ` Junio C Hamano 2008-07-18 5:44 ` SungHyun Nam 2008-07-18 6:18 ` Re* " Junio C Hamano 2008-07-18 6:26 ` Junio C Hamano 2008-07-18 9:07 ` SungHyun Nam 2008-07-18 9:13 ` Junio C Hamano
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).