Skip to content

Commit

Permalink
git-mv: Remove dead code branch
Browse files Browse the repository at this point in the history
The path list builder had a branch for the case the source is not in index, but
this can happen only if the source was a directory. However, in that case we
have already expanded the list to the directory contents and set mode
to WORKING_DIRECTORY, which is tested earlier.

The patch removes the superfluous branch and adds an assert() instead. git-mv
testsuite still passes.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Petr Baudis authored and gitster committed Jul 27, 2008
1 parent a08c53a commit f6c52fe
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions builtin-mv.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,13 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
if (mode == WORKING_DIRECTORY)
continue;

if (cache_name_pos(src, strlen(src)) >= 0) {
string_list_insert(src, &deleted);

/* destination can be a directory with 1 file inside */
if (string_list_has_string(&overwritten, dst))
string_list_insert(dst, &changed);
else
string_list_insert(dst, &added);
} else
assert(cache_name_pos(src, strlen(src)) >= 0);

string_list_insert(src, &deleted);
/* destination can be a directory with 1 file inside */
if (string_list_has_string(&overwritten, dst))
string_list_insert(dst, &changed);
else
string_list_insert(dst, &added);
}

Expand Down

0 comments on commit f6c52fe

Please sign in to comment.