From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: Christian Couder <chriscool@tuxfamily.org>
Subject: Using ‘git replace’ to replace blobs
Date: Sat, 6 Feb 2010 19:10:56 -0600 [thread overview]
Message-ID: <20100207011056.GA15307@progeny.tock> (raw)
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")
next reply other threads:[~2010-02-07 1:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-07 1:10 Jonathan Nieder [this message]
2010-02-07 6:45 ` Using ‘git replace’ to replace blobs Christian Couder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100207011056.GA15307@progeny.tock \
--to=jrnieder@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).