| 79 | } |
| 80 | |
| 81 | static void builtin_diff_b_f(struct rev_info *revs, |
| 82 | int argc, const char **argv UNUSED, |
| 83 | struct object_array_entry **blob) |
| 84 | { |
| 85 | /* Blob vs file in the working tree*/ |
| 86 | struct stat st; |
| 87 | const char *path; |
| 88 | |
| 89 | if (argc > 1) |
| 90 | usage(builtin_diff_usage); |
| 91 | |
| 92 | GUARD_PATHSPEC(&revs->prune_data, PATHSPEC_FROMTOP | PATHSPEC_LITERAL); |
| 93 | path = revs->prune_data.items[0].match; |
| 94 | |
| 95 | if (lstat(path, &st)) |
| 96 | die_errno(_("failed to stat '%s'"), path); |
| 97 | if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))) |
| 98 | die(_("'%s': not a regular file or symlink"), path); |
| 99 | |
| 100 | diff_set_mnemonic_prefix(&revs->diffopt, "o/", "w/"); |
| 101 | |
| 102 | if (blob[0]->mode == S_IFINVALID) |
| 103 | blob[0]->mode = canon_mode(st.st_mode); |
| 104 | |
| 105 | stuff_change(&revs->diffopt, |
| 106 | blob[0]->mode, canon_mode(st.st_mode), |
| 107 | &blob[0]->item->oid, null_oid(the_hash_algo), |
| 108 | 1, 0, |
| 109 | blob[0]->path ? blob[0]->path : path, |
| 110 | path); |
| 111 | diffcore_std(&revs->diffopt); |
| 112 | diff_flush(&revs->diffopt); |
| 113 | } |
| 114 | |
| 115 | static void builtin_diff_blobs(struct rev_info *revs, |
| 116 | int argc, const char **argv UNUSED, |
no test coverage detected