Skip to content

Commit c1acf1a

Browse files
pks-tgitster
authored andcommitted
object-file: rename variables in check_collision()
Rename variables used in `check_collision()` to clearly identify which file is the source and which is the destination. This will make the next step easier to reason about when we start to treat those files different from one another. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 0ad3d65 commit c1acf1a

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

object-file.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,56 +1974,56 @@ static void write_object_file_prepare_literally(const struct git_hash_algo *algo
19741974
hash_object_body(algo, &c, buf, len, oid, hdr, hdrlen);
19751975
}
19761976

1977-
static int check_collision(const char *filename_a, const char *filename_b)
1977+
static int check_collision(const char *source, const char *dest)
19781978
{
1979-
char buf_a[4096], buf_b[4096];
1980-
int fd_a = -1, fd_b = -1;
1979+
char buf_source[4096], buf_dest[4096];
1980+
int fd_source = -1, fd_dest = -1;
19811981
int ret = 0;
19821982

1983-
fd_a = open(filename_a, O_RDONLY);
1984-
if (fd_a < 0) {
1983+
fd_source = open(source, O_RDONLY);
1984+
if (fd_source < 0) {
19851985
if (errno != ENOENT)
1986-
ret = error_errno(_("unable to open %s"), filename_a);
1986+
ret = error_errno(_("unable to open %s"), source);
19871987
goto out;
19881988
}
19891989

1990-
fd_b = open(filename_b, O_RDONLY);
1991-
if (fd_b < 0) {
1990+
fd_dest = open(dest, O_RDONLY);
1991+
if (fd_dest < 0) {
19921992
if (errno != ENOENT)
1993-
ret = error_errno(_("unable to open %s"), filename_b);
1993+
ret = error_errno(_("unable to open %s"), dest);
19941994
goto out;
19951995
}
19961996

19971997
while (1) {
19981998
ssize_t sz_a, sz_b;
19991999

2000-
sz_a = read_in_full(fd_a, buf_a, sizeof(buf_a));
2000+
sz_a = read_in_full(fd_source, buf_source, sizeof(buf_source));
20012001
if (sz_a < 0) {
2002-
ret = error_errno(_("unable to read %s"), filename_a);
2002+
ret = error_errno(_("unable to read %s"), source);
20032003
goto out;
20042004
}
20052005

2006-
sz_b = read_in_full(fd_b, buf_b, sizeof(buf_b));
2006+
sz_b = read_in_full(fd_dest, buf_dest, sizeof(buf_dest));
20072007
if (sz_b < 0) {
2008-
ret = error_errno(_("unable to read %s"), filename_b);
2008+
ret = error_errno(_("unable to read %s"), dest);
20092009
goto out;
20102010
}
20112011

2012-
if (sz_a != sz_b || memcmp(buf_a, buf_b, sz_a)) {
2012+
if (sz_a != sz_b || memcmp(buf_source, buf_dest, sz_a)) {
20132013
ret = error(_("files '%s' and '%s' differ in contents"),
2014-
filename_a, filename_b);
2014+
source, dest);
20152015
goto out;
20162016
}
20172017

2018-
if (sz_a < sizeof(buf_a))
2018+
if (sz_a < sizeof(buf_source))
20192019
break;
20202020
}
20212021

20222022
out:
2023-
if (fd_a > -1)
2024-
close(fd_a);
2025-
if (fd_b > -1)
2026-
close(fd_b);
2023+
if (fd_source > -1)
2024+
close(fd_source);
2025+
if (fd_dest > -1)
2026+
close(fd_dest);
20272027
return ret;
20282028
}
20292029

0 commit comments

Comments
 (0)