Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
e7ec9de6
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,发现更多精彩内容 >>
提交
e7ec9de6
编写于
2月 07, 2010
作者:
J
Junio C Hamano
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'maint'
* maint: archive: simplify archive format guessing
上级
84249819
fe12d8e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
18 deletion
+26
-18
builtin-archive.c
builtin-archive.c
+16
-18
t/t5000-tar-tree.sh
t/t5000-tar-tree.sh
+10
-0
未找到文件。
builtin-archive.c
浏览文件 @
e7ec9de6
...
...
@@ -70,7 +70,7 @@ static const char *format_from_name(const char *filename)
return
NULL
;
ext
++
;
if
(
!
strcasecmp
(
ext
,
"zip"
))
return
"zip"
;
return
"
--format=
zip"
;
return
NULL
;
}
...
...
@@ -84,7 +84,7 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
const
char
*
exec
=
"git-upload-archive"
;
const
char
*
output
=
NULL
;
const
char
*
remote
=
NULL
;
const
char
*
format
=
NULL
;
const
char
*
format
_option
=
NULL
;
struct
option
local_opts
[]
=
{
OPT_STRING
(
'o'
,
"output"
,
&
output
,
"file"
,
"write the archive to this file"
),
...
...
@@ -92,33 +92,31 @@ int cmd_archive(int argc, const char **argv, const char *prefix)
"retrieve the archive from remote repository <repo>"
),
OPT_STRING
(
0
,
"exec"
,
&
exec
,
"cmd"
,
"path to the remote git-upload-archive command"
),
OPT_STRING
(
0
,
"format"
,
&
format
,
"fmt"
,
"archive format"
),
OPT_END
()
};
char
fmt_opt
[
32
];
argc
=
parse_options
(
argc
,
argv
,
prefix
,
local_opts
,
NULL
,
PARSE_OPT_KEEP_ALL
);
if
(
output
)
{
create_output_file
(
output
);
if
(
!
format
)
format
=
format_from_name
(
output
);
format_option
=
format_from_name
(
output
);
}
if
(
format
)
{
sprintf
(
fmt_opt
,
"--format=%s"
,
format
);
/*
* We have enough room in argv[] to muck it in place,
* because either --format and/or --output must have
* been given on the original command line if we get
* to this point, and parse_options() must have eaten
* it, i.e. we can add back one element to the array.
* But argv[] may contain "--"; we should make it the
* first option.
*/
/*
* We have enough room in argv[] to muck it in place, because
* --output must have been given on the original command line
* if we get to this point, and parse_options() must have eaten
* it, i.e. we can add back one element to the array.
*
* We add a fake --format option at the beginning, with the
* format inferred from our output filename. This way explicit
* --format options can override it, and the fake option is
* inserted before any "--" that might have been given.
*/
if
(
format_option
)
{
memmove
(
argv
+
2
,
argv
+
1
,
sizeof
(
*
argv
)
*
argc
);
argv
[
1
]
=
f
mt_opt
;
argv
[
1
]
=
f
ormat_option
;
argv
[
++
argc
]
=
NULL
;
}
...
...
t/t5000-tar-tree.sh
浏览文件 @
e7ec9de6
...
...
@@ -189,6 +189,16 @@ test_expect_success 'git archive --format=zip with --output' \
'git archive --format=zip --output=d2.zip HEAD &&
test_cmp d.zip d2.zip'
test_expect_success
'git archive with --output, inferring format'
'
git archive --output=d3.zip HEAD &&
test_cmp d.zip d3.zip
'
test_expect_success
'git archive with --output, override inferred format'
'
git archive --format=tar --output=d4.zip HEAD &&
test_cmp b.tar d4.zip
'
$UNZIP
-v
>
/dev/null 2>&1
if
[
$?
-eq
127
]
;
then
say
"Skipping ZIP tests, because unzip was not found"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录