Skip to content

Commit ced7b82

Browse files
agericJunio C Hamano
authored andcommitted
ls-files: Give hints when errors happen.
Without this patch "git commit file.c file2.c" produces the not so stellar output: error: pathspec 'file.c' did not match any. error: pathspec 'file2.c' did not match any. With this patch, the output is changed to: error: pathspec 'file.c' did not match any file(s) known to git. error: pathspec 'file2.c' did not match any file(s) known to git. Did you forget to 'git add'? Signed-off-by: Andreas Ericsson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 67c08ce commit ced7b82

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

builtin-ls-files.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,14 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
487487
for (num = 0; pathspec[num]; num++) {
488488
if (ps_matched[num])
489489
continue;
490-
error("pathspec '%s' did not match any.",
490+
error("pathspec '%s' did not match any file(s) known to git.",
491491
pathspec[num] + prefix_offset);
492492
errors++;
493493
}
494+
495+
if (errors)
496+
fprintf(stderr, "Did you forget to 'git add'?\n");
497+
494498
return errors ? 1 : 0;
495499
}
496500

0 commit comments

Comments
 (0)