MCPcopy Create free account
hub / github.com/git/git / chop_last_dir

Function chop_last_dir

remote.c:2910–2931  ·  view source on GitHub ↗

* Returns 1 if it was the last chop before ':'. */

Source from the content-addressed store, hash-verified

2908 * Returns 1 if it was the last chop before ':'.
2909 */
2910static int chop_last_dir(char **remoteurl, int is_relative)
2911{
2912 char *rfind = find_last_dir_sep(*remoteurl);
2913 if (rfind) {
2914 *rfind = '\0';
2915 return 0;
2916 }
2917
2918 rfind = strrchr(*remoteurl, ':');
2919 if (rfind) {
2920 *rfind = '\0';
2921 return 1;
2922 }
2923
2924 if (is_relative || !strcmp(".", *remoteurl))
2925 die(_("cannot strip one component off url '%s'"),
2926 *remoteurl);
2927
2928 free(*remoteurl);
2929 *remoteurl = xstrdup(".");
2930 return 0;
2931}
2932
2933char *relative_url(const char *remote_url, const char *url,
2934 const char *up_path)

Callers 1

relative_urlFunction · 0.85

Calls 2

xstrdupFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected