Git fork

print an error message for invalid path

If verification of path failed, it is always better to print an
error message saying this than relying on the caller function to
print a meaningful error message (especially when the callee already
prints error message for another situation).

Because the callers of add_index_entry_with_check() did not print
any error message, it resulted that the user would not notice the
problem when checkout of an invalid path failed.

Signed-off-by: Dmitry Potapov <dpotapov@gmail.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

authored by

Dmitry Potapov and committed by
Shawn O. Pearce
7e7abea9 616ab437

+5 -3
+1 -1
builtin-update-index.c
··· 218 218 struct cache_entry *ce; 219 219 220 220 if (!verify_path(path)) 221 - return -1; 221 + return error("Invalid path '%s'", path); 222 222 223 223 len = strlen(path); 224 224 size = cache_entry_size(len);
+4 -2
read-cache.c
··· 608 608 int size, len; 609 609 struct cache_entry *ce; 610 610 611 - if (!verify_path(path)) 611 + if (!verify_path(path)) { 612 + error("Invalid path '%s'", path); 612 613 return NULL; 614 + } 613 615 614 616 len = strlen(path); 615 617 size = cache_entry_size(len); ··· 893 895 if (!ok_to_add) 894 896 return -1; 895 897 if (!verify_path(ce->name)) 896 - return -1; 898 + return error("Invalid path '%s'", ce->name); 897 899 898 900 if (!skip_df_check && 899 901 check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {