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

Re: [PATCH 3/3] fast-export: output reset command for commandline revs

From
Sverre Rabbelier <srabbelier@gmail.com>
Date
Nov 6, 2011, 19:48 UTC
Message-ID
<CAGdFq_gkSxvw9Di_mUqS5N0bgCWh-dygMe_DWcR+ENAo=A-3=A@mail.gmail.com>
In-Reply-To
<20111106050126.GO27272@elie.hsd1.il.comcast.net>
Heya,
On Sun, Nov 6, 2011 at 06:01, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Thanks.  I'd suggest squashing in the test from patch 1/3 for easy
> reference (since each patch makes the other easier to understand).

Yes, agreed. The initial series was 5 patches in total, but splitting it out for such a small series (and small patch at that) makes less sense.

> These details seem like good details for the commit message, so the
> next puzzled person looking at the code can see what behavior is
> deliberate and what are the incidental side-effects.
All of it? I wasn't sure what part should go in the commit message.
> The "git fast-export a..$(git rev-parse HEAD^{commit})" case sounds
> worth a test.
A test_must_fail?
>> +#define REF_HANDLED (ALL_REV_FLAGS + 1)
>
> Could TMP_MARK be used for this?
I don't know its usage, is it?
Show 9 quoted lines
> -static void handle_tags_and_duplicates(struct string_list *extra_refs)
>> +static void handle_tags_and_duplicates(struct rev_info *revs, struct string_list *extra_refs)
>>  {
>>       int i;
>>
>> +     /* even if no commits were exported, we need to export the ref */
>> +     for (i = 0; i < revs->cmdline.nr; i++) {
>
> Might be clearer in a new function.
Yes, probably. handle_cmdline_refs?
Show 9 quoted lines
>> +             struct rev_cmdline_entry *elem = &revs->cmdline.rev[i];
>> +
>> +             if (elem->flags & UNINTERESTING)
>> +                     continue;
>> +
>> +             if (elem->whence != REV_CMD_REV && elem->whence != REV_CMD_RIGHT)
>> +                     continue;
>
> Oh, neat.

Yes, I must admit that this bit was easier than I dreaded it would be (I must admit that's been a large reason that I haven't taken the time to work on this till now). With the fast-export and remote-helper tests to guide me, I was able to code-by-accident the right conditions here :).

>> +
>> +             char *full_name;
>
> declaration-after-statement
Ah, yes.
Show 6 quoted lines
>> +             dwim_ref(elem->name, strlen(elem->name), elem->item->sha1, &full_name);
>> +
>> +             if (!prefixcmp(full_name, "refs/tags/") &&
>
> What happens if dwim_ref fails, perhaps because a ref was deleted in
> the meantime?

That would be bad. I assumed that we have a lock on the refs, should I add back the die check that's done by the other dwim_ref caller?

Show 12 quoted lines
>> +                     (tag_of_filtered_mode != REWRITE ||
>> +                     !get_object_mark(elem->item)))
>> +                     continue;
>
> Style nit: this would be easier to read if the "if" condition doesn't
> line up with the code below it:
>
>                if (!prefixcmp(full_name, "refs/tags/")) {
>                        if (tag_of_filtered_mode != REWRITE ||
>                            !get_object_mark(elem->item))
>                                continue;
>                }
Yeah, that does look better :).
> If tag_of_filtered_mode == ABORT, we are going to die() soon, right?

I don't know to be honest, perhaps we would have already died by now? I don't know the details of how the tag_of_filtered_mode part is implemented.

> So this seems to be about tag_of_filtered_mode == DROP --- makes
> sense.
>
> When does the !get_object_mark() case come up?

Eh, it has something to do with it being a replacement (rather than the same), maybe? This is mostly just taken from Dscho's original patch.

Show 7 quoted lines
>> +             if (!(elem->flags & REF_HANDLED)) {
>> +                     handle_reset(full_name, elem->item);
>> +                     elem->flags |= REF_HANDLED;
>> +             }
>
> Just curious: is the REF_HANDLED handling actually needed?  What
> would happen if fast-export included the redundant resets?

That would just be sloppy :). I don't think anything particularly bad would happen.

> Thanks for a pleasant read.
Thanks for the review.
-- 
Cheers,

Sverre Rabbelier
Previous: Jonathan NiederNext: Jonathan Nieder
Message 37 of 42 in “fast-export fixes”
  1. 0/3 fast-export fixesSverre Rabbelier, Nov 5, 2011
  2. 1/3 t9350: point out that refs are not updated correctlySverre Rabbelier, Nov 5, 2011
  3. Jonathan NiederNov 6, 2011
  4. Sverre RabbelierNov 6, 2011
  5. Jonathan NiederNov 7, 2011
  6. Felipe ContrerasOct 24, 2012
  7. Jonathan NiederOct 24, 2012
  8. Felipe ContrerasOct 24, 2012
  9. Jonathan NiederOct 24, 2012
  10. Felipe ContrerasOct 25, 2012
  11. Jonathan NiederOct 25, 2012
  12. Felipe ContrerasOct 25, 2012
  13. Jonathan NiederOct 25, 2012
  14. Sverre RabbelierOct 25, 2012
  15. Felipe ContrerasOct 25, 2012
  16. Sverre RabbelierOct 25, 2012
  17. Felipe ContrerasOct 25, 2012
  18. Sverre RabbelierOct 25, 2012
  19. Jonathan NiederOct 25, 2012
  20. Sverre RabbelierOct 25, 2012
  21. Jonathan NiederOct 25, 2012
  22. Sverre RabbelierOct 25, 2012
  23. Felipe ContrerasOct 25, 2012
  24. Felipe ContrerasOct 25, 2012
  25. Jonathan NiederOct 25, 2012
  26. Felipe ContrerasOct 25, 2012
  27. Jonathan NiederOct 25, 2012
  28. Felipe ContrerasOct 25, 2012
  29. Johannes SchindelinOct 24, 2012
  30. Felipe ContrerasOct 25, 2012
  31. 2/3 fast-export: do not refer to non-existing marksSverre Rabbelier, Nov 5, 2011
  32. Jonathan NiederNov 6, 2011
  33. Sverre RabbelierNov 6, 2011
  34. Johannes SchindelinJan 29, 2019
  35. 3/3 fast-export: output reset command for commandline revsSverre Rabbelier, Nov 5, 2011
  36. Jonathan NiederNov 6, 2011
  37. Sverre RabbelierNov 6, 2011
  38. Jonathan NiederNov 7, 2011
  39. Junio C HamanoNov 7, 2011
  40. Junio C HamanoNov 7, 2011
  41. Thomas RastNov 30, 2011
  42. Felipe ContrerasOct 24, 2012

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.