Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
1af0d112
G
git
项目概览
李少辉-开发者
/
git
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
git
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1af0d112
编写于
5月 23, 2006
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'jc/tartree' into jc/builtin-n-tar-tree
* jc/tartree: built-in tar-tree and remote tar-tree
上级
e8cc9cd9
21754264
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
143 addition
and
8 deletion
+143
-8
Makefile
Makefile
+6
-4
builtin-tar-tree.c
builtin-tar-tree.c
+59
-2
builtin-upload-tar.c
builtin-upload-tar.c
+74
-0
builtin.h
builtin.h
+2
-2
git.c
git.c
+2
-0
未找到文件。
Makefile
浏览文件 @
1af0d112
...
...
@@ -170,9 +170,10 @@ BUILT_INS = git-log$X git-whatchanged$X git-show$X \
git-count-objects
$X
git-diff
$X
git-push
$X
\
git-grep
$X
git-rev-list
$X
git-check-ref-format
$X
\
git-init-db
$X
git-ls-files
$X
git-ls-tree
$X
\
git-
tar-tree
$X
git-
read-tree
$X
git-commit-tree
$X
\
git-read-tree
$X
git-commit-tree
$X
\
git-apply
$X
git-show-branch
$X
git-diff-files
$X
\
git-diff-index
$X
git-diff-stages
$X
git-diff-tree
$X
git-diff-index
$X
git-diff-stages
$X
git-diff-tree
$X
\
git-tar-tree
$X
git-upload-tar
$X
# what 'all' will build and 'install' will install, in gitexecdir
ALL_PROGRAMS
=
$(PROGRAMS)
$(SIMPLE_PROGRAMS)
$(SCRIPTS)
...
...
@@ -222,9 +223,10 @@ BUILTIN_OBJS = \
builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o
\
builtin-grep.o builtin-rev-list.o builtin-check-ref-format.o
\
builtin-init-db.o builtin-ls-files.o builtin-ls-tree.o
\
builtin-
tar-tree.o builtin-
read-tree.o builtin-commit-tree.o
\
builtin-read-tree.o builtin-commit-tree.o
\
builtin-apply.o builtin-show-branch.o builtin-diff-files.o
\
builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o
builtin-diff-index.o builtin-diff-stages.o builtin-diff-tree.o
\
builtin-tar-tree.o builtin-upload-tar.o
GITLIBS
=
$(LIB_FILE)
$(XDIFF_LIB)
LIBS
=
$(GITLIBS)
-lz
...
...
builtin-tar-tree.c
浏览文件 @
1af0d112
...
...
@@ -8,11 +8,13 @@
#include "strbuf.h"
#include "tar.h"
#include "builtin.h"
#include "pkt-line.h"
#define RECORDSIZE (512)
#define BLOCKSIZE (RECORDSIZE * 20)
static
const
char
tar_tree_usage
[]
=
"git-tar-tree <key> [basedir]"
;
static
const
char
tar_tree_usage
[]
=
"git-tar-tree [--remote=<repo>] <ent> [basedir]"
;
static
char
block
[
BLOCKSIZE
];
static
unsigned
long
offset
;
...
...
@@ -302,7 +304,7 @@ static void traverse_tree(struct tree_desc *tree, struct strbuf *path)
}
}
int
cmd_tar_tree
(
int
argc
,
const
char
**
argv
,
char
**
envp
)
static
int
generate_tar
(
int
argc
,
const
char
**
argv
,
char
**
envp
)
{
unsigned
char
sha1
[
20
],
tree_sha1
[
20
];
struct
commit
*
commit
;
...
...
@@ -349,3 +351,58 @@ int cmd_tar_tree(int argc, const char **argv, char** envp)
free
(
current_path
.
buf
);
return
0
;
}
static
const
char
*
exec
=
"git-upload-tar"
;
static
int
remote_tar
(
int
argc
,
const
char
**
argv
)
{
int
fd
[
2
],
ret
,
len
;
pid_t
pid
;
char
buf
[
1024
];
char
*
url
;
if
(
argc
<
3
||
4
<
argc
)
usage
(
tar_tree_usage
);
/* --remote=<repo> */
url
=
strdup
(
argv
[
1
]
+
9
);
pid
=
git_connect
(
fd
,
url
,
exec
);
if
(
pid
<
0
)
return
1
;
packet_write
(
fd
[
1
],
"want %s
\n
"
,
argv
[
2
]);
if
(
argv
[
3
])
packet_write
(
fd
[
1
],
"base %s
\n
"
,
argv
[
3
]);
packet_flush
(
fd
[
1
]);
len
=
packet_read_line
(
fd
[
0
],
buf
,
sizeof
(
buf
));
if
(
!
len
)
die
(
"git-tar-tree: expected ACK/NAK, got EOF"
);
if
(
buf
[
len
-
1
]
==
'\n'
)
buf
[
--
len
]
=
0
;
if
(
strcmp
(
buf
,
"ACK"
))
{
if
(
5
<
len
&&
!
strncmp
(
buf
,
"NACK "
,
5
))
die
(
"git-tar-tree: NACK %s"
,
buf
+
5
);
die
(
"git-tar-tree: protocol error"
);
}
/* expect a flush */
len
=
packet_read_line
(
fd
[
0
],
buf
,
sizeof
(
buf
));
if
(
len
)
die
(
"git-tar-tree: expected a flush"
);
/* Now, start reading from fd[0] and spit it out to stdout */
ret
=
copy_fd
(
fd
[
0
],
1
);
close
(
fd
[
0
]);
ret
|=
finish_connect
(
pid
);
return
!!
ret
;
}
int
cmd_tar_tree
(
int
argc
,
const
char
**
argv
,
char
**
envp
)
{
if
(
argc
<
2
)
usage
(
tar_tree_usage
);
if
(
!
strncmp
(
"--remote="
,
argv
[
1
],
9
))
return
remote_tar
(
argc
,
argv
);
return
generate_tar
(
argc
,
argv
,
envp
);
}
builtin-upload-tar.c
0 → 100644
浏览文件 @
1af0d112
/*
* Copyright (c) 2006 Junio C Hamano
*/
#include "cache.h"
#include "pkt-line.h"
#include "exec_cmd.h"
#include "builtin.h"
static
const
char
upload_tar_usage
[]
=
"git-upload-tar <repo>"
;
static
int
nak
(
const
char
*
reason
)
{
packet_write
(
1
,
"NACK %s
\n
"
,
reason
);
packet_flush
(
1
);
return
1
;
}
int
cmd_upload_tar
(
int
argc
,
const
char
**
argv
,
char
**
envp
)
{
int
len
;
const
char
*
dir
=
argv
[
1
];
char
buf
[
8192
];
unsigned
char
sha1
[
20
];
char
*
base
=
NULL
;
char
hex
[
41
];
int
ac
;
const
char
*
av
[
4
];
if
(
argc
!=
2
)
usage
(
upload_tar_usage
);
if
(
strlen
(
dir
)
<
sizeof
(
buf
)
-
1
)
strcpy
(
buf
,
dir
);
/* enter-repo smudges its argument */
else
packet_write
(
1
,
"NACK insanely long repository name %s
\n
"
,
dir
);
if
(
!
enter_repo
(
buf
,
0
))
{
packet_write
(
1
,
"NACK not a git archive %s
\n
"
,
dir
);
packet_flush
(
1
);
return
1
;
}
len
=
packet_read_line
(
0
,
buf
,
sizeof
(
buf
));
if
(
len
<
5
||
strncmp
(
"want "
,
buf
,
5
))
return
nak
(
"expected want"
);
if
(
buf
[
len
-
1
]
==
'\n'
)
buf
[
--
len
]
=
0
;
if
(
get_sha1
(
buf
+
5
,
sha1
))
return
nak
(
"expected sha1"
);
strcpy
(
hex
,
sha1_to_hex
(
sha1
));
len
=
packet_read_line
(
0
,
buf
,
sizeof
(
buf
));
if
(
len
)
{
if
(
len
<
5
||
strncmp
(
"base "
,
buf
,
5
))
return
nak
(
"expected (optional) base"
);
if
(
buf
[
len
-
1
]
==
'\n'
)
buf
[
--
len
]
=
0
;
base
=
strdup
(
buf
+
5
);
len
=
packet_read_line
(
0
,
buf
,
sizeof
(
buf
));
}
if
(
len
)
return
nak
(
"expected flush"
);
packet_write
(
1
,
"ACK
\n
"
);
packet_flush
(
1
);
ac
=
0
;
av
[
ac
++
]
=
"tar-tree"
;
av
[
ac
++
]
=
hex
;
if
(
base
)
av
[
ac
++
]
=
base
;
av
[
ac
++
]
=
NULL
;
execv_git_cmd
(
av
);
/* should it return that is an error */
return
1
;
}
builtin.h
浏览文件 @
1af0d112
...
...
@@ -27,9 +27,10 @@ extern int cmd_grep(int argc, const char **argv, char **envp);
extern
int
cmd_rev_list
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_check_ref_format
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_init_db
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_tar_tree
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_upload_tar
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_ls_files
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_ls_tree
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_tar_tree
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_read_tree
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_commit_tree
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_apply
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
...
...
@@ -39,5 +40,4 @@ extern int cmd_diff_index(int argc, const char **argv, char **envp);
extern
int
cmd_diff_stages
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
extern
int
cmd_diff_tree
(
int
argc
,
const
char
**
argv
,
char
**
envp
);
#endif
git.c
浏览文件 @
1af0d112
...
...
@@ -52,6 +52,8 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
{
"grep"
,
cmd_grep
},
{
"rev-list"
,
cmd_rev_list
},
{
"init-db"
,
cmd_init_db
},
{
"tar-tree"
,
cmd_tar_tree
},
{
"upload-tar"
,
cmd_upload_tar
},
{
"check-ref-format"
,
cmd_check_ref_format
},
{
"ls-files"
,
cmd_ls_files
},
{
"ls-tree"
,
cmd_ls_tree
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录