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>
Dmitry Potapov committed
Oct 11, 2008 at 20:39 UTC
7e7abea96b8140c592a46293f5e33aae0683c7ac
2 files changed
+5
-3
builtin-update-index.c
+1
-1
@@ -218,7 +218,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
218
struct cache_entry *ce;
219
220
if (!verify_path(path))
221
- return -1;
221
+ return error("Invalid path '%s'", path);
222
223
len = strlen(path);
224
size = cache_entry_size(len);
read-cache.c
+4
-2
@@ -608,8 +608,10 @@ struct cache_entry *make_cache_entry(unsigned int mode,
608
int size, len;
609
struct cache_entry *ce;
610
611
- if (!verify_path(path))
611
+ if (!verify_path(path)) {
612
+ error("Invalid path '%s'", path);
613
return NULL;
614
+ }
615
616
len = strlen(path);
617
size = cache_entry_size(len);
@@ -893,7 +895,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
895
if (!ok_to_add)
896
return -1;
897
if (!verify_path(ce->name))
896
- return -1;
898
+ return error("Invalid path '%s'", ce->name);
899
900
if (!skip_df_check &&
901
check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {