Commit f9e377a
clone: factor out dir_exists() helper
Two parts of git-clone's setup logic check whether a
directory exists, and they both call stat directly with the
same scratch "struct stat" buffer. Let's pull that into a
helper, which has a few advantages:
- it makes the purpose of the stat calls more obvious
- it makes it clear that we don't care about the
information in "buf" remaining valid
- if we later decide to make the check more robust (e.g.,
complaining about non-directories), we can do it in one
place
Note that we could just use file_exists() for this, which
has identical code. But we specifically care about
directories, so this future-proofs us against that function
later getting more picky about seeing actual files.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 8486b84 commit f9e377a
1 file changed
+8
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
863 | 863 | | |
864 | 864 | | |
865 | 865 | | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
866 | 872 | | |
867 | 873 | | |
868 | 874 | | |
869 | | - | |
870 | 875 | | |
871 | 876 | | |
872 | 877 | | |
| |||
938 | 943 | | |
939 | 944 | | |
940 | 945 | | |
941 | | - | |
| 946 | + | |
942 | 947 | | |
943 | 948 | | |
944 | 949 | | |
| |||
949 | 954 | | |
950 | 955 | | |
951 | 956 | | |
952 | | - | |
| 957 | + | |
953 | 958 | | |
954 | 959 | | |
955 | 960 | | |
| |||
0 commit comments