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

Re: [PATCH 2/5] git-submodule: New subcommand 'summary' (2) - hard work

From
Ping Yin <pkufranky@gmail.com>
Date
Jan 12, 2008, 09:48 UTC
Message-ID
<46dff0320801120148r1a760bcdq4b9dcdf31354d9e0@mail.gmail.com>
In-Reply-To
<7vejcnv3zk.fsf@gitster.siamese.dyndns.org>
On Jan 12, 2008 4:32 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
> Ping Yin <pkufranky@gmail.com> writes:
>
>
> > +             check_dst=t
> > +             check_src=t
> > +             case $status in
> > +             D)
> > +                     check_dst=
> > +                     ;;
> > +             A)
> > +                     check_src=
> > +                     ;;
>
> I'd loosen the above grep (see my comments to your 1/5) and also
> add this:
>
>                 *)
>                         continue ;# punt
>                         ;;
>
> so that the rest of the code won't break when seeing a path that
> was submodule in the HEAD but is a blob in the index.

Right. I thought 'M' should be the default case because I missed the case 'T' (head blob but index submodule, or the reverse) .

Show 15 quoted lines
>
> > +             esac
> > +
> > +             (
> > +                     errmsg=
> > +                     unfound_src=
> > +                     unfound_dst=
> > +
> > +                     test -z "$check_src" ||
> > +                     GIT_DIR="$name/.git" git-rev-parse $sha1_src >&/dev/null ||
>
>
> I think you would want to read full 40-char sha1_src and
> sha1_dst with "while read", and keep that full 40-char in these
> variables, and use them when calling rev-parse here.

Hmm, precision is really a problem. However, "git diff --raw" will not always give full 40-char sha1, instead it will give sha1 with enough length. So maybe i can use the sha1 from "git diff --raw" ?

Show 5 quoted lines
>
> If you are checking if that the object exists in the submodule,
> use "rev-parse --verify", which was designed for exactly that
> purpose.  If you also want to verify if the object is a commit,
> which may be a good idea anyway, "rev-parse --verify $sha1_src^0".
Yes, --verify is better.
                   ;;
>
> When reporting errors, you would want to give full 40-chars...
>
As said before, enough is ok?
Show 30 quoted lines
> > +                     *)
> > +                             left=
> > +                             right=
> > +                             test -n "$check_src" &&
> > +                             left=$(GIT_DIR="$name/.git" git log --pretty=format:"  <%s" \
> > +                             ${check_dst:+$sha1_dst..}$sha1_src 2>/dev/null)
> > +
> > +                             test -n "$check_dst" &&
> > +                             right=$(GIT_DIR="$name/.git" git log --reverse --pretty=format:"  >%s" \
> > +                             ${check_src:+$sha1_src..}$sha1_dst 2>/dev/null)
> > +                             ;;
> > +                     esac
> > +
> > +                     echo "* $name $sha1_src...$sha1_dst:"
>
> While reporting like this, you would want the shortened form,
> perhaps produced your "cut -c1-7".
>
> > +                     if test -n "$errmsg"
> > +                     then
> > +                             echo "$errmsg"
> > +                     else
> > +                             test -n "$left" && echo "$left"
> > +                             test -n "$right" && echo "$right"
> > +                     fi
> > +                     echo
> > +             ) | sed 's/^/# /'
> > +     done
>
> I'd prefer to always have "-e" before the sed expression.
Is it not portable without "-e"?
Show 10 quoted lines
>
> Any reason why you want separate invocation of sed inside the
> while loop?  IOW, why isn't it like this?
>
>         git diff --raw |
>         while read ...
>         do
>                 ...
>         done | sed -e 's/^/# /'
>
Just because i'm stupid. :)
-- 
Ping Yin
Previous: Junio C HamanoNext: Ping Yin
Message 12 of 19 in “submodule summary support”
  1. 0/5 submodule summary supportPing Yin, Jan 12, 2008
  2. 1/5 git-submodule: New subcommand 'summary' (1) - code frameworkPing Yin, Jan 12, 2008
  3. 2/5 git-submodule: New subcommand 'summary' (2) - hard workPing Yin, Jan 12, 2008
  4. 3/5 git-submodule: New subcommand 'summary' (3) - limit summary sizePing Yin, Jan 12, 2008
  5. 4/5 git-status: submodule summary supportPing Yin, Jan 12, 2008
  6. 5/5 git-status: configurable submodule summary sizePing Yin, Jan 12, 2008
  7. Junio C HamanoJan 12, 2008
  8. Ping YinJan 12, 2008
  9. Junio C HamanoJan 12, 2008
  10. Ping YinJan 13, 2008
  11. Junio C HamanoJan 12, 2008
  12. Ping YinJan 12, 2008
  13. Ping YinJan 12, 2008
  14. Junio C HamanoJan 12, 2008
  15. Ping YinJan 12, 2008
  16. Junio C HamanoJan 12, 2008
  17. Ping YinJan 13, 2008
  18. Junio C HamanoJan 12, 2008
  19. Ping YinJan 12, 2008

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.