| @@ -60,7 +60,8 @@ mod from_bytes { · 59 unmodified lines |
| 60 | let repo = repo("blob.prefix").unwrap(); | 60 | let repo = repo("blob.prefix").unwrap(); |
| 61 | assert_eq!( | 61 | assert_eq!( |
| 62 | parse_spec("dead", &repo).unwrap_err().to_string(), | 62 | parse_spec("dead", &repo).unwrap_err().to_string(), |
| 63 | "Found more than one object prefixed with dead\nThe ref partially named 'dead' could not be found" | 63 | "Found more than one object prefixed with dead\nThe ref partially named 'dead' could not be found", |
| | 64 | "our messages aren't yet as good for ambiguous objects as we don't provide additional information" |
| 64 | ); | 65 | ); |
| 65 | assert_eq!( | 66 | assert_eq!( |
| 66 | parse_spec("beef", &repo).unwrap_err().to_string(), | 67 | parse_spec("beef", &repo).unwrap_err().to_string(), |
| @@ -73,10 +74,21 @@ mod from_bytes { · 6 unmodified lines |
| 73 | assert_eq!( | 74 | assert_eq!( |
| 74 | parse_spec("bad0", &repo).unwrap_err().to_string(), | 75 | parse_spec("bad0", &repo).unwrap_err().to_string(), |
| 75 | "Found more than one object prefixed with bad0\nThe ref partially named 'bad0' could not be found", | 76 | "Found more than one object prefixed with bad0\nThe ref partially named 'bad0' could not be found", |
| 76 | "git is able to also detect that the object has an invalid type, but we are not because the type doesn't matter here" | 77 | "git is able to also detect that the object has an invalid type because it tries to provide additional context, we don't" |
| 77 | ); | 78 | ); |
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| | 81 | |
| | 82 | #[test] |
| | 83 | fn blob_and_tree_can_be_disambiguated_by_type_some_day() { |
| | 84 | let repo = repo("ambiguous_blob_and_tree").unwrap(); |
| | 85 | assert_eq!( |
| | 86 | parse_spec("0000000000", &repo).unwrap_err().to_string(), |
| | 87 | "Found more than one object prefixed with 0000000000\nThe ref partially named '0000000000' could not be found", |
| | 88 | concat!("in theory one could disambiguate with 0000000000^{{tree}} (which works in git) or 0000000000^{{blob}} which doesn't work for some reason.", |
| | 89 | "but to do that we would have to know the list of object candidates and a lot more logic which right now we don't.") |
| | 90 | ); |
| | 91 | } |
| 80 | } | 92 | } |
| 81 | | 93 | |
| 82 | #[test] | 94 | #[test] |
| @@ -98,13 +110,13 @@ mod from_bytes { · 15 unmodified lines |
| 98 | | 110 | |
| 99 | { | 111 | { |
| 100 | let repo = repo("blob.corrupt").unwrap(); | 112 | let repo = repo("blob.corrupt").unwrap(); |
| 101 | let spec = parse_spec("cafe", &repo).unwrap(); | 113 | let spec = parse_spec("cafea", &repo).unwrap(); |
| 102 | assert_eq!( | 114 | assert_eq!( |
| 103 | spec, | 115 | spec, |
| 104 | RevSpec::from_id(hex_to_id("cafea31147e840161a1860c50af999917ae1536b").attach(&repo)) | 116 | RevSpec::from_id(hex_to_id("cafea31147e840161a1860c50af999917ae1536b").attach(&repo)) |
| 105 | ); | 117 | ); |
| 106 | assert_eq!( | 118 | assert_eq!( |
| 107 | &format!("{:?}", parse_spec("cafe^{object}", &repo).unwrap_err())[..80], | 119 | &format!("{:?}", parse_spec("cafea^{object}", &repo).unwrap_err())[..80], |
| 108 | r#"FindObject(Find(Loose(DecompressFile { source: Inflate(DecompressError(General {"# | 120 | r#"FindObject(Find(Loose(DecompressFile { source: Inflate(DecompressError(General {"# |
| 109 | ); | 121 | ); |
| 110 | } | 122 | } |