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

Re: [PATCH 4/8] git-repack --max-pack-size: add fixup_header_footer()

From
DHDana How <danahow@gmail.com>
Date
May 1, 2007, 05:41 UTC
Message-ID
<56b7f5510704302241n79601619kda8251a9f7776884@mail.gmail.com>
In-Reply-To
<20070501050633.GZ5942@spearce.org>
On 4/30/07, Shawn O. Pearce <spearce@spearce.org> wrote:
Show 13 quoted lines
> Dana How <danahow@gmail.com> wrote:
> > Add our own version of the one in fast-import.c here.
> > Needed later to correct bad object count in header for split pack.
> ...
> > diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
> > --- a/builtin-pack-objects.c
> > +++ b/builtin-pack-objects.c
> > @@ -562,6 +562,42 @@ static off_t write_one(struct sha1file *f,
> > +static void fixup_header_footer(int pack_fd, unsigned char *pack_file_sha1,
> > +                             char *pack_name, uint32_t object_count)
> > +{
>
> This looks a *lot* like the code in fast-import.c.
I hope so!  That's where I copied it from.
> Why not
> refactor both to use the same implementation and stuff it away in
> say pack-check.c (for lack of a better place), or start a new file
> (pack-write.c)?

Actually I didn't just copy it, I tried to rewrite it for my use as well as the fast-import.c use (note there is a 3rd copy in some *index*.c file which I didn't try to merge in yet). However I didn't yet put it in a new file or change fast-import.c to call it since I wanted to change as little as possible.

Show 9 quoted lines
> There is a *lot* of code in fast-import.c (over 2,000 lines) that
> was half-copied from other core code, and that was half created
> on its own.  This is also true in index-pack.c and pack-objects.c;
> I'd like to see these implementations unify more rather than copy
> code from each other.
>
> I know git-blame will identify the original author quite well,
> but I'd really like to avoid adding lots more code to maintain
> if we can avoid it.
I agree with all your arguments.  I had several reasons
to avoid extra rearrangements/refactorings:
(a) First patch to git, not previously known to me;
(b) I prefer to separate new functionality from "clean-up" work;
(c) I didn't really view myself as the person to make the *writing*
    code in git as well organized/minimized as the *reading* code
    [e.g. the sliding mmap stuff -- nice!];
(d) Apparently you and Nicolas Pitre have a lot of pending changes
    affecting the packing code.

I'd have no problem submitting a follow-on patch later containing some clean-up work if you & NP clear it, so I know I won't have problems from (d). Note I had to completely rewrite this patch when NP submitted some of his pending stuff.

NP wrote that you posted a summary of v3/v4 pack ideas, but I couldn't find it in the list archives. Could you either email it to me, or (re-)post it to the list?

Thanks,
-- 
Dana L. How  danahow@gmail.com  +1 650 804 5991 cell
Previous: Shawn O. PearceNext: Shawn O. Pearce
Message 3 of 8 in “git-repack --max-pack-size: add fixup_header_footer()”
  1. 4/8 git-repack --max-pack-size: add fixup_header_footer()Dana How, Apr 30, 2007
  2. Shawn O. PearceMay 1, 2007
  3. Dana HowMay 1, 2007
  4. Shawn O. PearceMay 1, 2007
  5. Johannes SchindelinMay 1, 2007
  6. Nicolas PitreMay 1, 2007
  7. Dana HowMay 1, 2007
  8. Nicolas PitreMay 1, 2007

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.