git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Using ‘git replace’ to replace blobs
@ 2010-02-07  1:10 Jonathan Nieder
  2010-02-07  6:45 ` Christian Couder
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Nieder @ 2010-02-07  1:10 UTC (permalink / raw)
  To: git; +Cc: Christian Couder

I think it is a known problem that ‘git replace’ cannot be used safely
to replace blobs used in the currently checked out commit.  The man
page says:

	Comparing blobs or trees that have been replaced with
	those that replace them will not work properly.

Indeed, in practice it produces problems. [1]

I would like to start to fix this.  But the correct semantics are not
obvious to me:

 - When writing a tree from an index that includes replaced blobs,
   should the result use the original blobs or the replaced ones?

 - When reading a tree that includes replaced blobs, should the
   resulting cache entries use the original blobs or the replaced
   ones?

My hunch is to say both should use the replaced blobs.  This way,
replacing a blob in a checked-out index would behave in a more
intuitive way, and git filter-branch would make permanent any
substitutions requested through replaced blob entries.

I have not thought it through completely, though.

Thoughts?
Jonathan

[1] For example,

 git init repo
 cd repo
 echo first > 1.txt
 echo second > 2.txt
 git add 1.txt 2.txt
 git commit -m demonstration
 git show --raw
 git ls-tree HEAD | awk '
	NR == 1 { first = $3 }
	NR == 2 { system("git replace " first " " $3) }
 '
 git status
 rm *
 git checkout -f
 git status

which one would expect to result in a clean tree, produces

 Initialized empty Git repository in /tmp/repo/.git/
 [master (root-commit) 998cc27] demonstration
  2 files changed, 2 insertions(+), 0 deletions(-)
  create mode 100644 1.txt
  create mode 100644 2.txt
 commit 998cc270986f68450f00bda5e5db62f31367ff96
 Author: Jonathan Nieder <jrnieder@gmail.com>
 Date:   Sat Feb 6 18:48:50 2010 -0600

     demonstration

 :000000 100644 0000000... 9c59e24... A  1.txt
 :000000 100644 0000000... e019be0... A  2.txt
 # On branch master
 nothing to commit (working directory clean)
 # On branch master
 # Changed but not updated:
 #   (use "git add <file>..." to update what will be committed)
 #   (use "git checkout -- <file>..." to discard changes in working
 #   directory)
 #
 #       modified:   1.txt
 #
 no changes added to commit (use "git add" and/or "git commit -a")

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-07  6:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-07  1:10 Using ‘git replace’ to replace blobs Jonathan Nieder
2010-02-07  6:45 ` Christian Couder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).