[PATCH] Silent flag for show-diff
This patch adds a -s flag for show-diff, which will surpress the actual diffing. This is useful for my scripts when they just want to see what needs to be updated in the cache. Signed-off-by: Petr Baudis <pasky@ucw.cz>maint
parent
3d8c7a5790
commit
e2e5e98a40
14
show-diff.c
14
show-diff.c
|
@ -57,9 +57,18 @@ static void show_diff_empty(struct cache_entry *ce)
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
int silent = 0;
|
||||||
int entries = read_cache();
|
int entries = read_cache();
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
while (argc-- > 1) {
|
||||||
|
if (!strcmp(argv[1], "-s")) {
|
||||||
|
silent = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
usage("show-diff [-s]");
|
||||||
|
}
|
||||||
|
|
||||||
if (entries < 0) {
|
if (entries < 0) {
|
||||||
perror("read_cache");
|
perror("read_cache");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -74,7 +83,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
if (stat(ce->name, &st) < 0) {
|
if (stat(ce->name, &st) < 0) {
|
||||||
printf("%s: %s\n", ce->name, strerror(errno));
|
printf("%s: %s\n", ce->name, strerror(errno));
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT && !silent)
|
||||||
show_diff_empty(ce);
|
show_diff_empty(ce);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -86,6 +95,9 @@ int main(int argc, char **argv)
|
||||||
printf("%02x", ce->sha1[n]);
|
printf("%02x", ce->sha1[n]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
if (silent)
|
||||||
|
continue;
|
||||||
|
|
||||||
new = read_sha1_file(ce->sha1, type, &size);
|
new = read_sha1_file(ce->sha1, type, &size);
|
||||||
show_differences(ce->name, new, size);
|
show_differences(ce->name, new, size);
|
||||||
free(new);
|
free(new);
|
Loading…
Reference in New Issue