git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 09/10] builtin/replace: unset read_replace_refs

From
Christian Couder <chriscool@tuxfamily.org>
Date
Dec 11, 2013, 07:46 UTC
Message-ID
<20131211074614.11117.18678.chriscool@tuxfamily.org>
In-Reply-To
<20131211074147.11117.1155.chriscool@tuxfamily.org>

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>
---
 builtin/replace.c  | 2 ++
 t/t6050-replace.sh | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/builtin/replace.c b/builtin/replace.c
index 9f3619a..1672870 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -174,6 +174,8 @@ int cmd_replace(int argc, const char **argv, const char *prefix)
 		OPT_END()
 	};
 
+	read_replace_refs = 0;
+
 	argc = parse_options(argc, argv, prefix, options, git_replace_usage, 0);
 
 	if (list && delete)
diff --git a/t/t6050-replace.sh b/t/t6050-replace.sh
index e1cc3b8..d0c62f7 100755
--- a/t/t6050-replace.sh
+++ b/t/t6050-replace.sh
@@ -306,7 +306,7 @@ test_expect_success 'test --format medium' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'test --format full' '
+test_expect_success 'test --format full' '
 	{
 		echo "$H1 (commit) -> $BLOB (blob)" &&
 		echo "$BLOB (blob) -> $REPLACED (blob)" &&
-- 
1.8.5.1.102.g090758b
Previous: Christian CouderNext: Christian Couder
Message 18 of 20 in “teach replace objects to sha1_object_info_extended()”
  1. 00/10 teach replace objects to sha1_object_info_extended()Christian Couder, Dec 11, 2013
  2. 01/10 Rename READ_SHA1_FILE_REPLACE flag to LOOKUP_REPLACE_OBJECTChristian Couder, Dec 11, 2013
  3. 02/10 replace_object: don't check read_replace_refs twiceChristian Couder, Dec 11, 2013
  4. 03/10 Introduce lookup_replace_object_extended() to pass flagsChristian Couder, Dec 11, 2013
  5. 04/10 Add an "unsigned flags" parameter to sha1_object_info_extended()Christian Couder, Dec 11, 2013
  6. 05/10 t6050: show that git cat-file --batch fails with replace objectsChristian Couder, Dec 11, 2013
  7. 06/10 sha1_file: perform object replacement in sha1_object_info_extended()Christian Couder, Dec 11, 2013
  8. 07/10 builtin/replace: teach listing using short, medium or full formatsChristian Couder, Dec 11, 2013
  9. Karsten BleesDec 18, 2013
  10. Christian CouderDec 18, 2013
  11. Junio C HamanoDec 18, 2013
  12. Christian CouderDec 19, 2013
  13. Junio C HamanoDec 19, 2013
  14. Christian CouderDec 21, 2013
  15. Junio C HamanoDec 26, 2013
  16. Christian CouderDec 28, 2013
  17. 08/10 t6050: add tests for listing with --formatChristian Couder, Dec 11, 2013
  18. 09/10 builtin/replace: unset read_replace_refsChristian Couder, Dec 11, 2013
  19. 10/10 Documentation/git-replace: describe --format optionChristian Couder, Dec 11, 2013
  20. Junio C HamanoDec 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.