From: Christian Couder <christian.couder@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>, "Jeff King" <peff@peff.net>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Karsten Blees" <karsten.blees@gmail.com>,
"Nguyen Thai Ngoc Duy" <pclouds@gmail.com>,
"Stefan Beller" <sbeller@google.com>,
"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Ramsay Jones" <ramsay@ramsayjones.plus.com>,
"Christian Couder" <christian.couder@gmail.com>,
"Christian Couder" <chriscool@tuxfamily.org>
Subject: [PATCH v4 2/2] builtin/apply: move 'newfd' global into 'struct apply_state'
Date: Fri, 3 Jun 2016 18:58:52 +0200 [thread overview]
Message-ID: <20160603165852.12399-2-chriscool@tuxfamily.org> (raw)
In-Reply-To: <20160603165852.12399-1-chriscool@tuxfamily.org>
From: Christian Couder <christian.couder@gmail.com>
To libify the apply functionality the 'newfd' variable should
not be static and global to the file. Let's move it into
'struct apply_state'.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
This is to replace:
[PATCH v3 49/49] builtin/apply: move 'newfd' global into 'struct apply_state'
from the "libify apply and use lib in am, part 1" patch series.
There is no change compared to the previous version except that this
patch should apply cleanly on top of PATCH v4 1/2.
builtin/apply.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/builtin/apply.c b/builtin/apply.c
index cc635eb..7338ee6 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -57,6 +57,7 @@ struct apply_state {
* lock_file structures, it isn't safe to free(lock_file).
*/
struct lock_file *lock_file;
+ int newfd;
/* These control what gets looked at and modified */
int apply; /* this is not a dry-run */
@@ -120,8 +121,6 @@ struct apply_state {
int applied_after_fixing_ws;
};
-static int newfd = -1;
-
static const char * const apply_usage[] = {
N_("git apply [<options>] [<patch>...]"),
NULL
@@ -4552,8 +4551,8 @@ static int apply_patch(struct apply_state *state,
state->apply = 0;
state->update_index = state->check_index && state->apply;
- if (state->update_index && newfd < 0)
- newfd = hold_locked_index(state->lock_file, 1);
+ if (state->update_index && state->newfd < 0)
+ state->newfd = hold_locked_index(state->lock_file, 1);
if (state->check_index) {
if (read_cache() < 0)
@@ -4662,6 +4661,7 @@ static void init_apply_state(struct apply_state *state,
state->prefix = prefix;
state->prefix_length = state->prefix ? strlen(state->prefix) : 0;
state->lock_file = lock_file;
+ state->newfd = -1;
state->apply = 1;
state->line_termination = '\n';
state->p_value = 1;
@@ -4782,6 +4782,7 @@ static int apply_all_patches(struct apply_state *state,
if (state->update_index) {
if (write_locked_index(&the_index, state->lock_file, COMMIT_LOCK))
die(_("Unable to write new index file"));
+ state->newfd = -1;
}
return !!errs;
--
2.8.2.444.g74f55c9.dirty
next prev parent reply other threads:[~2016-06-03 16:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 16:58 [PATCH v4 1/2] builtin/apply: add 'lock_file' pointer into 'struct apply_state' Christian Couder
2016-06-03 16:58 ` Christian Couder [this message]
2016-06-03 17:23 ` Christian Couder
2016-06-03 18:03 ` Junio C Hamano
2016-06-06 10:03 ` Christian Couder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160603165852.12399-2-chriscool@tuxfamily.org \
--to=christian.couder@gmail.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=avarab@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karsten.blees@gmail.com \
--cc=pclouds@gmail.com \
--cc=peff@peff.net \
--cc=ramsay@ramsayjones.plus.com \
--cc=sbeller@google.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).