Skip to content

Commit 7e7abea

Browse files
dmpotspearce
authored andcommitted
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 <[email protected]> Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 616ab43 commit 7e7abea

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

builtin-update-index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
218218
struct cache_entry *ce;
219219

220220
if (!verify_path(path))
221-
return -1;
221+
return error("Invalid path '%s'", path);
222222

223223
len = strlen(path);
224224
size = cache_entry_size(len);

read-cache.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,10 @@ struct cache_entry *make_cache_entry(unsigned int mode,
608608
int size, len;
609609
struct cache_entry *ce;
610610

611-
if (!verify_path(path))
611+
if (!verify_path(path)) {
612+
error("Invalid path '%s'", path);
612613
return NULL;
614+
}
613615

614616
len = strlen(path);
615617
size = cache_entry_size(len);
@@ -893,7 +895,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
893895
if (!ok_to_add)
894896
return -1;
895897
if (!verify_path(ce->name))
896-
return -1;
898+
return error("Invalid path '%s'", ce->name);
897899

898900
if (!skip_df_check &&
899901
check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {

0 commit comments

Comments
 (0)