From: Jonathan Nieder <jrnieder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, John Fultz <jfultz@wolfram.com>
Subject: Re: [PATCH] filter-branch: resolve $commit^{tree} in no-index case
Date: Tue, 19 Jan 2016 17:22:53 -0800 [thread overview]
Message-ID: <20160120012253.GD16090@google.com> (raw)
In-Reply-To: <20160119222802.GC6556@sigill.intra.peff.net>
Jeff King wrote:
> On Tue, Jan 19, 2016 at 04:59:28PM -0500, Jeff King wrote:
>> We could get away "git diff --exit-code $1 $2" to do a single process
>> invocation (rather than two rev-parses), but I don't know if it is worth
>> the complexity.
>
> And here's that patch.
>
> I'm actually a little iffy on it because it switches to "diff-tree" from
> a raw-sha1 comparison. For a well-formed repo, that shouldn't matter.
> But what if you had a commit that was replacing a malformed tree object,
> but not otherwise changing the diff? We might drop it as "empty", even
> though you'd prefer to keep it.
Mph. We could get the best of both worlds by introducing a "git
rev-parse --compare <a> <b>" that compares object ids. Actually...
How about something like this?
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
git-filter-branch.sh | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 86b2ff1..06f4e0f 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -44,7 +44,15 @@ skip_commit()
# it will skip commits that leave the tree untouched, commit the other.
git_commit_non_empty_tree()
{
- if test $# = 3 && test "$1" = $(git rev-parse "$3^{tree}"); then
+ if
+ test $# = 3 &&
+ git rev-parse "$1" "$3^{tree}" |
+ {
+ read a
+ read b
+ test "$a" = "$b"
+ }
+ then
map "$3"
else
git commit-tree "$@"
@@ -404,7 +412,7 @@ while read commit parents; do
then
tree=$(git write-tree)
else
- tree=$(git rev-parse "$commit^{tree}")
+ tree="$commit^{tree}"
fi
workdir=$workdir @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
"$tree" $parentstr < ../message > ../map/$commit ||
--
2.7.0
next prev parent reply other threads:[~2016-01-20 1:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-19 20:48 git filter-branch not removing commits when it should in 2.7.0 John Fultz
2016-01-19 21:14 ` Junio C Hamano
2016-01-19 21:35 ` Junio C Hamano
2016-01-19 21:37 ` Jeff King
2016-01-19 21:46 ` Junio C Hamano
2016-01-19 21:51 ` [PATCH] filter-branch: resolve $commit^{tree} in no-index case Jeff King
2016-01-19 21:59 ` Jeff King
2016-01-19 22:07 ` Jeff King
2016-01-19 22:23 ` Junio C Hamano
2016-01-19 22:28 ` Jeff King
2016-01-19 22:48 ` Jeff King
2016-01-20 1:22 ` Jonathan Nieder [this message]
2016-01-20 1:34 ` Jeff King
2016-01-20 1:51 ` Junio C Hamano
2016-01-20 2:00 ` Jeff King
2016-01-20 2:43 ` Junio C Hamano
2016-01-20 3:23 ` Junio C Hamano
2016-01-20 4:14 ` Jeff King
2016-01-20 0:47 ` Jonathan Nieder
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=20160120012253.GD16090@google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jfultz@wolfram.com \
--cc=peff@peff.net \
/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).