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

Re: diff-index --cc no longer permitted, gitk is now broken (slightly)

From
Sergey Organov <sorganov@gmail.com>
Date
Aug 30, 2021, 20:01 UTC
Message-ID
<87pmtuzoql.fsf@osv.gnss.ru>
In-Reply-To
<YS0f37xPKOHCDHr1@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 66 quoted lines
> On Mon, Aug 30, 2021 at 04:05:50PM +0300, Sergey Organov wrote:
>
>> > Is gitk wrong to add --cc unconditionally? Should it do so only when
>> > there are conflicts? Or not at all?
>> 
>> As far as I can tell, --cc had no effect on diff-index, it was just
>> silently consumed. If I'm right, this line in gitk never needed --cc.
>> Then either gitk is to be fixed, or we can "fix" diff-index to silently
>> consume --cc/-c again, for backward compatibility.
>
> I think it does have an effect. Try this to generate a simple merge
> conflict:
>
>   git init repo
>   cd repo
>
>   echo base >file
>   git add file
>   git commit -m base
>
>   echo main >file
>   git commit -am main
>
>   git checkout -b side HEAD^
>   echo side >file
>   git commit -am side
>
>   git merge main ;# maybe master here depending on your config
>
> And then with pre-v2.33 Git, --cc does a combined diff:
>
>   $ git.v2.32.0 diff-index -p  HEAD
>   diff --git a/file b/file
>   index 2299c37..81768df 100644
>   --- a/file
>   +++ b/file
>   @@ -1 +1,5 @@
>   +<<<<<<< HEAD
>    side
>   +=======
>   +main
>   +>>>>>>> main
>
>   $ git.v2.32.0 diff-index --cc HEAD
>   diff --cc file
>   index df967b9,2299c37..0000000
>   --- a/file
>   +++ b/file
>   @@@ -1,1 -1,1 +1,5 @@@
>   - base
>   ++<<<<<<< HEAD
>   + side
>   ++=======
>   ++main
>   ++>>>>>>> main
>
> Likewise, --raw will show a combined diff, though it's a bit less useful
> because the unmerged entry has a null sha1:
>
>   $ git.v2.32.0 diff-index HEAD
>   :100644 100644 2299c37978265a95cbe835a4b0f0bbf15aad5549 0000000000000000000000000000000000000000 M	file
>
>   $ git.v2.32.0 diff-index --cc --raw HEAD
>   ::100644 100644 100644 df967b96a579e45a18b8251732d16804b2e56a55 2299c37978265a95cbe835a4b0f0bbf15aad5549 0000000000000000000000000000000000000000 MM	file
>
> -Peff

Well, thanks! As it does make a difference, it's a pity it's neither documented nor being tested.

I need to review the issue more closely to give a fix then.

Thanks, -- Sergey Organov

Previous: Jeff KingNext: Johannes Sixt
Message 4 of 29 in “diff-index --cc no longer permitted, gitk is now broken (slightly)”
  1. Johannes SixtAug 30, 2021
  2. Sergey OrganovAug 30, 2021
  3. Jeff KingAug 30, 2021
  4. Sergey OrganovAug 30, 2021
  5. Johannes SixtAug 30, 2021
  6. Sergey OrganovAug 30, 2021
  7. Junio C HamanoAug 30, 2021
  8. Sergey OrganovAug 30, 2021
  9. Junio C HamanoAug 30, 2021
  10. Sergey OrganovAug 30, 2021
  11. Sergey OrganovSep 1, 2021
  12. Junio C HamanoSep 7, 2021
  13. Sergey OrganovSep 7, 2021
  14. Sergey OrganovSep 8, 2021
  15. Johannes SixtSep 8, 2021
  16. Sergey OrganovSep 8, 2021
  17. Junio C HamanoSep 9, 2021
  18. Sergey OrganovSep 9, 2021
  19. Sergey OrganovSep 16, 2021
  20. Junio C HamanoSep 16, 2021
  21. Sergey OrganovSep 16, 2021
  22. Junio C HamanoSep 16, 2021
  23. Sergey OrganovSep 17, 2021
  24. Junio C HamanoSep 17, 2021
  25. Sergey OrganovSep 17, 2021
  26. Philip OakleySep 17, 2021
  27. Sergey OrganovSep 17, 2021
  28. Sergey OrganovSep 18, 2021
  29. Johannes SixtSep 7, 2021

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.