资源简介
linux下的git2.0.0
Git在Wikipedia上的定义:它是一个免费的、分布式的版本控制工具,或是一个强调了速度快的源代码管理工具。Git最初被Linus Torvalds开发出来用于管理Linux内核的开发。每一个Git的工作目录都是一个完全独立的代码库,并拥有完整的历史记录和版本追踪能力,不依赖 于网络和中心服务器。
代码片段和文件信息
#include “cache.h“
/*
* Do not use this for inspecting *tracked* content. When path is a
* symlink to a directory we do not want to say it is a directory when
* dealing with tracked content in the working tree.
*/
int is_directory(const char *path)
{
struct stat st;
return (!stat(path &st) && S_ISDIR(st.st_mode));
}
/* We allow “recursive“ symbolic links. Only within reason though. */
#define MAXDEPTH 5
/*
* Return the real path (i.e. absolute path with symlinks resolved
* and extra slashes removed) equivalent to the specified path. (If
* you want an absolute path but don‘t mind links use
* absolute_path().) The return value is a pointer to a static
* buffer.
*
* The input and all intermediate paths must be shorter than MAX_PATH.
* The directory part of path (i.e. everything up to the last
* dir_sep) must denote a valid existing directory but the last
* component need not exist. If die_on_error is set then die with an
* informative error message if there is a problem. Otherwise return
* NULL on errors (without generating any output).
*
* If path is our buffer then return path as it‘s already what the
* user wants.
*/
static const char *real_path_internal(const char *path int die_on_error)
{
static char bufs[2][PATH_MAX + 1] *buf = bufs[0] *next_buf = bufs[1];
char *retval = NULL;
/*
* If we have to temporarily chdir() store the original CWD
* here so that we can chdir() back to it at the end of the
* function:
*/
char cwd[1024] = ““;
int buf_index = 1;
int depth = MAXDEPTH;
char *last_elem = NULL;
struct stat st;
/* We‘ve already done it */
if (path == buf || path == next_buf)
return path;
if (!*path) {
if (die_on_error)
die(“The empty string is not a valid path“);
else
goto error_out;
}
if (strlcpy(buf path PATH_MAX) >= PATH_MAX) {
if (die_on_error)
die(“Too long path: %.*s“ 60 path);
else
goto error_out;
}
while (depth--) {
if (!is_directory(buf)) {
char *last_slash = find_last_dir_sep(buf);
if (last_slash) {
last_elem = xstrdup(last_slash + 1);
last_slash[1] = ‘\0‘;
} else {
last_elem = xstrdup(buf);
*buf = ‘\0‘;
}
}
if (*buf) {
if (!*cwd && !getcwd(cwd sizeof(cwd))) {
if (die_on_error)
die_errno(“Could not get current working directory“);
else
goto error_out;
}
if (chdir(buf)) {
if (die_on_error)
die_errno(“Could not switch to ‘%s‘“ buf);
else
goto error_out;
}
}
if (!getcwd(buf PATH_MAX)) {
if (die_on_error)
die_errno(“Could not get current working directory“);
else
goto error_out;
}
if (last_elem) {
size_t len = strlen(buf);
if (len + strlen(last_elem) + 2 > PATH_MAX) {
if (die_on_error)
die(“Too long path name: ‘%s/%s‘“
buf last_elem);
else
goto error_out;
}
if (len && !is_dir_sep(buf[len - 1]))
buf[len++] = ‘/‘;
strcpy(buf + len last_elem);
free(last_elem);
last_elem = NULL;
- 上一篇:华为 GTM900才模块资料大全
- 下一篇:测地距离—来自science杂志
相关资源
- 我们的linux上机作业 linux小游戏 炸弹
- linux下基于socket和curses的双人弹球游戏
- linux网络聊天室
- 使用RTMPdump(libRTMP)直播来自v4l2的摄
- Linux+man中文手册
- Linux典藏大系之Linux系统移植第2版
- 嵌入式系统设计与应用 基于ARM Cort
- linux_syscall_support.h_2016/12/20
- Linux中nginx安装相关资源包
- Linux驱动模块单独编译Makefile
- GetDataGraphDigitizer
- Linux 进程控制与进程互斥附实验报告
- linux下socket can 编程详解
- 嵌入式Linux驱动开发基础总结
- DES 纯c实现(des.c和des.h) 含pkcs1填充
- Linux基础教程.ppt
-
Jli
nk_Linux_V422.zip - Atollic_TrueSTUDIO_for_STM32_v9.0.1_20180420-1
- 安装linux后的mbr修复工具(含64位)
- 动手做一个迷你型Linux操作系统
- Linux安装weblogic12详细步骤
- ncompress-4.2.4-54.el6_2.1.x86_64.rpm
- MT7601(小度wifi360wifimiwif) staap linux驱
- 《嵌入式Linux系统开发标准教程》第
- 基于Linux LQL流量控制系统的研究与实
- linux c 使用openssl实现SHA1WithRSA实现,签
- USB8152linux系统驱动包
- jpeglib读取jpeg,转为bmp图,24真彩和灰
- 北大青鸟Linux培训教材(完全版)LS
- rkispcamera
评论
共有 条评论