Skip to content

Commit b0320ea

Browse files
sbeyergitster
authored andcommitted
git-reset: Let -q hush "locally modified" messages
"git reset -q" is advertised to "only report errors", but "locally modified" messages are still shown. They are not errors but diagnostics. Signed-off-by: Stephan Beyer <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 128de65 commit b0320ea

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

builtin-reset.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static void print_new_head_line(struct commit *commit)
8585
printf("\n");
8686
}
8787

88-
static int update_index_refresh(int fd, struct lock_file *index_lock)
88+
static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)
8989
{
9090
int result;
9191

@@ -96,7 +96,8 @@ static int update_index_refresh(int fd, struct lock_file *index_lock)
9696

9797
if (read_cache() < 0)
9898
return error("Could not read index");
99-
result = refresh_cache(REFRESH_SAY_CHANGED) ? 1 : 0;
99+
100+
result = refresh_cache(flags) ? 1 : 0;
100101
if (write_cache(fd, active_cache, active_nr) ||
101102
commit_locked_index(index_lock))
102103
return error ("Could not refresh index");
@@ -128,7 +129,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,
128129
}
129130

130131
static int read_from_tree(const char *prefix, const char **argv,
131-
unsigned char *tree_sha1)
132+
unsigned char *tree_sha1, int refresh_flags)
132133
{
133134
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
134135
int index_fd, index_was_discarded = 0;
@@ -152,7 +153,7 @@ static int read_from_tree(const char *prefix, const char **argv,
152153
if (!index_was_discarded)
153154
/* The index is still clobbered from do_diff_cache() */
154155
discard_cache();
155-
return update_index_refresh(index_fd, lock);
156+
return update_index_refresh(index_fd, lock, refresh_flags);
156157
}
157158

158159
static void prepend_reflog_action(const char *action, char *buf, size_t size)
@@ -246,7 +247,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
246247
else if (reset_type != NONE)
247248
die("Cannot do %s reset with paths.",
248249
reset_type_names[reset_type]);
249-
return read_from_tree(prefix, argv + i, sha1);
250+
return read_from_tree(prefix, argv + i, sha1,
251+
quiet ? REFRESH_QUIET : REFRESH_SAY_CHANGED);
250252
}
251253
if (reset_type == NONE)
252254
reset_type = MIXED; /* by default */
@@ -286,7 +288,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
286288
case SOFT: /* Nothing else to do. */
287289
break;
288290
case MIXED: /* Report what has not been updated. */
289-
update_index_refresh(0, NULL);
291+
update_index_refresh(0, NULL,
292+
quiet ? REFRESH_QUIET : REFRESH_SAY_CHANGED);
290293
break;
291294
}
292295

0 commit comments

Comments
 (0)