Skip to content

Commit

Permalink
print an error message for invalid path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dmpot authored and spearce committed Oct 12, 2008
1 parent 616ab43 commit 7e7abea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion builtin-update-index.c
Expand Up @@ -218,7 +218,7 @@ static int add_cacheinfo(unsigned int mode, const unsigned char *sha1,
struct cache_entry *ce;

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

len = strlen(path);
size = cache_entry_size(len);
Expand Down
6 changes: 4 additions & 2 deletions read-cache.c
Expand Up @@ -608,8 +608,10 @@ struct cache_entry *make_cache_entry(unsigned int mode,
int size, len;
struct cache_entry *ce;

if (!verify_path(path))
if (!verify_path(path)) {
error("Invalid path '%s'", path);
return NULL;
}

len = strlen(path);
size = cache_entry_size(len);
Expand Down Expand Up @@ -893,7 +895,7 @@ static int add_index_entry_with_check(struct index_state *istate, struct cache_e
if (!ok_to_add)
return -1;
if (!verify_path(ce->name))
return -1;
return error("Invalid path '%s'", ce->name);

if (!skip_df_check &&
check_file_directory_conflict(istate, ce, pos, ok_to_replace)) {
Expand Down

0 comments on commit 7e7abea

Please sign in to comment.