We don't have make multiple filesystem calls: it may be better to store the list of directories in an array and work with that. Maybe try something like this?

```
cd "$git_dir"
for d in "${dirs[@]}"; do
  if [[ "$d" == "$git_dir/rebase-apply/applying" ]]; then
    #do your business
  fi
  #etc
done
```