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

[PATCH] bundle create: keep symbolic refs' names instead of resolving them

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 21, 2007, 16:53 UTC
Message-ID
<Pine.LNX.4.64.0711211652470.27959@racer.site>
In-Reply-To
<8aa486160711210815g5a1973c2see28a6263fc56030@mail.gmail.com>

When creating a bundle, symbolic refs used to be resolved to the non-symbolic refs they point to before being written to the list of contained refs. I.e. "git bundle create a1.bundle HEAD master" would show something like

388afe7881b33102fada216dd07806728773c011 refs/heads/master 388afe7881b33102fada216dd07806728773c011 refs/heads/master

Introduce a special handling so that the symbolic refs are listed with the names passed on the command line.

Noticed by Santi Béjar.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 bundle.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/bundle.c b/bundle.c
index e4d60cd..5e8242f 100644
--- a/bundle.c
+++ b/bundle.c
@@ -6,6 +6,7 @@
 #include "revision.h"
 #include "list-objects.h"
 #include "run-command.h"
+#include "refs.h"
 
 static const char bundle_signature[] = "# v2 git bundle\n";
 
@@ -231,12 +232,17 @@ int create_bundle(struct bundle_header *header, const char *path,
 	for (i = 0; i < revs.pending.nr; i++) {
 		struct object_array_entry *e = revs.pending.objects + i;
 		unsigned char sha1[20];
-		char *ref;
+		const char *ref;
+		int flag;
 
 		if (e->item->flags & UNINTERESTING)
 			continue;
-		if (dwim_ref(e->name, strlen(e->name), sha1, &ref) != 1)
+		ref = resolve_ref(e->name, sha1, 1, &flag);
+		if (!ref)
 			continue;
+		if (flag & REF_ISSYMREF)
+			ref = e->name;
+
 		/*
 		 * Make sure the refs we wrote out is correct; --max-count and
 		 * other limiting options could have prevented all the tips
@@ -249,7 +255,6 @@ int create_bundle(struct bundle_header *header, const char *path,
 		if (!(e->item->flags & SHOWN) && e->item->type == OBJ_COMMIT) {
 			warning("ref '%s' is excluded by the rev-list options",
 				e->name);
-			free(ref);
 			continue;
 		}
 		/*
@@ -280,7 +285,6 @@ int create_bundle(struct bundle_header *header, const char *path,
 				obj->flags |= SHOWN;
 				add_pending_object(&revs, obj, e->name);
 			}
-			free(ref);
 			continue;
 		}
 
@@ -289,7 +293,6 @@ int create_bundle(struct bundle_header *header, const char *path,
 		write_or_die(bundle_fd, " ", 1);
 		write_or_die(bundle_fd, ref, strlen(ref));
 		write_or_die(bundle_fd, "\n", 1);
-		free(ref);
 	}
 	if (!ref_count)
 		die ("Refusing to create empty bundle.");
-- 
1.5.3.6.1977.g54d30
Previous: Santi BéjarNext: Johannes Schindelin
Message 27 of 33 in “Wishlist for a bundle-only transport mode”
  1. Santi BéjarNov 21, 2007
  2. Jakub NarebskiNov 21, 2007
  3. Santi BéjarNov 21, 2007
  4. Johannes SchindelinNov 21, 2007
  5. Jakub NarebskiNov 21, 2007
  6. Johannes SchindelinNov 21, 2007
  7. Jakub NarebskiNov 21, 2007
  8. Johannes SchindelinNov 21, 2007
  9. Jakub NarebskiNov 21, 2007
  10. Santi BéjarNov 22, 2007
  11. Junio C HamanoNov 22, 2007
  12. Jakub NarebskiNov 23, 2007
  13. Junio C HamanoNov 23, 2007
  14. Jakub NarebskiNov 23, 2007
  15. Santi BéjarNov 23, 2007
  16. Johannes SchindelinNov 23, 2007
  17. Junio C HamanoNov 23, 2007
  18. Santi BéjarNov 23, 2007
  19. Junio C HamanoNov 23, 2007
  20. Santi BéjarNov 23, 2007
  21. Junio C HamanoNov 24, 2007
  22. Jakub NarebskiNov 23, 2007
  23. Johannes SchindelinNov 21, 2007
  24. Santi BéjarNov 21, 2007
  25. Johannes SchindelinNov 21, 2007
  26. Santi BéjarNov 21, 2007
  27. bundle create: keep symbolic refs' names instead of resolving themJohannes Schindelin, Nov 21, 2007
  28. Johannes SchindelinNov 22, 2007
  29. bundle create: keep symbolic refs' names instead of resolving themJohannes Schindelin, Nov 22, 2007
  30. Kristian HøgsbergNov 21, 2007
  31. Johannes SchindelinNov 21, 2007
  32. Jakub NarebskiNov 21, 2007
  33. Johannes SchindelinNov 21, 2007

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.