Skip to content

Commit

Permalink
merge-recursive: avoid confusing logic in was_dirty()
Browse files Browse the repository at this point in the history
It took this developer more than a moment to verify that was_dirty()
really returns 0 (i.e. "false") if the file was not even tracked. In
other words, the `dirty` variable that was initialized to 1 (i.e.
"true") and then negated to be returned was not helping readability.

The same holds for the final return: rather than assigning the value to
return to `dirty` and then *immediately* returning that, we can simplify
it to a single statement.
  • Loading branch information
dscho committed Sep 16, 2022
1 parent ed8c247 commit 5ff86c2
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,15 +864,13 @@ static int would_lose_untracked(struct merge_options *opt, const char *path)
static int was_dirty(struct merge_options *opt, const char *path)
{
struct cache_entry *ce;
int dirty = 1;

if (opt->priv->call_depth || !was_tracked(opt, path))
return !dirty;
return 0;

ce = index_file_exists(opt->priv->unpack_opts.src_index,
path, strlen(path), ignore_case);
dirty = verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
return dirty;
return verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
}

static int make_room_for_path(struct merge_options *opt, const char *path)
Expand Down

0 comments on commit 5ff86c2

Please sign in to comment.