Ensure that we can build without libgen.h
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v4 Latest4 patches 24 repliesIn review
- v34 patches 4 repliesSuperseded
- v24 patches 13 repliesSuperseded
Patches in v4 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | Refactor skipping DOS drive prefixescompat/ compat/ compat/ +2 more | +28 | 9 replies | |
| 2/4 | compat/basename: make basename() conform to POSIXcompat/ | +17 | 2 replies | |
| 3/4 | Provide a dirname() function when NO_LIBGEN_H=YesPleasecompat/ git-compat-util.h | +46 | 3 replies | |
| 4/4 | t0060: verify that basename() and dirname() work as expectedt/ test-path-utils.c | +169 | 7 replies |
Reviews trailers per patch
None of the 4 patches has a Reviewed-by or Acked-by.
| Patch | Ramsay Jones | Torsten Bögershausen |
|---|---|---|
| Series | Pointed-out-by | |
| 1/4 | ||
| 2/4 | ||
| 3/4 | ||
| 4/4 | Derived-from-code-by |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v4 0/4] Ensure that we can build without libgen.h
This mini series adds a fall-back for the dirname() function that we use e.g. in git-am. This is necessary because not all platforms have a working libgen.h.
While at it, we ensure that our basename() drop-in conforms to the POSIX specifications.
In addition to Eric's style improvement, v4 also fixes the signature of skip_dos_drive_prefix() in the non-Windows case.
Johannes Schindelin (4):
Refactor skipping DOS drive prefixes compat/basename: make basename() conform to POSIX Provide a dirname() function when NO_LIBGEN_H=YesPlease
t0060: verify that basename() and dirname() work as expected
compat/basename.c | 66 ++++++++++++++++++-- compat/mingw.c | 14 ++--- compat/mingw.h | 10 ++- git-compat-util.h | 10 +++ path.c | 14 ++--- t/t0060-path-utils.sh | 3 + test-path-utils.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 259 insertions(+), 24 deletions(-)
Interdiff vs v3:
diff --git a/compat/basename.c b/compat/basename.c index 0a2ed25..96bd953 100644
--- a/compat/basename.c
+++ b/compat/basename.c
@@ -29,20 +29,15 @@ char *gitbasename (char *path)
char *gitdirname(char *path)
{
+ static struct strbuf buf = STRBUF_INIT;
char *p = path, *slash = NULL, c;
int dos_drive_prefix;
if (!p)
return ".";
- if ((dos_drive_prefix = skip_dos_drive_prefix(&p)) && !*p) {
- static struct strbuf buf = STRBUF_INIT;
-
-dot:
- strbuf_reset(&buf);
- strbuf_addf(&buf, "%.*s.", dos_drive_prefix, path);
- return buf.buf;
- }
+ if ((dos_drive_prefix = skip_dos_drive_prefix(&p)) && !*p)
+ goto dot;
/*
* POSIX.1-2001 says dirname("/") should return "/", and dirname("//")
@@ -64,8 +59,13 @@ dot:
slash = tentative;
}
- if (!slash)
- goto dot;
- *slash = '\0';
- return path;
+ if (slash) {
+ *slash = '\0';
+ return path;
+ }
+
+dot:
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "%.*s.", dos_drive_prefix, path);
+ return buf.buf;
}
diff --git a/git-compat-util.h b/git-compat-util.h
index 94f311a..5f72f1c 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -338,7 +338,7 @@ static inline int git_has_dos_drive_prefix(const char *path)
#endif
#ifndef skip_dos_drive_prefix
-static inline int git_skip_dos_drive_prefix(const char **path) +static inline int git_skip_dos_drive_prefix(char **path)
{
return 0;
}
Signature · 1 line
2.6.3.windows.1.300.g1c25e49