Skip to content

Commit

Permalink
commit-tree: the command wants a tree and commits
Browse files Browse the repository at this point in the history
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Jul 9, 2012
1 parent da3ac0c commit 75f5ac0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions builtin/commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
if (argc < 2 || !strcmp(argv[1], "-h"))
usage(commit_tree_usage);

if (get_sha1(argv[1], tree_sha1))
die("Not a valid object name %s", argv[1]);
if (get_sha1_tree(argv[1], tree_sha1))
die("Not a valid tree object name %s", argv[1]);

for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "-p")) {
unsigned char sha1[20];
if (argc <= ++i)
usage(commit_tree_usage);
if (get_sha1(argv[i], sha1))
if (get_sha1_commit(argv[i], sha1))
die("Not a valid object name %s", argv[i]);
assert_sha1_type(sha1, OBJ_COMMIT);
new_parent(lookup_commit(sha1), &parents);
Expand Down Expand Up @@ -104,7 +104,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix)
continue;
}

if (get_sha1(arg, tree_sha1))
if (get_sha1_tree(arg, tree_sha1))
die("Not a valid object name %s", arg);
if (got_tree)
die("Cannot give more than one trees");
Expand Down
4 changes: 2 additions & 2 deletions t/t1512-rev-parse-disambiguation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ test_expect_success 'disambiguate blob' '
test_cmp a0blgqsjc actual
'

test_expect_failure 'disambiguate tree' '
test_expect_success 'disambiguate tree' '
commit=$(echo "d7xm" | git commit-tree 000000000) &&
test $(git rev-parse $commit^{tree}) = $(git rev-parse 0000000000cdc)
'
Expand All @@ -97,7 +97,7 @@ test_expect_success 'disambiguate commit-ish' '
git rev-parse --verify 000000000^0
'

test_expect_failure 'disambiguate commit' '
test_expect_success 'disambiguate commit' '
commit=$(echo "j9xqh" | git commit-tree 0000000000cdc -p 000000000) &&
test $(git rev-parse $commit^) = $(git rev-parse 0000000000e4f)
'
Expand Down

0 comments on commit 75f5ac0

Please sign in to comment.