Junio C Hamano <[EMAIL PROTECTED]> writes:

>  - 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 <[EMAIL PROTECTED]>

cd /opt/packrat/playpen/public/in-place/git/git.junio/
# - 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]))
-               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))

Compilation finished at Mon Jul 11 16:12:36

To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to