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

[PATCH 2/5] fast-export: do not refer to non-existing marks

From
Sverre Rabbelier <srabbelier@gmail.com>
Date
Jul 24, 2011, 14:21 UTC
Message-ID
<1311517282-24831-3-git-send-email-srabbelier@gmail.com>
In-Reply-To
<1311517282-24831-1-git-send-email-srabbelier@gmail.com>
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>

When calling `git fast-export a..a b` when a and b refer to the same commit, nothing would be exported, and an incorrect reset line would be printed for b ('from :0').

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
---
  We encountered this one while staring at the code and trying to
  figure out if our existing solution was sufficient.
 builtin/fast-export.c |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index becef85..92743c8 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -512,9 +512,20 @@ static void get_tags_and_duplicates(struct object_array *pending,
 	}
 }
 
+static void handle_reset(const char *name, struct object *object)
+{
+	int mark = get_object_mark(object);
+
+	if (mark)
+		printf("reset %s\nfrom :%d\n\n", name,
+		       get_object_mark(object));
+	else
+		printf("reset %s\nfrom %s\n\n", name,
+		       sha1_to_hex(object->sha1));
+}
+
 static void handle_tags_and_duplicates(struct string_list *extra_refs)
 {
-	struct commit *commit;
 	int i;
 
 	for (i = extra_refs->nr - 1; i >= 0; i--) {
@@ -526,9 +537,7 @@ static void handle_tags_and_duplicates(struct string_list *extra_refs)
 			break;
 		case OBJ_COMMIT:
 			/* create refs pointing to already seen commits */
-			commit = (struct commit *)object;
-			printf("reset %s\nfrom :%d\n\n", name,
-			       get_object_mark(&commit->object));
+			handle_reset(name, object);
 			show_progress();
 			break;
 		}
-- 
1.7.6.385.g91185.dirty
Previous: Sverre RabbelierNext: Sverre Rabbelier
Message 3 of 29 in “fast-export: prepare for remote helpers awesomeness”
  1. 0/5 fast-export: prepare for remote helpers awesomenessSverre Rabbelier, Jul 24, 2011
  2. 1/5 t9350: point out that refs are not updated correctlySverre Rabbelier, Jul 24, 2011
  3. 2/5 fast-export: do not refer to non-existing marksSverre Rabbelier, Jul 24, 2011
  4. 3/5 setup_revisions: remember whether a ref was positive or notSverre Rabbelier, Jul 24, 2011
  5. Junio C HamanoJul 24, 2011
  6. Junio C HamanoJul 24, 2011
  7. Sverre RabbelierAug 3, 2011
  8. Junio C HamanoAug 3, 2011
  9. Johannes SchindelinAug 8, 2011
  10. Junio C HamanoAug 8, 2011
  11. Sverre RabbelierAug 8, 2011
  12. Junio C HamanoAug 8, 2011
  13. Sverre RabbelierAug 8, 2011
  14. Junio C HamanoAug 8, 2011
  15. Sverre RabbelierAug 8, 2011
  16. Junio C HamanoAug 8, 2011
  17. Sverre RabbelierAug 8, 2011
  18. Junio C HamanoAug 8, 2011
  19. Sverre RabbelierAug 8, 2011
  20. Junio C HamanoAug 8, 2011
  21. Junio C HamanoAug 8, 2011
  22. Sverre RabbelierAug 8, 2011
  23. Junio C HamanoAug 8, 2011
  24. Sverre RabbelierAug 8, 2011
  25. Johannes SchindelinJul 26, 2011
  26. 4/5 fast-export: do not export negative refsSverre Rabbelier, Jul 24, 2011
  27. Junio C HamanoJul 24, 2011
  28. Johannes SchindelinJul 26, 2011
  29. 5/5 setup_revisions: remember whether a ref was positive or notSverre Rabbelier, Jul 24, 2011

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.