Skip to content

Commit 974f0d4

Browse files
pks-tgitster
authored andcommitted
builtin/mv: convert assert(3p) into BUG()
The use of asserts is discouraged in our codebase because they lead to different behaviour depending on how Git is built. When being unsure enough whether a condition always holds so that one adds the assert, then the assert should probably trigger regardless of how Git is being built. Drop the call to assert(3p) in git-mv(1) and instead use `BUG()`. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8583c9d commit 974f0d4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin/mv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ int cmd_mv(int argc,
560560
continue;
561561

562562
pos = index_name_pos(the_repository->index, src, strlen(src));
563-
assert(pos >= 0);
563+
if (pos < 0)
564+
BUG("could not find source in index: '%s'", src);
564565
if (!(mode & SPARSE) && !lstat(src, &st))
565566
sparse_and_dirty = ie_modified(the_repository->index,
566567
the_repository->index->cache[pos],

0 commit comments

Comments
 (0)