builtin/replace: unset read_replace_refs

When checking to see if some objects are of the same type and when displaying the type of objects, git replace uses the sha1_object_info() function. Unfortunately this function by default respects replace refs, so instead of the type of a replaced object, it gives the type of the replacement object which might be different. To fix this bug, and because git replace should work at a level before replacement takes place, let's unset the read_replace_refs global variable at the beginning of cmd_replace(). Suggested-by: Jeff King <peff@peff.net> Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Christian Couder committed Dec 11, 2013 at 08:46 UTC 769a4fa463bb36ba78eb318f25e0e211f4fae949
2 files changed +3 -1
builtin/replace.c
+2
@@ -174,6 +174,8 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
174 OPT_END()
175 };
176
177 + read_replace_refs = 0;
178 +
179 argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
180
181 if (list && delete)
t/t6050-replace.sh
+1 -1
@@ -306,7 +306,7 @@ test_expect_success 'test --format medium' '
306 test_cmp expected actual
307 '
308
309 -test_expect_failure 'test --format full' '
309 +test_expect_success 'test --format full' '
310 {
311 echo "$H1 (commit) -> $BLOB (blob)" &&
312 echo "$BLOB (blob) -> $REPLACED (blob)" &&