git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] sha1_name: reorganize get_sha1_basic()

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 2, 2013, 19:59 UTC
Message-ID
<CAMP44s3-TM1PW6qKAFRf=Sdojw3RNscM_VJZfBy3C7xHZst_Wg@mail.gmail.com>
In-Reply-To
<1367524078-13266-1-git-send-email-artagnon@gmail.com>
On Thu, May 2, 2013 at 2:47 PM, Ramkumar Ramachandra <artagnon@gmail.com> wrote:
Show 22 quoted lines
> A small suggestion.  Squash this in if you like; optionally submit it
> as a separate part.
>
> diff --git a/sha1_name.c b/sha1_name.c
> index 6428001..109ab41 100644
> --- a/sha1_name.c
> +++ b/sha1_name.c
> @@ -448,11 +448,12 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
>         if (len && str[len-1] == '}') {
>                 for (at = len-2; at >= 0; at--) {
>                         if (str[at] == '@' && str[at+1] == '{') {
> -                               if (at == 0 && str[2] == '-') {
> -                                       nth_prior = 1;
> -                                       continue;
> -                               }
> -                               if (!upstream_mark(str + at, len - at)) {
> +                               if (str[at+2] == '-') {
> +                                       if (at != 0)
> +                                               return -1;
> +                                       else
> +                                               nth_prior = 1;
> +                               } else if (!upstream_mark(str + at, len - at)) {
Generally I don't like this style, it's prone to multiple indentation levels.
                        if (str[at] == '@' && str[at+1] == '{') {
-                               if (at == 0 && str[2] == '-') {
+                               if (str[at+2] == '-') {
+                                       if (at != 0)
+                                               /* @{-N} not at start */
+                                               return -1;
                                        nth_prior = 1;
                                        continue;
                                }
Otherwise makes sense, but I would do it as a separate patch.
-- 
Felipe Contreras
Previous: Ramkumar Ramachandra
Message 7 of 7 in “sha1_name: reorganize get_sha1_basic()”
  1. sha1_name: reorganize get_sha1_basic()Felipe Contreras, May 2, 2013
  2. Felipe ContrerasMay 2, 2013
  3. Ramkumar RamachandraMay 2, 2013
  4. Felipe ContrerasMay 2, 2013
  5. Ramkumar RamachandraMay 2, 2013
  6. Ramkumar RamachandraMay 2, 2013
  7. Felipe ContrerasMay 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.