sha1_name: Suggest commit:./file for path in subdir
Currently, the "Did you mean..." message suggests "commit:fullpath" only. Extend this to show the more convenient "commit:./file" form also. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael J Gruber committed
Mar 31, 2011 at 11:17 UTC
e41d718c7df31c891b242bcf3a1cfea812308e40
2 files changed
+8
-5
sha1_name.c
+7
-4
@@ -1012,11 +1012,13 @@ static void diagnose_invalid_sha1_path(const char *prefix,
1012
if (!get_tree_entry(tree_sha1, fullname,
1013
sha1, &mode)) {
1014
die("Path '%s' exists, but not '%s'.\n"
1015
- "Did you mean '%s:%s'?",
1015
+ "Did you mean '%s:%s' aka '%s:./%s'?",
1016
fullname,
1017
filename,
1018
object_name,
1019
- fullname);
1019
+ fullname,
1020
+ object_name,
1021
+ filename);
1022
}
1023
die("Path '%s' does not exist in '%s'",
1024
filename, object_name);
@@ -1065,9 +1067,10 @@ static void diagnose_invalid_index_path(int stage,
1067
if (ce_namelen(ce) == fullnamelen &&
1068
!memcmp(ce->name, fullname, fullnamelen))
1069
die("Path '%s' is in the index, but not '%s'.\n"
1068
- "Did you mean ':%d:%s'?",
1070
+ "Did you mean ':%d:%s' aka ':%d:./%s'?",
1071
fullname, filename,
1070
- ce_stage(ce), fullname);
1072
+ ce_stage(ce), fullname,
1073
+ ce_stage(ce), filename);
1074
}
1075
1076
if (!lstat(filename, &st))
t/t1506-rev-parse-diagnosis.sh
+1
-1
@@ -9,7 +9,7 @@ exec </dev/null
9
test_did_you_mean ()
10
{
11
printf "fatal: Path '$2$3' $4, but not ${5:-'$3'}.\n" >expected &&
12
- printf "Did you mean '$1:$2$3'?\n" >>expected &&
12
+ printf "Did you mean '$1:$2$3'${2:+ aka '$1:./$3'}?\n" >>expected &&
13
test_cmp expected error
14
}
15