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

Re: Bootstrapping into git, commit gripes at me

From
Junio C Hamano <junkio@cox.net>
Date
Jul 11, 2005, 23:15 UTC
Message-ID
<7v8y0dndd8.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<7vll4dndwu.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> writes:
Show 10 quoted lines
>
>  - git-commit-tree says check_valid("commit") and barfs.
>
> My current preference is to keep .git/refs/heads tag free.  At
> least, I do not think we should ever write non commits to
> .git/*_HEAD.
>
> What do you think?  An alternative would be to allow tags
> (recursively) pointing at a commit as a commit parent, but I do
> not think we would want to go that route.

Or, just dereferencing tags for commit parents in commit-tree would be fine as well.

------------ Dereference tags given as commit-tree -p parameters.

Marc Singer noticed that when he has a tag instead of a commit in his .git/HEAD (this happens after git checkout -f <tag>), git commit barfs. This patch makes commit-tree dereference tags like everybody else does.

Signed-off-by: Junio C Hamano <junkio@cox.net>
---

cd /opt/packrat/playpen/public/in-place/git/git.junio/ jit-diff # - master: [PATCH] git-cvsimport-script: add "import only" option # + (working tree)

diff --git a/commit-tree.c b/commit-tree.c
--- a/commit-tree.c
+++ b/commit-tree.c
@@ -8,6 +8,7 @@
 #include <pwd.h>
 #include <time.h>
 #include <ctype.h>
+#include "commit.h"
 
 #define BLOCKING (1ul << 14)
 
@@ -133,10 +134,14 @@ int main(int argc, char **argv)
 	check_valid(tree_sha1, "tree");
 	for (i = 2; i < argc; i += 2) {
 		char *a, *b;
+		struct commit *commit;
 		a = argv[i]; b = argv[i+1];
 		if (!b || strcmp(a, "-p") || get_sha1(b, parent_sha1[parents]))
 			usage(commit_tree_usage);
-		check_valid(parent_sha1[parents], "commit");
+		commit = lookup_commit_reference(parent_sha1[parents]);
+		if (!commit)
+			usage(commit_tree_usage);
+		memcpy(parent_sha1[parents], commit->object.sha1, 20);
 		if (new_parent(parents))
 			parents++;
 	}

Compilation finished at Mon Jul 11 16:12:36
Previous: Junio C HamanoNext: Linus Torvalds
Message 5 of 33 in “Bootstrapping into git, commit gripes at me”
  1. Marc SingerJul 8, 2005
  2. Linus TorvaldsJul 9, 2005
  3. Marc SingerJul 11, 2005
  4. Junio C HamanoJul 11, 2005
  5. Junio C HamanoJul 11, 2005
  6. Linus TorvaldsJul 12, 2005
  7. Linus TorvaldsJul 12, 2005
  8. Marc SingerJul 12, 2005
  9. Linus TorvaldsJul 12, 2005
  10. Linus TorvaldsJul 12, 2005
  11. Linus TorvaldsJul 12, 2005
  12. Marc SingerJul 12, 2005
  13. Linus TorvaldsJul 12, 2005
  14. Marc SingerJul 12, 2005
  15. Petr BaudisJul 12, 2005
  16. Junio C HamanoJul 12, 2005
  17. Matthias UrlichsJul 12, 2005
  18. Petr BaudisJul 24, 2005
  19. Junio C HamanoJul 24, 2005
  20. Linus TorvaldsJul 12, 2005
  21. Petr BaudisAug 12, 2005
  22. Junio C HamanoJul 12, 2005
  23. Linus TorvaldsJul 12, 2005
  24. Junio C HamanoJul 12, 2005
  25. Linus TorvaldsJul 12, 2005
  26. Marc SingerJul 12, 2005
  27. Daniel BarkalowJul 12, 2005
  28. Linus TorvaldsJul 11, 2005
  29. Marc SingerJul 9, 2005
  30. Matthias UrlichsJul 9, 2005
  31. Petr BaudisJul 10, 2005
  32. Marc SingerJul 9, 2005
  33. Junio C HamanoJul 9, 2005

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.