I assume that your question is how bash can know to change the directory so that the working directory is foo (rather than foo/bar/..) in cd foo/bar/...
While these two paths will be are represented by the same inode (unless there are symlinks present in the path, as shown at the end of this answer), the shell does need to take special measures to show the current directory name as foo, rather than ... In bash, when cd encounters .. in the path, it internally just strips the parent directory away, meaning that .. can never be the directory name.
This is documented in help cd:
.. is processed by removing the immediately previous pathname component back to a slash or the beginning of DIR.
This special casing results in the following interesting behaviour (note that foo/qux/.. still resolved to foo, even when the real path was bar/baz/..):
$ tree
.
|-- bar
| `-- baz
`-- foo
3 directories, 0 files
$ ln -s "$(readlink -f bar/baz)" foo/qux
$ tree
.
|-- bar
| `-- baz
`-- foo
`-- qux -> bar/baz
4 directories, 0 files
$ cd foo/qux/..
$ basename "$(pwd)"
foo