sha1_name.c: add support for disambiguating other types

This teaches the revision parser that in "$name:$path" (used for a
blob object name), "$name" must be a tree-ish.

There are many more places where we know what types of objects are
called for.  This patch adds support for "commit", "treeish", "tree",
and "blob", which could be used in the following contexts:

 - "git apply --build-fake-ancestor" reads the "index" lines from
   the patch; they must name blob objects (not even "blob-ish");

 - "git commit-tree" reads a tree object name (not "tree-ish"), and
   zero or more commit object names (not "committish");

 - "git reset $rev" wants a committish; "git reset $rev -- $path"
   wants a treeish.

They will come in later patches in the series.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2012-07-02 23:35:05 -07:00
parent d5f6b1d756
commit daba53aeaf
3 changed files with 76 additions and 5 deletions

View File

@@ -45,7 +45,7 @@ test_expect_success 'warn ambiguity when no candidate matches type hint' '
grep "short SHA1 000000000 is ambiguous" actual
'
test_expect_failure 'disambiguate tree-ish' '
test_expect_success 'disambiguate tree-ish' '
# feed tree-ish in an unambiguous way
git rev-parse --verify 0000000000cdc:a0blgqsjc &&