Skip to content

Commit e41d718

Browse files
Michael J Grubergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34df9ab commit e41d718

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

sha1_name.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,11 +1012,13 @@ static void diagnose_invalid_sha1_path(const char *prefix,
10121012
if (!get_tree_entry(tree_sha1, fullname,
10131013
sha1, &mode)) {
10141014
die("Path '%s' exists, but not '%s'.\n"
1015-
"Did you mean '%s:%s'?",
1015+
"Did you mean '%s:%s' aka '%s:./%s'?",
10161016
fullname,
10171017
filename,
10181018
object_name,
1019-
fullname);
1019+
fullname,
1020+
object_name,
1021+
filename);
10201022
}
10211023
die("Path '%s' does not exist in '%s'",
10221024
filename, object_name);
@@ -1065,9 +1067,10 @@ static void diagnose_invalid_index_path(int stage,
10651067
if (ce_namelen(ce) == fullnamelen &&
10661068
!memcmp(ce->name, fullname, fullnamelen))
10671069
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'?",
10691071
fullname, filename,
1070-
ce_stage(ce), fullname);
1072+
ce_stage(ce), fullname,
1073+
ce_stage(ce), filename);
10711074
}
10721075

10731076
if (!lstat(filename, &st))

t/t1506-rev-parse-diagnosis.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ exec </dev/null
99
test_did_you_mean ()
1010
{
1111
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 &&
1313
test_cmp expected error
1414
}
1515

0 commit comments

Comments
 (0)