Using ‘git replace’ to replace blobs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
 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")
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]