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

Fix for normalization of foreign idents

From
Marcus Comstedt <marcus@mc.pp.se>
Date
Aug 23, 2010, 21:30 UTC
Message-ID
<1282599032-11369-1-git-send-email-marcus@mc.pp.se>
Hi.

The new behaviour that $Id$ tags containing expanded idents from other version control systems, nice though it is, has a rather serious problem. This is because convert_to_git is no longer the inverse operation of convert_to_working_tree. For native git idents, the transformations are

  $Id$ --(c_t_w_t)--> $Id: 123...$ --(c_t_g)--> $Id$
but for foreign idents, it becomes
  $Id: blah$ --(c_t_w_t)--> $Id: blah$ --(c_t_g)--> $Id$

The result of this is that git may consider even newly checked out files as modified, even though neither the file contents nor its attributes have been modified after the checkout. I say _may_, because it can also happen that it decides based on the time stamps that it doesn't need to compare the actual contents, in which case the file does not show as modified.

The following patch fixes this by preserving the foreign ident also in convert_to_git, meaning that convert_to_git is again the inverse operation of convert_to_working_tree, with the following transformation series:

  $Id: blah$ --(c_t_w_t)--> $Id: blah$ --(c_t_g)--> $Id: blah$

This restores correct and deterministic operation of status and diff, meaning that if the file hasn't actually been modified, no modifications are shown.

As you might suggest, always keeping the foreign ident would mean it is never updated when you commit new versions of the file, which isn't really what we want. Keeping the foreign ident as long as the last modification to the file was made in the previous version control system makes perfect sense, but once we make a commit to the file within git, it should be replaced with a git ident. The patch is therefore slightly more complex, adding an extra parameter to control whether foreign idents are collapsed or not. This parameter is set to true only in the case when index_mem is called with write_object set to true, which is to say when we create a new blob from the working tree (i.e. we are committing the file).

I hope we can agree that this is a sound and unintrusive way of handling the problem. :-)

Incidentally, should one want to create a commit to replace a foreign ident with a native git one without making any other changes to the file, this is still simple to do. All that is needed is to change any character inside the expanded ident in the working tree, and the file will show as modified, and will have the foreign ident removed on commit.

  // Marcus
Next: Marcus Comstedt
Message 1 of 19 in “Fix for normalization of foreign idents”
  1. Marcus ComstedtAug 23, 2010
  2. convert: fix normalization of foreign identsMarcus Comstedt, Aug 23, 2010
  3. Jonathan NiederAug 23, 2010
  4. Marcus ComstedtAug 23, 2010
  5. Jonathan NiederAug 23, 2010
  6. Junio C HamanoAug 23, 2010
  7. Marcus ComstedtAug 24, 2010
  8. Marcus ComstedtSep 6, 2010
  9. Jonathan NiederSep 6, 2010
  10. Marcus ComstedtSep 7, 2010
  11. 1/2 convert: fix normalization of foreign identsMarcus Comstedt, Aug 23, 2010
  12. Junio C HamanoSep 10, 2010
  13. Marcus ComstedtSep 12, 2010
  14. Junio C HamanoSep 12, 2010
  15. Marcus ComstedtSep 12, 2010
  16. convert: generalize checksafe parameterMarcus Comstedt, Sep 13, 2010
  17. 2/2 t0021: test checkout and commit of foreign identsMarcus Comstedt, Sep 7, 2010
  18. 0/2 fix normalization of foreign idents (now with test cases)Marcus Comstedt, Sep 7, 2010
  19. Jonathan NiederSep 8, 2010

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.