Skip to content

Commit ef33eae

Browse files
committed
merge-recursive: avoid confusing logic in was_dirty()
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.
1 parent 13844b7 commit ef33eae

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

merge-recursive.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,15 +873,13 @@ static int would_lose_untracked(struct merge_options *opt, const char *path)
873873
static int was_dirty(struct merge_options *opt, const char *path)
874874
{
875875
struct cache_entry *ce;
876-
int dirty = 1;
877876

878877
if (opt->priv->call_depth || !was_tracked(opt, path))
879-
return !dirty;
878+
return 0;
880879

881880
ce = index_file_exists(opt->priv->unpack_opts.src_index,
882881
path, strlen(path), ignore_case);
883-
dirty = verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
884-
return dirty;
882+
return verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
885883
}
886884

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

0 commit comments

Comments
 (0)