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

Re: [PATCH v3] Accept tags in HEAD or MERGE_HEAD

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Aug 19, 2011, 12:53 UTC
Message-ID
<CACsJy8CWFv3dvhd1rWdgc6i5f8xTz-skHxEvgw=hgVUPUW6Fmw@mail.gmail.com>
In-Reply-To
<7vd3g2a431.fsf@alter.siamese.dyndns.org>
2011/8/19 Junio C Hamano <gitster@pobox.com>:
Show 17 quoted lines
>>  static unsigned char head_sha1[20];
>> +static struct commit *head_commit;
>
> I was not happy with the file-scope global head_sha1[] already, and this
> makes me even less happy. Was it too much trouble to keep them local to
> cmd_commit() and pass them around as arguments where necessary?  If you
> pass around head_commit, is_null_sha1(head_sha1) can be replaced with a
> check !head_commit so we may even be able to lose the head_sha1[] global.
>
> And actually removing head_sha1[] is a necessary step from the correctness
> point of view. The repository may have given an object name for a tag in
> head_sha1[] and lookup_expect_commit() may have peeled it to a commit.
> The code may want to add the "HEAD" as one of the parents of a new commit,
> and head_sha1[] is no longer the place to pick that information up after
> your fix. The code needs to look at head_commit->object.sha1[] instead.
> Losing the use of head_sha1[] variable and forcing the code to go to
> head_commit->object.sha1[] reduces the risk of such confusion.

I actually wanted to get rid of head_sha1 but it made changes bigger. But the patch's become big already. Let me remove head_sha1[] (and head[] in merge.c) globally, then put this fix on top.

-- 
Duy
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 11 of 21 in “commit: check return value of lookup_commit()”
  1. commit: check return value of lookup_commit()Nguyễn Thái Ngọc Duy, Aug 15, 2011
  2. Junio C HamanoAug 15, 2011
  3. Nguyen Thai Ngoc DuyAug 16, 2011
  4. Junio C HamanoAug 16, 2011
  5. Nguyen Thai Ngoc DuyAug 17, 2011
  6. commit: accept tag objects in HEAD/MERGE_HEADNguyễn Thái Ngọc Duy, Aug 17, 2011
  7. Junio C HamanoAug 17, 2011
  8. Nguyen Thai Ngoc DuyAug 18, 2011
  9. Accept tags in HEAD or MERGE_HEADNguyễn Thái Ngọc Duy, Aug 18, 2011
  10. Junio C HamanoAug 18, 2011
  11. Nguyen Thai Ngoc DuyAug 19, 2011
  12. 1/4 commit: remove global variable head_sha1[]Nguyễn Thái Ngọc Duy, Aug 19, 2011
  13. 2/4 merge: keep stash[] a local variableNguyễn Thái Ngọc Duy, Aug 19, 2011
  14. Junio C HamanoAug 19, 2011
  15. 3/4 merge: remove global variable head[]Nguyễn Thái Ngọc Duy, Aug 19, 2011
  16. Junio C HamanoAug 23, 2011
  17. 4/4 Accept tags in HEAD or MERGE_HEADNguyễn Thái Ngọc Duy, Aug 19, 2011
  18. Junio C HamanoAug 19, 2011
  19. Nguyen Thai Ngoc DuyAug 20, 2011
  20. Junio C HamanoAug 19, 2011
  21. Nguyen Thai Ngoc DuyAug 20, 2011

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.