Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
278ce746
Commit
278ce746
authored
Jul 01, 2013
by
Russell Belfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add helpful buffer shorten function
parent
c61300ed
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
2 deletions
+12
-2
src/buffer.c
+9
-0
src/buffer.h
+1
-0
src/config_file.c
+1
-1
src/indexer.c
+1
-1
No files found.
src/buffer.c
View file @
278ce746
...
@@ -259,6 +259,15 @@ void git_buf_truncate(git_buf *buf, size_t len)
...
@@ -259,6 +259,15 @@ void git_buf_truncate(git_buf *buf, size_t len)
}
}
}
}
void
git_buf_shorten
(
git_buf
*
buf
,
size_t
amount
)
{
if
(
amount
>
buf
->
size
)
amount
=
buf
->
size
;
buf
->
size
=
buf
->
size
-
amount
;
buf
->
ptr
[
buf
->
size
]
=
'\0'
;
}
void
git_buf_rtruncate_at_char
(
git_buf
*
buf
,
char
separator
)
void
git_buf_rtruncate_at_char
(
git_buf
*
buf
,
char
separator
)
{
{
ssize_t
idx
=
git_buf_rfind_next
(
buf
,
separator
);
ssize_t
idx
=
git_buf_rfind_next
(
buf
,
separator
);
...
...
src/buffer.h
View file @
278ce746
...
@@ -91,6 +91,7 @@ int git_buf_vprintf(git_buf *buf, const char *format, va_list ap);
...
@@ -91,6 +91,7 @@ int git_buf_vprintf(git_buf *buf, const char *format, va_list ap);
void
git_buf_clear
(
git_buf
*
buf
);
void
git_buf_clear
(
git_buf
*
buf
);
void
git_buf_consume
(
git_buf
*
buf
,
const
char
*
end
);
void
git_buf_consume
(
git_buf
*
buf
,
const
char
*
end
);
void
git_buf_truncate
(
git_buf
*
buf
,
size_t
len
);
void
git_buf_truncate
(
git_buf
*
buf
,
size_t
len
);
void
git_buf_shorten
(
git_buf
*
buf
,
size_t
amount
);
void
git_buf_rtruncate_at_char
(
git_buf
*
path
,
char
separator
);
void
git_buf_rtruncate_at_char
(
git_buf
*
path
,
char
separator
);
int
git_buf_join_n
(
git_buf
*
buf
,
char
separator
,
int
nbuf
,
...);
int
git_buf_join_n
(
git_buf
*
buf
,
char
separator
,
int
nbuf
,
...);
...
...
src/config_file.c
View file @
278ce746
...
@@ -1395,7 +1395,7 @@ static int parse_multiline_variable(diskfile_backend *cfg, git_buf *value, int i
...
@@ -1395,7 +1395,7 @@ static int parse_multiline_variable(diskfile_backend *cfg, git_buf *value, int i
* standard, this character **has** to be last one in the buf, with
* standard, this character **has** to be last one in the buf, with
* no whitespace after it */
* no whitespace after it */
assert
(
is_multiline_var
(
value
->
ptr
));
assert
(
is_multiline_var
(
value
->
ptr
));
git_buf_
truncate
(
value
,
git_buf_len
(
value
)
-
1
);
git_buf_
shorten
(
value
,
1
);
proc_line
=
fixup_line
(
line
,
in_quotes
);
proc_line
=
fixup_line
(
line
,
in_quotes
);
if
(
proc_line
==
NULL
)
{
if
(
proc_line
==
NULL
)
{
...
...
src/indexer.c
View file @
278ce746
...
@@ -602,7 +602,7 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *
...
@@ -602,7 +602,7 @@ int git_indexer_stream_finalize(git_indexer_stream *idx, git_transfer_progress *
git_vector_sort
(
&
idx
->
objects
);
git_vector_sort
(
&
idx
->
objects
);
git_buf_sets
(
&
filename
,
idx
->
pack
->
pack_name
);
git_buf_sets
(
&
filename
,
idx
->
pack
->
pack_name
);
git_buf_
truncate
(
&
filename
,
filename
.
size
-
strlen
(
"pack"
));
git_buf_
shorten
(
&
filename
,
strlen
(
"pack"
));
git_buf_puts
(
&
filename
,
"idx"
);
git_buf_puts
(
&
filename
,
"idx"
);
if
(
git_buf_oom
(
&
filename
))
if
(
git_buf_oom
(
&
filename
))
return
-
1
;
return
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment