Re: [PATCH] reset: trivial refactoring
- From
Martin von Zweigbergk <martinvonz@gmail.com>
- Date
- Jun 13, 2013, 21:13 UTC
- Message-ID
- <CANiSa6i5xL-V+W46zWXGzLc+dSO6a+V0BLPt7hFgGZGXpp03BQ@mail.gmail.com>
- In-Reply-To
- <1371147305-20771-1-git-send-email-felipe.contreras@gmail.com>
On Thu, Jun 13, 2013 at 11:15 AM, Felipe Contreras <felipe.contreras@gmail.com> wrote:
Show 6 quoted lines
> @@ -82,7 +82,7 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
> if (unpack_trees(nr, desc, &opts))
> return -1;
>
> - if (reset_type == MIXED || reset_type == HARD) {
> + if (reset_type == HARD) {Are you sure that this can not be reached given that...
Show 12 quoted lines
> @@ -323,8 +323,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
> struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
> int newfd = hold_locked_index(lock, 1);
> if (reset_type == MIXED) {
> + int flags = quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN;
> if (read_from_tree(pathspec, sha1))
> return 1;
> + refresh_index(&the_index, flags, NULL, NULL,
> + _("Unstaged changes after reset:"));
> } else {
> int err = reset_index(sha1, reset_type, quiet);
> if (reset_type == KEEP && !err)...the line after this one reads
err = reset_index(sha1, MIXED, quiet);
? I don't know what the consequence of not calling prime_cache_tree() would be, though.
The merging of the two if blocks looks good. Thanks.