Skip to content

Commit 4d09641

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 602ba37 commit 4d09641

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
@@ -875,15 +875,13 @@ static int would_lose_untracked(struct merge_options *opt, const char *path)
875875
static int was_dirty(struct merge_options *opt, const char *path)
876876
{
877877
struct cache_entry *ce;
878-
int dirty = 1;
879878

880879
if (opt->priv->call_depth || !was_tracked(opt, path))
881-
return !dirty;
880+
return 0;
882881

883882
ce = index_file_exists(opt->priv->unpack_opts.src_index,
884883
path, strlen(path), ignore_case);
885-
dirty = verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
886-
return dirty;
884+
return verify_uptodate(ce, &opt->priv->unpack_opts) != 0;
887885
}
888886

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

0 commit comments

Comments
 (0)