Skip to content

Commit afd2a1d

Browse files
calvin-wan-googlegitster
authored andcommitted
wrapper: reduce scope of remove_or_warn()
remove_or_warn() is only used by entry.c and apply.c, but it is currently declared and defined in wrapper.{h,c}, so it has a scope much greater than it needs. This needlessly large scope also causes wrapper.c to need to include object.h, when this file is largely unconcerned with Git objects. Move remove_or_warn() to entry.{h,c}. The file apply.c still has access to it, since it already includes entry.h for another reason. Signed-off-by: Calvin Wan <[email protected]> Signed-off-by: Jonathan Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d88e810 commit afd2a1d

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

entry.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,3 +581,8 @@ void unlink_entry(const struct cache_entry *ce, const char *super_prefix)
581581
return;
582582
schedule_dir_for_removal(ce->name, ce_namelen(ce));
583583
}
584+
585+
int remove_or_warn(unsigned int mode, const char *file)
586+
{
587+
return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file);
588+
}

entry.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,10 @@ int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st)
6262
void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
6363
struct stat *st);
6464

65+
/*
66+
* Calls the correct function out of {unlink,rmdir}_or_warn based on
67+
* the supplied file mode.
68+
*/
69+
int remove_or_warn(unsigned int mode, const char *path);
70+
6571
#endif /* ENTRY_H */

wrapper.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "abspath.h"
66
#include "config.h"
77
#include "gettext.h"
8-
#include "object.h"
98
#include "repository.h"
109
#include "strbuf.h"
1110
#include "trace2.h"
@@ -632,11 +631,6 @@ int rmdir_or_warn(const char *file)
632631
return warn_if_unremovable("rmdir", file, rmdir(file));
633632
}
634633

635-
int remove_or_warn(unsigned int mode, const char *file)
636-
{
637-
return S_ISGITLINK(mode) ? rmdir_or_warn(file) : unlink_or_warn(file);
638-
}
639-
640634
static int access_error_is_ok(int err, unsigned flag)
641635
{
642636
return (is_missing_file_error(err) ||

wrapper.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ int unlink_or_msg(const char *file, struct strbuf *err);
106106
* not exist.
107107
*/
108108
int rmdir_or_warn(const char *path);
109-
/*
110-
* Calls the correct function out of {unlink,rmdir}_or_warn based on
111-
* the supplied file mode.
112-
*/
113-
int remove_or_warn(unsigned int mode, const char *path);
114109

115110
/*
116111
* Call access(2), but warn for any error except "missing file"

0 commit comments

Comments
 (0)