Skip to content

Commit

Permalink
sha1_name: Suggest commit:./file for path in subdir
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed Apr 3, 2011
1 parent 34df9ab commit e41d718
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions sha1_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,13 @@ static void diagnose_invalid_sha1_path(const char *prefix,
if (!get_tree_entry(tree_sha1, fullname,
sha1, &mode)) {
die("Path '%s' exists, but not '%s'.\n"
"Did you mean '%s:%s'?",
"Did you mean '%s:%s' aka '%s:./%s'?",
fullname,
filename,
object_name,
fullname);
fullname,
object_name,
filename);
}
die("Path '%s' does not exist in '%s'",
filename, object_name);
Expand Down Expand Up @@ -1065,9 +1067,10 @@ static void diagnose_invalid_index_path(int stage,
if (ce_namelen(ce) == fullnamelen &&
!memcmp(ce->name, fullname, fullnamelen))
die("Path '%s' is in the index, but not '%s'.\n"
"Did you mean ':%d:%s'?",
"Did you mean ':%d:%s' aka ':%d:./%s'?",
fullname, filename,
ce_stage(ce), fullname);
ce_stage(ce), fullname,
ce_stage(ce), filename);
}

if (!lstat(filename, &st))
Expand Down
2 changes: 1 addition & 1 deletion t/t1506-rev-parse-diagnosis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ exec </dev/null
test_did_you_mean ()
{
printf "fatal: Path '$2$3' $4, but not ${5:-'$3'}.\n" >expected &&
printf "Did you mean '$1:$2$3'?\n" >>expected &&
printf "Did you mean '$1:$2$3'${2:+ aka '$1:./$3'}?\n" >>expected &&
test_cmp expected error
}

Expand Down

0 comments on commit e41d718

Please sign in to comment.