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
28481609
Commit
28481609
authored
Oct 18, 2019
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stash: refactor code that prepares commit messages
parent
ca2d34a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
+15
-18
src/stash.c
+15
-18
No files found.
src/stash.c
View file @
28481609
...
...
@@ -437,36 +437,33 @@ cleanup:
return
error
;
}
static
int
prepare_worktree_commit_message
(
git_buf
*
msg
,
const
char
*
user_message
)
static
int
prepare_worktree_commit_message
(
git_buf
*
out
,
const
char
*
user_message
)
{
git_buf
buf
=
GIT_BUF_INIT
;
int
error
;
if
((
error
=
git_buf_set
(
&
buf
,
git_buf_cstr
(
msg
),
git_buf_len
(
msg
)))
<
0
)
return
error
;
git_buf_clear
(
msg
);
int
error
=
0
;
if
(
!
user_message
)
git_buf_printf
(
msg
,
"WIP on %s"
,
git_buf_cstr
(
&
buf
));
else
{
if
(
!
user_message
)
{
git_buf_printf
(
&
buf
,
"WIP on %s"
,
git_buf_cstr
(
out
));
}
else
{
const
char
*
colon
;
if
((
colon
=
strchr
(
git_buf_cstr
(
&
buf
),
':'
))
==
NULL
)
if
((
colon
=
strchr
(
git_buf_cstr
(
out
),
':'
))
==
NULL
)
goto
cleanup
;
git_buf_puts
(
msg
,
"On "
);
git_buf_put
(
msg
,
git_buf_cstr
(
&
buf
),
colon
-
buf
.
ptr
);
git_buf_printf
(
msg
,
": %s
\n
"
,
user_message
);
git_buf_puts
(
&
buf
,
"On "
);
git_buf_put
(
&
buf
,
git_buf_cstr
(
out
),
colon
-
out
->
ptr
);
git_buf_printf
(
&
buf
,
": %s
\n
"
,
user_message
);
}
error
=
(
git_buf_oom
(
msg
)
||
git_buf_oom
(
&
buf
))
?
-
1
:
0
;
if
(
git_buf_oom
(
&
buf
))
{
error
=
-
1
;
goto
cleanup
;
}
git_buf_swap
(
out
,
&
buf
);
cleanup:
git_buf_dispose
(
&
buf
);
return
error
;
}
...
...
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