git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix incorrect ref namespace check
@ 2012-01-05 12:35 Nguyễn Thái Ngọc Duy
  2012-01-05 12:39 ` Nguyễn Thái Ngọc Duy
  0 siblings, 1 reply; 5+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-01-05 12:35 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy

The reason why the trailing slash is needed is obvious. refs/stash is
not a namespace, but a single ref. Do full string compare on it.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/fetch.c  |    2 +-
 builtin/remote.c |    2 +-
 log-tree.c       |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 33ad3aa..daa68d2 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -573,7 +573,7 @@ static void find_non_local_tags(struct transport *transport,
 
 	for_each_ref(add_existing, &existing_refs);
 	for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
-		if (prefixcmp(ref->name, "refs/tags"))
+		if (prefixcmp(ref->name, "refs/tags/"))
 			continue;
 
 		/*
diff --git a/builtin/remote.c b/builtin/remote.c
index 583eec9..f54a89a 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -534,7 +534,7 @@ static int add_branch_for_removal(const char *refname,
 	}
 
 	/* don't delete non-remote-tracking refs */
-	if (prefixcmp(refname, "refs/remotes")) {
+	if (prefixcmp(refname, "refs/remotes/")) {
 		/* advise user how to delete local branches */
 		if (!prefixcmp(refname, "refs/heads/"))
 			string_list_append(branches->skipped,
diff --git a/log-tree.c b/log-tree.c
index 319bd31..9a88fcc 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -119,7 +119,7 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
 		type = DECORATION_REF_REMOTE;
 	else if (!prefixcmp(refname, "refs/tags/"))
 		type = DECORATION_REF_TAG;
-	else if (!prefixcmp(refname, "refs/stash"))
+	else if (!strcmp(refname, "refs/stash"))
 		type = DECORATION_REF_STASH;
 	else if (!prefixcmp(refname, "HEAD"))
 		type = DECORATION_REF_HEAD;
-- 
1.7.8.36.g69ee2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] Fix incorrect ref namespace check
  2012-01-05 12:35 [PATCH] Fix incorrect ref namespace check Nguyễn Thái Ngọc Duy
@ 2012-01-05 12:39 ` Nguyễn Thái Ngọc Duy
  2012-01-05 16:23   ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2012-01-05 12:39 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy

The reason why the trailing slash is needed is obvious. refs/stash and
HEAD are not namespace, but complete refs. Do full string compare on them.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 I missed prefixcmp(..., "HEAD") right below prefixcmp(..., "refs/stash")

 builtin/fetch.c  |    2 +-
 builtin/remote.c |    2 +-
 log-tree.c       |    4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 33ad3aa..daa68d2 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -573,7 +573,7 @@ static void find_non_local_tags(struct transport *transport,
 
 	for_each_ref(add_existing, &existing_refs);
 	for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
-		if (prefixcmp(ref->name, "refs/tags"))
+		if (prefixcmp(ref->name, "refs/tags/"))
 			continue;
 
 		/*
diff --git a/builtin/remote.c b/builtin/remote.c
index 583eec9..f54a89a 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -534,7 +534,7 @@ static int add_branch_for_removal(const char *refname,
 	}
 
 	/* don't delete non-remote-tracking refs */
-	if (prefixcmp(refname, "refs/remotes")) {
+	if (prefixcmp(refname, "refs/remotes/")) {
 		/* advise user how to delete local branches */
 		if (!prefixcmp(refname, "refs/heads/"))
 			string_list_append(branches->skipped,
diff --git a/log-tree.c b/log-tree.c
index 319bd31..535b905 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -119,9 +119,9 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
 		type = DECORATION_REF_REMOTE;
 	else if (!prefixcmp(refname, "refs/tags/"))
 		type = DECORATION_REF_TAG;
-	else if (!prefixcmp(refname, "refs/stash"))
+	else if (!strcmp(refname, "refs/stash"))
 		type = DECORATION_REF_STASH;
-	else if (!prefixcmp(refname, "HEAD"))
+	else if (!strcmp(refname, "HEAD"))
 		type = DECORATION_REF_HEAD;
 
 	if (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS)
-- 
1.7.8.36.g69ee2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix incorrect ref namespace check
  2012-01-05 12:39 ` Nguyễn Thái Ngọc Duy
@ 2012-01-05 16:23   ` Junio C Hamano
  2012-01-11  1:54     ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2012-01-05 16:23 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, Michael Haggerty

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> The reason why the trailing slash is needed is obvious. refs/stash and
> HEAD are not namespace, but complete refs. Do full string compare on them.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  I missed prefixcmp(..., "HEAD") right below prefixcmp(..., "refs/stash")

As Michael has been actively showing interest in cleaning up the area, he
should have been CC'ed, I would think.

>
>  builtin/fetch.c  |    2 +-
>  builtin/remote.c |    2 +-
>  log-tree.c       |    4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> index 33ad3aa..daa68d2 100644
> --- a/builtin/fetch.c
> +++ b/builtin/fetch.c
> @@ -573,7 +573,7 @@ static void find_non_local_tags(struct transport *transport,
>  
>  	for_each_ref(add_existing, &existing_refs);
>  	for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
> -		if (prefixcmp(ref->name, "refs/tags"))
> +		if (prefixcmp(ref->name, "refs/tags/"))
>  			continue;
>  
>  		/*
> diff --git a/builtin/remote.c b/builtin/remote.c
> index 583eec9..f54a89a 100644
> --- a/builtin/remote.c
> +++ b/builtin/remote.c
> @@ -534,7 +534,7 @@ static int add_branch_for_removal(const char *refname,
>  	}
>  
>  	/* don't delete non-remote-tracking refs */
> -	if (prefixcmp(refname, "refs/remotes")) {
> +	if (prefixcmp(refname, "refs/remotes/")) {
>  		/* advise user how to delete local branches */
>  		if (!prefixcmp(refname, "refs/heads/"))
>  			string_list_append(branches->skipped,
> diff --git a/log-tree.c b/log-tree.c
> index 319bd31..535b905 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -119,9 +119,9 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
>  		type = DECORATION_REF_REMOTE;
>  	else if (!prefixcmp(refname, "refs/tags/"))
>  		type = DECORATION_REF_TAG;
> -	else if (!prefixcmp(refname, "refs/stash"))
> +	else if (!strcmp(refname, "refs/stash"))
>  		type = DECORATION_REF_STASH;
> -	else if (!prefixcmp(refname, "HEAD"))
> +	else if (!strcmp(refname, "HEAD"))
>  		type = DECORATION_REF_HEAD;
>  
>  	if (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix incorrect ref namespace check
  2012-01-05 16:23   ` Junio C Hamano
@ 2012-01-11  1:54     ` Nguyen Thai Ngoc Duy
  2012-01-11  4:49       ` Michael Haggerty
  0 siblings, 1 reply; 5+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2012-01-11  1:54 UTC (permalink / raw)
  To: Michael Haggerty; +Cc: git, Junio C Hamano

Any comments Mike?

2012/1/5 Junio C Hamano <gitster@pobox.com>:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>> The reason why the trailing slash is needed is obvious. refs/stash and
>> HEAD are not namespace, but complete refs. Do full string compare on them.
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>>  I missed prefixcmp(..., "HEAD") right below prefixcmp(..., "refs/stash")
>
> As Michael has been actively showing interest in cleaning up the area, he
> should have been CC'ed, I would think.
>
>>
>>  builtin/fetch.c  |    2 +-
>>  builtin/remote.c |    2 +-
>>  log-tree.c       |    4 ++--
>>  3 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>> index 33ad3aa..daa68d2 100644
>> --- a/builtin/fetch.c
>> +++ b/builtin/fetch.c
>> @@ -573,7 +573,7 @@ static void find_non_local_tags(struct transport *transport,
>>
>>       for_each_ref(add_existing, &existing_refs);
>>       for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
>> -             if (prefixcmp(ref->name, "refs/tags"))
>> +             if (prefixcmp(ref->name, "refs/tags/"))
>>                       continue;
>>
>>               /*
>> diff --git a/builtin/remote.c b/builtin/remote.c
>> index 583eec9..f54a89a 100644
>> --- a/builtin/remote.c
>> +++ b/builtin/remote.c
>> @@ -534,7 +534,7 @@ static int add_branch_for_removal(const char *refname,
>>       }
>>
>>       /* don't delete non-remote-tracking refs */
>> -     if (prefixcmp(refname, "refs/remotes")) {
>> +     if (prefixcmp(refname, "refs/remotes/")) {
>>               /* advise user how to delete local branches */
>>               if (!prefixcmp(refname, "refs/heads/"))
>>                       string_list_append(branches->skipped,
>> diff --git a/log-tree.c b/log-tree.c
>> index 319bd31..535b905 100644
>> --- a/log-tree.c
>> +++ b/log-tree.c
>> @@ -119,9 +119,9 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
>>               type = DECORATION_REF_REMOTE;
>>       else if (!prefixcmp(refname, "refs/tags/"))
>>               type = DECORATION_REF_TAG;
>> -     else if (!prefixcmp(refname, "refs/stash"))
>> +     else if (!strcmp(refname, "refs/stash"))
>>               type = DECORATION_REF_STASH;
>> -     else if (!prefixcmp(refname, "HEAD"))
>> +     else if (!strcmp(refname, "HEAD"))
>>               type = DECORATION_REF_HEAD;
>>
>>       if (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS)



-- 
Duy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Fix incorrect ref namespace check
  2012-01-11  1:54     ` Nguyen Thai Ngoc Duy
@ 2012-01-11  4:49       ` Michael Haggerty
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Haggerty @ 2012-01-11  4:49 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: git, Junio C Hamano

On 01/11/2012 02:54 AM, Nguyen Thai Ngoc Duy wrote:
> Any comments Mike?

Looks fine to me.

Theoretically, we could add an API for iterating over references
*excluding* a particular namespace, which (after hierarchical refs is
accepted) could be implemented a bit more efficiently than iterating
over all references and then excluding those in the unwanted namespace.
 But I think it would be far more trouble than it's worth.

Michael

> 2012/1/5 Junio C Hamano <gitster@pobox.com>:
>> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>>
>>> The reason why the trailing slash is needed is obvious. refs/stash and
>>> HEAD are not namespace, but complete refs. Do full string compare on them.
>>>
>>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>>> ---
>>>  I missed prefixcmp(..., "HEAD") right below prefixcmp(..., "refs/stash")
>>
>> As Michael has been actively showing interest in cleaning up the area, he
>> should have been CC'ed, I would think.
>>
>>>
>>>  builtin/fetch.c  |    2 +-
>>>  builtin/remote.c |    2 +-
>>>  log-tree.c       |    4 ++--
>>>  3 files changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/builtin/fetch.c b/builtin/fetch.c
>>> index 33ad3aa..daa68d2 100644
>>> --- a/builtin/fetch.c
>>> +++ b/builtin/fetch.c
>>> @@ -573,7 +573,7 @@ static void find_non_local_tags(struct transport *transport,
>>>
>>>       for_each_ref(add_existing, &existing_refs);
>>>       for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) {
>>> -             if (prefixcmp(ref->name, "refs/tags"))
>>> +             if (prefixcmp(ref->name, "refs/tags/"))
>>>                       continue;
>>>
>>>               /*
>>> diff --git a/builtin/remote.c b/builtin/remote.c
>>> index 583eec9..f54a89a 100644
>>> --- a/builtin/remote.c
>>> +++ b/builtin/remote.c
>>> @@ -534,7 +534,7 @@ static int add_branch_for_removal(const char *refname,
>>>       }
>>>
>>>       /* don't delete non-remote-tracking refs */
>>> -     if (prefixcmp(refname, "refs/remotes")) {
>>> +     if (prefixcmp(refname, "refs/remotes/")) {
>>>               /* advise user how to delete local branches */
>>>               if (!prefixcmp(refname, "refs/heads/"))
>>>                       string_list_append(branches->skipped,
>>> diff --git a/log-tree.c b/log-tree.c
>>> index 319bd31..535b905 100644
>>> --- a/log-tree.c
>>> +++ b/log-tree.c
>>> @@ -119,9 +119,9 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in
>>>               type = DECORATION_REF_REMOTE;
>>>       else if (!prefixcmp(refname, "refs/tags/"))
>>>               type = DECORATION_REF_TAG;
>>> -     else if (!prefixcmp(refname, "refs/stash"))
>>> +     else if (!strcmp(refname, "refs/stash"))
>>>               type = DECORATION_REF_STASH;
>>> -     else if (!prefixcmp(refname, "HEAD"))
>>> +     else if (!strcmp(refname, "HEAD"))
>>>               type = DECORATION_REF_HEAD;
>>>
>>>       if (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS)
> 
> 
> 


-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-01-11  4:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-05 12:35 [PATCH] Fix incorrect ref namespace check Nguyễn Thái Ngọc Duy
2012-01-05 12:39 ` Nguyễn Thái Ngọc Duy
2012-01-05 16:23   ` Junio C Hamano
2012-01-11  1:54     ` Nguyen Thai Ngoc Duy
2012-01-11  4:49       ` Michael Haggerty

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